db-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| PGHOST | No | Database host | |
| PGPORT | No | Database port | |
| PGUSER | No | Database user | |
| PGSSLMODE | No | SSL mode | disable |
| PGDATABASE | No | Database name | |
| PGPASSWORD | No | Database password | |
| DATABASE_URL | No | Full connection string (wins over PG*) | |
| DB_MCP_DRIVER | No | Database driver | postgres |
| DB_MCP_MAX_ROWS | No | Hard cap for run_readonly_query | 1000 |
| DB_MCP_DEFAULT_SCHEMA | No | Default schema | public |
| DB_MCP_SAMPLE_MAX_ROWS | No | Hard cap for sample_rows | 50 |
| DB_MCP_MAX_QUERY_LENGTH | No | Max query length | 10000 |
| DB_MCP_STATEMENT_TIMEOUT_MS | No | Per-statement timeout | 5000 |
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_databasesA | List databases the read-only user can connect to, with owner and comment when available. |
| list_schemasA | List schemas (namespaces) the read-only user can access. Excludes system schemas (pg_*, information_schema). |
| list_tablesA | List tables and views in a schema. Returns name, type (table/view/materialized view/foreign table), a planner row estimate when available, and any comment. Defaults to the configured default schema. |
| describe_tableA | Describe a table: columns (type, nullability, default, comment), primary key, foreign keys, unique constraints, check constraints, and indexes. |
| get_table_ddlA | Return the reconstructed CREATE TABLE DDL for a table (PostgreSQL has no SHOW CREATE TABLE, so this is the closest supported reconstruction from the catalog, including constraints and indexes). |
| get_relationshipsA | List foreign-key relationships with constraint names, referenced tables/columns, ON UPDATE/DELETE actions, and a cardinality hint (1:1 when the FK columns are uniquely constrained locally, otherwise many:1). Optionally filter by schema and/or table. |
| get_indexesA | List indexes on a table: name, access method (btree/gin/gist/...), uniqueness, whether it backs the primary key, ordered columns with sort direction and NULLS ordering, and any partial-index predicate. |
| sample_rowsA | Return a small sample of rows from a table. The limit is capped at the server's hard maximum (default 50) regardless of the requested value. |
| run_readonly_queryA | Execute a single read-only SQL query (SELECT / EXPLAIN-without-ANALYZE / SHOW). The query is validated with a real PostgreSQL parser and rejected if it contains any write, DDL, data-modifying CTE, multiple statements, or other side effect. Results are capped at the server row maximum. Returns columns, rows, row count, execution time, and a truncation flag. |
| search_schemaA | Search across the schema for a term (case-insensitive substring). Matches table names, column names, table/column comments, constraint names, and index names. Optionally restrict to a single schema. |
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 10 tools
Each tool has a clearly distinct purpose: describing table structure, fetching indexes, listing foreign keys, retrieving DDL, enumerating databases/schemas/tables, running queries, sampling rows, and searching schema metadata. No two tools overlap in functionality.
All tools follow a consistent verb_noun pattern using snake_case (e.g., describe_table, list_schemas, run_readonly_query). The verbs accurately describe the action (describe, get, list, run, sample, search), and there are no mixed naming conventions.
With 10 tools, the server is well-scoped for database introspection and read-only queries. Each tool addresses a distinct need without redundancy or excessive granularity, fitting the typical range of 3-15 tools for a focused domain.
The tool set covers core CRUD-like operations for database metadata (create via DDL retrieval, read via descriptions and queries, and listing). Minor gaps exist, such as missing explicit tools for table size estimation or listing extensions, but most common exploration workflows are supported.