PostgreSQL MCP Server
PostgreSQL MCP server - query, schema introspection, explain, and health checks for AI assistants
Connector by YawLabs · GitHub account verified by the MCP Registry
Install
Works with Claude Code, Codex, VS Code, Cursor, Windsurf, Claude Desktop. Read the repository before you give any tool access to your data.
npx agentmarket install connector/yawlabs-postgres-mcp
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: database-access, monitoring-observability
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this server can do and what it asks for, from its tool list, install config and code. Checked Oct 25, 2026.
- Tools
- 20 read · 0 write · 3 delete
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Node.js package
Tools by what they do 23
Read from the source code; the running server may list different tools.
Read 20 · Look things up without changing anything.
pg_advisorpg_describe_tablepg_healthpg_index_advisorpg_inspect_lockspg_io_statspg_list_extensionspg_list_functionspg_list_rolespg_list_schemaspg_list_tablespg_list_views
Show 8 more tools
pg_readonlypg_replication_statuspg_search_columnspg_seq_scan_tablespg_table_bloatpg_table_privilegespg_top_queriespg_unused_indexes
Delete 3 · Delete, drop, revoke or wipe things.
pg_explainpg_killpg_query
Network hosts it talks to 7
api.github.com· found in codeapt.postgresql.org· found in codebiomejs.dev· found in codegithub.com· found in codeoamjs.org· found in codepostgresql.org· found in codeyaw.sh· found in code
Files it touches
- Your home directory (~)
~/yaw/homebrew-yaw~/yaw/scoop-yaw
Tools (23)
Read from the source code; the running server may differ. Descriptions are the server’s own words; hidden characters are shown as [U+…].
pg_advisorDatabase advisor (DBA lints)read-onlyDescription is built at runtime.
pg_describe_tableDescribe tableread-onlyDescribe a relation: kind (table / view / materialized_view / partitioned_table / foreign_table), columns (name, type, nullable, default, `generated`, `identity`), primary key, foreign keys (outgoing), `referenced_by` (other tables whose FKs point at this one), `constraints` (CHECK / UNIQUE non-PK / EXCLUDE), indexes, and partition info (`partition_of` parent, `partitions` children). Works on views and materialized views too -- PK/FK/constraint/index lists will simply be empty for a plain view. Use `kind` to disambiguate before assuming you can write to the relation. Generated columns (`genera…
pg_explainExplain query plancan change or delete dataGet the query plan for a SQL statement. By default, this uses plain EXPLAIN (no execution). Set `analyze: true` to run the query with EXPLAIN ANALYZE - for non-SELECT statements, ALLOW_WRITES=1 is required (since ANALYZE actually executes the statement). Writes executed during EXPLAIN ANALYZE are rolled back, so you can inspect a plan for an INSERT/UPDATE/DELETE without persisting the rows -- but only what Postgres rolls back is undone: a sequence the statement advanced (nextval, a serial or identity column) stays advanced, and any side effect of a function the statement called that lands outs…
pg_healthDatabase health snapshotread-onlyDescription is built at runtime.
pg_index_advisorRecommend indexes for a workloadread-onlyDescription is built at runtime.
pg_inspect_locksInspect blocking locksread-onlyShow current lock contention: which sessions are blocked and who is blocking them. Returns blocked PID, blocking PID, lock types, relation being contested, and the queries involved. Use this first when a tool call hangs or the app feels stuck - it's the fastest way to identify a long-held transaction holding a lock. Row shape: one row per (blocked_pid, blocking_pid) pair. A session waiting on multiple blockers appears on multiple rows -- group/deduplicate by `blocked_pid` if you want a per-blocked-session count. Scope: CLUSTER-WIDE, unlike `pg_health` active_queries, which is filtered to the d…
pg_io_statsI/O statistics and in-flight async I/Oread-onlyDescription is built at runtime.
pg_killCancel or terminate a backendcan change or delete dataCancel a running query (SIGINT-equivalent) or terminate a backend connection (SIGTERM-equivalent) by PID. Find the PID via `pg_health` active_queries or `pg_inspect_locks`. Requires ALLOW_WRITES=1 since this changes database session state. The role in DATABASE_URL must have permission - cancelling another user's query needs the `pg_signal_backend` role or superuser. Note: `pg_signal_backend` does NOT cover superuser-owned backends - only a superuser can signal another superuser's session. Cancel is graceful; terminate is forceful. `signaled=true` means postgres SENT the signal, not that the ta…
pg_list_extensionsList installed extensionsread-onlyList installed PostgreSQL extensions. Returns name, version, schema, and description. Useful to check for pgvector, postgis, pg_stat_statements, uuid-ossp, etc. before writing queries that rely on them.
pg_list_functionsList functions and proceduresread-onlyList functions, procedures, and aggregates in a schema. Returns name, arguments, return type, kind (function/procedure/aggregate/window), and implementation language.
pg_list_rolesList rolesread-onlyList database roles (users and groups) with their login/superuser/createdb/createrole attributes and inherited role memberships. Use this to answer 'who has access to this database?' without needing to read `pg_authid` directly.
pg_list_schemasList schemasread-onlyList non-system schemas in the database. Excludes `pg_catalog`, `information_schema`, and other `pg_*` internals.
pg_list_tablesList tables in a schemaread-onlyList tables (and optionally views) in a schema. Returns name, type (table/view/materialized view/foreign), and estimated row count (from `reltuples`; null = no ANALYZE yet on PG 14+; 0 may mean empty or unanalyzed on PG <= 13). Paginate via `limit`/`offset` on very large schemas.
pg_list_viewsList views with definitionsread-onlyList views and materialized views in a schema with their SQL definitions. Use this over `pg_list_tables` with `includeViews: true` when you want the view body, not just names.
pg_queryRun SQL querycan change or delete dataRun a SQL query against the configured PostgreSQL database. Postgres itself is the primary safety gate: the role in `DATABASE_URL` enforces what queries can succeed. The recommended posture is a least-privileged role (e.g. one granted `pg_read_all_data`), which makes writes server-rejected regardless of any env var. `ALLOW_WRITES=1` is a secondary belt-and-braces gate - it lifts the in-server `BEGIN READ ONLY` wrapper, but it cannot grant privileges the role lacks. Useful for managed databases where creating a second role is awkward. For read-only access where you want the guarantee in the too…
Show 8 more tools
pg_readonlyRun read-only SQLread-onlyRun a SQL statement with no persistent data changes. Always executes inside a `BEGIN READ ONLY` transaction regardless of `ALLOW_WRITES`, so postgres itself rejects any INSERT/UPDATE/DELETE/DDL and the transaction is always rolled back. Use this whenever the goal is to read - SELECT, EXPLAIN, SHOW, VALUES, WITH ... SELECT, etc. Scope caveat for hosts that auto-allow this tool: `READ ONLY` constrains writes to the DATABASE, not every side effect. Functions whose effect is outside the table data - `pg_cancel_backend` / `pg_terminate_backend`, `pg_read_file`, `lo_export`, `COPY ... TO PROGRAM` - …
pg_replication_statusReplication statusread-onlyReplication overview: configured replication slots, connected replicas (from `pg_stat_replication`), and current WAL position. Use on primary to spot lagging or disconnected replicas, on replicas to see upstream status. Returns empty arrays on a standalone (non-replicated) database rather than erroring.
pg_search_columnsSearch columns by nameread-onlySearch for columns by name across all user schemas. Supports SQL LIKE patterns (`%` matches any substring, `_` matches one character). Case-insensitive. Use this instead of iterating `pg_describe_table` when the user asks 'which tables have X'.
pg_seq_scan_tablesFind tables with heavy sequential scansread-onlyTables with high sequential-scan counts relative to index scans - the first place to look for missing-index candidates. Returns `{rows, stats_reset, stats_reset_age_seconds}`: each row has seq_scans, idx_scans, live tuples, and the ratio. A high ratio on a large table usually means a query is reading the whole table where an index would suffice. Pair with `pg_top_queries` to find which query is doing it. These counters are cumulative since the last statistics reset, so every ratio here is only meaningful relative to the top-level `stats_reset` (and `stats_reset_age_seconds`). A ratio measured …
pg_table_bloatEstimate table bloatread-onlyEstimate table bloat (dead tuples + free space) for tables in a schema. Returns live tuples, dead tuples, dead-tuple ratio, last_vacuum / last_autovacuum timestamps, and total relation size. A high dead_ratio with a stale last_autovacuum is a sign a table needs VACUUM. On PostgreSQL 19+ every row also carries `stats_reset`: the last time THAT relation's counters were reset via `pg_stat_reset_single_table_counters()`. Read it before trusting anything else in the row -- a reset zeroes live_tuples and dead_tuples AND clears last_vacuum / last_autovacuum / last_analyze together, so a table reset a…
pg_table_privilegesShow table privilegesread-onlyShow which roles have which privileges (SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER) on a table or on every table in a schema. If `table` is omitted, the result spans every table in `schema`, ordered by table then grantee. Use this to answer 'who can write to this table?' or to audit schema-wide access before a migration. Visibility caveat: backed by `information_schema.table_privileges`, which postgres filters by what the calling role can see. A least-privileged role may not see grants involving unrelated third-party roles. For a complete picture, run as a superuser or a mem…
pg_top_queriesTop queries by execution timeread-onlyTop N queries by total or mean execution time. Requires the `pg_stat_statements` extension to be installed and enabled (most managed Postgres providers have it on by default). Returns `{rows, stats_reset, stats_reset_age_seconds, dealloc}`: each row has normalized query text (constants replaced with `?`), call count, total/mean/min/max time in ms, rows returned, and cache hit ratio. Use this to find slow queries worth optimizing. `calls` and `total_time_ms` are cumulative since the last `pg_stat_statements_reset()`, so this ranking only describes the window that started at the top-level `stats…
pg_unused_indexesFind unused indexesread-onlyIndexes that have never been scanned or have very low usage, largest first. Each unused index costs write amplification (every INSERT/UPDATE maintains it) and disk space, so before adding a new index, check whether the fix is to drop a dead one. Returns `{rows, stats_reset, stats_reset_age_seconds}`. READ THIS BEFORE RECOMMENDING A DROP: `scans` is a counter, not a verdict. It only counts since the last statistics reset, which is why the top-level `stats_reset` and `stats_reset_age_seconds` are part of the answer. If the counters were reset an hour ago, EVERY index looks unused; if `stats_rese…
Compare and alternatives
Featured in
Signals
- Stars
- 10
- Forks
- 2
- Open issues
- 0
- Last commit
- Oct 15, 2026 (13 days ago)
- Last release
- Oct 11, 2026 (17 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- Registry name
io.github.YawLabs/postgres-mcp- Version
- 0.13.9
- Auth
- No auth
- Packages
- npm @yawlabs/postgres-mcp
- License
- MIT
- Repository
- github.com/YawLabs/postgres-mcp
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
More from YawLabs
- 0.665score
Tailscale MCP Server
YawLabs
Tailscale MCP server for managing your tailnet from AI assistants
ConnectorAFreshness: ALocal★ 34Claude Code +5 - 0.648score
ctxlint
YawLabs
Lint AI agent context files (CLAUDE.md, AGENTS.md, etc.) against your actual codebase
ConnectorAFreshness: ALocal★ 11Claude Code +5 - 0.636score
Caddy MCP Server
YawLabs
MCP server for managing Caddy web servers via the admin API
ConnectorAFreshness: ALocal★ 12Claude Code +5 - 0.634score
Yaw Labs AWS MCP
YawLabs
AWS MCP server — call any AWS API from AI assistants, with first-class SSO re-login
ConnectorAFreshness: ALocal★ 5Claude Code +5 - 0.630score
LemonSqueezy MCP Server
YawLabs
LemonSqueezy MCP server for managing your store from AI assistants
ConnectorAFreshness: ALocal★ 4Claude Code +5 - 0.625score
SSH MCP Server
YawLabs
MCP server for SSH operations with built-in diagnostics
ConnectorAFreshness: ALocal★ 6Claude Code +5
Cite this page
PostgreSQL MCP Server. Agent Mart. https://agentmart.dev/connectors/yawlabs-postgres-mcp (last updated 2026-10-24)