pg-lens-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| DATABASE_URL | Yes | PostgreSQL connection string for the database to inspect (e.g. postgres://pglens:pglens@localhost:5433/shop). A read-only database user is recommended. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| list_tablesA | List the tables in the database (excluding system schemas), with approximate row counts. |
| describe_tableA | Describe one table: columns and types, primary key, and existing indexes. |
| explain_queryA | Run EXPLAIN (FORMAT JSON) for a SELECT query and return a plain summary: total cost, node types, sequential scans, and index scans. The query is planned, never executed, and writes are rejected. |
| suggest_indexesA | Analyse a SELECT query's plan and suggest indexes for sequential scans, with reasoning and the CREATE INDEX statement. Suggestions only — this tool never creates an index. |
| table_statsB | Statistics for one table: live/dead rows, sequential vs index scan counts, and table/index sizes. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 5 tools
Each tool targets a distinct step in a query-tuning workflow: enumeration, schema inspection, plan explanation, index suggestion, and table runtime stats. The only mild overlap is between describe_table and table_stats, which both operate on a single table, but their descriptions clearly separate schema structure from runtime statistics.
Four of five names follow a clean verb_noun snake_case pattern (list_tables, describe_table, explain_query, suggest_indexes). table_stats deviates as noun_noun, but the overall convention remains predictable and readable.
Five tools is well-scoped for a read-only Postgres diagnostics server; each tool earns its place in the list → describe → explain → suggest chain. No redundant or filler tools.
The core workflow of discovering tables, inspecting structure, analysing plans, and proposing indexes is fully covered. Minor gaps exist: no tool to enumerate schemas/views or list all indexes globally (e.g. unused or duplicate index detection), and no pg_stat_statements-style slow-query discovery.