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 |
Capabilities
Features and capabilities supported by this server
| 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 | |
Latest Blog Posts
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/eklemen/db-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server