Python MCP server for PostgreSQL database inspection and querying
Most database access work still happens through a UI a human drives. PostgreSQL MCP server moves it into the conversation instead. Python MCP server for PostgreSQL database inspection and querying.
A Python Model Context Protocol (MCP) server for inspecting and querying PostgreSQL databases from MCP-compatible clients. It provides schema discovery, safe read-only query execution, query explanation, table previews, index analysis, relationship inspection, and PostgreSQL resources for table metadata.
The server publishes 10 tools. What each one is for:
postgresql_list_tables — List public base tablespostgresql_describe_table — Show columns and metadata for a tablepostgresql_execute_read_query — Run bounded SQL under read-only transaction modepostgresql_execute_write_query — Run a single approved modifying SQL statement and commitpostgresql_explain_query — Return PostgreSQL EXPLAIN output for a single querypostgresql_get_database_summary — Return database version and table countpostgresql_get_relationships — Inspect foreign-key relationshipspostgresql_analyze_indexes — Inspect indexes and sizespostgresql_preview_table — Return up to 10 rows from a tablepostgresql_search_sql_definitions — Search public SQL routines/functionsInstallation goes through your MCP client rather than a global install: point it at mdev-postgresql-mcp-server on PyPI and it is fetched when the client starts. The copy-paste blocks for Claude Desktop, Claude Code and Cursor are further down this page.
Configuration is passed through the environment: POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB. Treat anything key-shaped as a real credential — scope it to the minimum the server needs, and rotate it if it ever lands in a shared config.
Among the database access options, the useful question is rarely "what can it do" but "what does it cost you to run" — permissions, credentials, and how much of your context its toolset consumes. PostgreSQL's toolset — postgresql_list_tables, postgresql_describe_table, postgresql_execute_read_query and 7 more — is a fair guide to whether it matches your workflow. It is maintained by musaddiq-dev; worth a glance at recent repository activity before you build anything load-bearing on it.
This entry was verified against PostgreSQL's own documentation before publication; SyncDev keeps the directory reviewed rather than auto-generated.
| Tool | What it does |
|---|---|
| postgresql_list_tables | List public base tables |
| postgresql_describe_table | Show columns and metadata for a table |
| postgresql_execute_read_query | Run bounded SQL under read-only transaction mode |
| postgresql_execute_write_query | Run a single approved modifying SQL statement and commit |
| postgresql_explain_query | Return PostgreSQL EXPLAIN output for a single query |
| postgresql_get_database_summary | Return database version and table count |
| postgresql_get_relationships | Inspect foreign-key relationships |
| postgresql_analyze_indexes | Inspect indexes and sizes |
| postgresql_preview_table | Return up to 10 rows from a table |
| postgresql_search_sql_definitions | Search public SQL routines/functions |
{
"mcpServers": {
"postgresql-server": {
"command": "uvx",
"args": ["mdev-postgresql-mcp-server"],
"env": {
"POSTGRES_HOST": "your-value",
"POSTGRES_PORT": "your-value",
"POSTGRES_USER": "your-value",
"POSTGRES_PASSWORD": "your-value",
"POSTGRES_DB": "your-value"
}
}
}
}Add to claude_desktop_config.json, then restart Claude Desktop.
| Variable | Description | Required |
|---|---|---|
| POSTGRES_HOST | Endpoint or connection string the server talks to. | Optional |
| POSTGRES_PORT | Configuration value read at startup. | Optional |
| POSTGRES_USER | Configuration value read at startup. | Optional |
| POSTGRES_PASSWORD | Configuration value read at startup. | Optional |
| POSTGRES_DB | Configuration value read at startup. | Optional |
Read-only SQL access to Postgres — let your assistant inspect schemas and answer questions from real data.
Manage your whole Supabase project in conversation — database, auth, storage, Edge Functions and branches.
Query, modify and analyse local SQLite databases in conversation — the fastest way to chat with a data file.
Metabase ships its own MCP endpoint — search your BI content, build and run queries, and save questions and dashboards without leaving the chat.
Official MongoDB server covering data, schemas and Atlas management — from find queries to spinning up clusters.
Serverless Postgres with database branching — point your assistant at Neon and let it work on disposable copies.