
PostgreSQL MCP Server
Connects Claude directly to your PostgreSQL databases with the essentials: run queries, inspect schema structure, check query plans with EXPLAIN, and ping database health. Useful when you want Claude to help debug slow queries, explore unfamiliar table structures, or write SQL against your actual schema without copy-pasting DDL back and forth. The stdio transport means it runs locally, keeping your database credentials on your machine. Straightforward tool for anyone who spends time in Postgres and wants an AI that can see what you're working with.
- GitHub stars
- 10
- tools
- 23
- transport
- STDIO
- last updated
- Nov 12, 2026
Tools
23 toolsPublic tool metadata for what this MCP can expose to an agent.
pg_readonlyRun a SQL statement with no persistent data changes - always inside BEGIN READ ONLY, regardless of ALLOW_WRITES.
Run a SQL statement with no persistent data changes - always inside BEGIN READ ONLY, regardless of ALLOW_WRITES.
No parameter schema in public metadata yet.
pg_queryRun a SQL query. Writes gated by the role in DATABASE_URL first, ALLOW_WRITES second.
Run a SQL query. Writes gated by the role in DATABASE_URL first, ALLOW_WRITES second.
No parameter schema in public metadata yet.
pg_list_schemasList non-system schemas.
List non-system schemas.
No parameter schema in public metadata yet.
pg_list_tablesList tables (and optionally views) in a schema with estimated row counts.
List tables (and optionally views) in a schema with estimated row counts.
No parameter schema in public metadata yet.
pg_describe_tableKind, columns, PK, outgoing FKs, incoming FKs, CHECK / UNIQUE / EXCLUDE constraints, indexes, and partition parent/children for a relation.
Kind, columns, PK, outgoing FKs, incoming FKs, CHECK / UNIQUE / EXCLUDE constraints, indexes, and partition parent/children for a relation.
No parameter schema in public metadata yet.
pg_list_viewsList views and materialized views in a schema, including their SQL definitions.
List views and materialized views in a schema, including their SQL definitions.
No parameter schema in public metadata yet.
pg_list_functionsList functions, procedures, and aggregates in a schema with signatures and return types.
List functions, procedures, and aggregates in a schema with signatures and return types.
No parameter schema in public metadata yet.
pg_list_extensionsList installed extensions with versions.
List installed extensions with versions.
No parameter schema in public metadata yet.
pg_search_columnsFind columns by name pattern across all user schemas.
Find columns by name pattern across all user schemas.
No parameter schema in public metadata yet.
pg_explainEXPLAIN or EXPLAIN ANALYZE for a SQL statement. Text or JSON output.
EXPLAIN or EXPLAIN ANALYZE for a SQL statement. Text or JSON output.
No parameter schema in public metadata yet.
pg_index_advisorRecommend indexes for a workload and prove each one pays for itself first, using HypoPG hypothetical indexes.
Recommend indexes for a workload and prove each one pays for itself first, using HypoPG hypothetical indexes.
No parameter schema in public metadata yet.
pg_healthServer version, database size, connections, active queries, pg_stat_database rollup, table count.
Server version, database size, connections, active queries, pg_stat_database rollup, table count.
No parameter schema in public metadata yet.
pg_top_queriesTop N queries by total/mean execution time. Requires the pg_stat_statements extension.
Top N queries by total/mean execution time. Requires the pg_stat_statements extension.
No parameter schema in public metadata yet.
pg_seq_scan_tablesTables with heavy sequential scans - missing-index candidates.
Tables with heavy sequential scans - missing-index candidates.
No parameter schema in public metadata yet.
pg_unused_indexesNon-unique, non-primary indexes with low scan counts - drop candidates.
Non-unique, non-primary indexes with low scan counts - drop candidates.
No parameter schema in public metadata yet.
pg_io_statsI/O observability from pg_stat_io, plus in-flight async I/O handles and active io_method (PG18+).
I/O observability from pg_stat_io, plus in-flight async I/O handles and active io_method (PG18+).
No parameter schema in public metadata yet.
pg_inspect_locksWho is blocking whom right now (blocked PID, blocker PID, lock type, queries).
Who is blocking whom right now (blocked PID, blocker PID, lock type, queries).
No parameter schema in public metadata yet.
pg_list_rolesDatabase roles with login/superuser/createdb flags and group memberships.
Database roles with login/superuser/createdb flags and group memberships.
No parameter schema in public metadata yet.
pg_table_privilegesWho has SELECT/INSERT/UPDATE/DELETE/etc. on a table or whole schema.
Who has SELECT/INSERT/UPDATE/DELETE/etc. on a table or whole schema.
No parameter schema in public metadata yet.
pg_table_bloatTables with high dead-tuple ratios - VACUUM candidates.
Tables with high dead-tuple ratios - VACUUM candidates.
No parameter schema in public metadata yet.
pg_replication_statusReplication slots, connected replicas, and current WAL position.
Replication slots, connected replicas, and current WAL position.
No parameter schema in public metadata yet.
pg_advisorRolled-up DBA lints in one call: sequence exhaustion, wraparound risk, tables without a primary key, and public tables with RLS disabled.
Rolled-up DBA lints in one call: sequence exhaustion, wraparound risk, tables without a primary key, and public tables with RLS disabled.
No parameter schema in public metadata yet.
pg_killCancel a running query or terminate a backend connection. Requires ALLOW_WRITES=1.
Cancel a running query or terminate a backend connection. Requires ALLOW_WRITES=1.
No parameter schema in public metadata yet.
Sponsors
Readme
@yawlabs/postgres-mcp
One click adds this to your local Yaw MCP config so it's available in every Yaw Terminal session. Or install manually below.
Query a PostgreSQL database from Claude Code, Cursor, and any MCP client. Read-only by default - writes opt in via a single env var - so an agent can't silently drop your tables.
Built and maintained by Yaw Labs.
What's new in 0.12
An index advisor, opt-in audit logging, structured tool output, and support for current-revision MCP clients. Full detail in the CHANGELOG.
Details
- Repository
- github.com/yawlabs/postgres-mcp
- Website
- yaw.sh/mcp-servers/postgres-mcp
- Category
- Databases
- Package
@yawlabs/postgres-mcp- Transport
- STDIO
- Registry
- MCP registry, active