Database · 2 skills

PostgreSQL MCP and Claude skills

Run read-only SQL against PostgreSQL for business numbers and database health: signups, slow queries, dead tuples, connections and size growth.

Connect PostgreSQL to your agent (MCP)

  1. MCP server. The PostgreSQL project doesn't publish an MCP server, and the reference Postgres server from the MCP project has been archived. A common community choice is Postgres MCP Pro (postgres-mcp), whose --access-mode=restricted runs every statement in a read-only transaction with a time limit: claude mcp add --env DATABASE_URI=postgresql://report_reader:<password>@db.example.com:5432/app --transport stdio postgres -- uvx postgres-mcp --access-mode=restricted. In Codex and Cursor, put the same command, arguments and DATABASE_URI in the server config. Managed hosts such as Supabase and Neon run their own MCP servers.
  2. psql with a connection string. Claude Code and Codex can run psql "$DATABASE_URL" -X -A -F ',' -c "SELECT ..." directly; it needs only the client and the URL.
  3. A read-only role, used by both: CREATE ROLE report_reader LOGIN PASSWORD '...', GRANT CONNECT ON DATABASE app TO report_reader, then GRANT pg_read_all_data, pg_monitor TO report_reader on Postgres 14 and later (on older versions, grant USAGE on the schema and SELECT on its tables). Add ALTER ROLE report_reader SET default_transaction_read_only = on and ALTER ROLE report_reader SET statement_timeout = '30s'.

The role is the safeguard that holds whichever tool connects: with only read privileges it can't write, alter or drop anything, pg_monitor lets it see the statistics views, and the timeout stops a runaway query. Point it at a read replica if you have one.

2 PostgreSQL skills

What agents do with PostgreSQL

With a connection string, an agent answers two kinds of questions. Business ones come from your own tables: new signups per day, orders, active accounts, rows created since yesterday. Health ones come from Postgres's statistics views. pg_stat_statements (from the extension of the same name) ranks queries by total_exec_time, mean_exec_time and calls; pg_stat_activity shows sessions with their state, query_start and wait_event, so long-running and idle-in-transaction sessions stand out; pg_stat_user_tables gives n_live_tup, n_dead_tup, seq_scan and last_autovacuum; and pg_database_size() and pg_total_relation_size() track growth.

Teams schedule a daily metrics post from a few saved queries, a weekly list of the slowest queries, tables with many dead tuples or no recent autovacuum, connections against max_connections, and database size against last month.

postgresql.org

Your PostgreSQL numbers, on one board with everything else

Skills are free to use with any agent. Briefkin is where their results land: one board for every report, number and question your agents send, with a ping when something needs you.

Free during the open beta. No card.