@yawlabs/postgres-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| ALLOW_WRITES | No | Set to '1' or 'true' to allow write operations via pg_query and pg_explain ANALYZE-of-writes. Default is unset (read-only). | |
| DATABASE_URL | Yes | PostgreSQL connection string (required). | |
| POSTGRES_MAX_ROWS | No | Maximum rows returned by pg_query. Default is 1000. | 1000 |
| POSTGRES_POOL_MAX | No | Maximum pool connections. Default is 5. | 5 |
| POSTGRES_STATEMENT_TIMEOUT_MS | No | Per-statement timeout in milliseconds. Default is 30000. | 30000 |
| POSTGRES_CONNECTION_TIMEOUT_MS | No | TCP connect timeout in milliseconds. Default is 10000. | 10000 |
| POSTGRES_SSL_REJECT_UNAUTHORIZED | No | Set to 'false' to skip TLS cert verification (connection remains encrypted). Default is unset. |
Capabilities
Features and capabilities supported by this server
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| pg_readonlyA | Run a SQL statement with no persistent data changes. Always executes inside a |
| pg_queryA | Run a SQL query against the configured PostgreSQL database. Postgres itself is the primary safety gate: the role in |
| pg_list_schemasA | List non-system schemas in the database. Excludes |
| pg_list_tablesA | List tables (and optionally views) in a schema. Returns name, type (table/view/materialized view/foreign), and estimated row count (from |
| pg_describe_tableA | Describe a relation: kind (table / view / materialized_view / partitioned_table / foreign_table), columns (name, type, nullable, default), primary key, foreign keys (outgoing), |
| pg_list_viewsA | List views and materialized views in a schema with their SQL definitions. Use this over |
| pg_list_functionsA | List functions, procedures, and aggregates in a schema. Returns name, arguments, return type, kind (function/procedure/aggregate/window), and implementation language. |
| pg_list_extensionsA | List 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_search_columnsA | Search for columns by name across all user schemas. Supports SQL LIKE patterns ( |
| pg_explainA | Get the query plan for a SQL statement. By default, this uses plain EXPLAIN (no execution). Set |
| pg_healthA | Quick health snapshot: server version, database size, connection count, active queries, and table count. Useful as a connection sanity check and to spot runaway queries. |
| pg_top_queriesA | Top N queries by total or mean execution time. Requires the |
| pg_seq_scan_tablesA | Tables with high sequential-scan counts relative to index scans - the first place to look for missing-index candidates. Returns 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_unused_indexesA | Indexes that have never been scanned or have very low usage. Each unused index costs write amplification (every INSERT/UPDATE maintains it) and disk space. Excludes primary keys and unique constraints (which are load-bearing even with zero scans). Use this before adding new indexes - sometimes the fix is to drop a dead one. |
| pg_inspect_locksA | Show 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 |
| pg_list_rolesA | List 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_table_privilegesA | Show which roles have which privileges (SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER) on a table or on every table in a schema. If |
| pg_killA | Cancel a running query (SIGINT-equivalent) or terminate a backend connection (SIGTERM-equivalent) by PID. Find the PID via |
| pg_replication_statusA | Replication overview: configured replication slots, connected replicas (from |
| pg_advisorA | Rolled-up DBA lint pass. One call returns three categories of findings:
|
| pg_table_bloatA | Estimate 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. Three methods are available via the
|
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/YawLabs/postgres-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server