loading…
Search for a command to run...
loading…
A PostgreSQL MCP server that enables querying and managing multiple databases through a single configuration file without needing separate server instances. It
A PostgreSQL MCP server that enables querying and managing multiple databases through a single configuration file without needing separate server instances. It provides tools for executing SQL queries, listing databases, and inspecting table schemas with built-in support for read-only transactions and connection pooling.
A single MCP server for all your Postgres databases.
Instead of configuring a separate MCP server entry for each database, pg-pool-mcp lets you define all your connections in one config file and query any of them by name. No restarts, no config juggling.
The official Postgres MCP server binds to a single database via a CLI argument. If you work with multiple databases (dev, staging, prod, or just different projects), you either need multiple MCP server entries or you're editing config and restarting every time you switch.
pg-pool-mcp gives you:
git clone <repo-url>
cd pg-pool-mcp
npm install
Create a databases.json file (see databases.example.json for reference):
{
"databases": {
"local": {
"host": "localhost",
"port": 5432,
"database": "mydb",
"user": "postgres",
"password": "$PG_PASSWORD",
"readOnly": false
},
"production": {
"connectionString": "postgresql://$PROD_USER:$PROD_PASSWORD@prod-host:5432/prod_db",
"readOnly": true
}
},
"defaults": {
"readOnly": true,
"queryTimeout": 30000,
"poolSize": 5
}
}
Each database entry supports either a connectionString or individual fields (host, port, database, user, password).
| Option | Type | Default | Description |
|---|---|---|---|
readOnly |
boolean | true |
Wrap queries in read-only transactions |
queryTimeout |
number | 30000 |
Statement timeout in milliseconds |
poolSize |
number | 5 |
Max connections in the pool |
ssl |
boolean/object | — | SSL configuration passed to pg |
String values support $VAR and ${VAR} syntax, resolved from your environment at startup. This keeps passwords out of the config file:
{
"password": "$PG_PASSWORD",
"connectionString": "postgresql://${DB_USER}:${DB_PASS}@host/db"
}
Add to ~/.claude.json (global) or .mcp.json (per-project):
{
"mcpServers": {
"multi-pg": {
"type": "stdio",
"command": "npx",
"args": [
"tsx",
"/path/to/pg-pool-mcp/src/index.ts",
"--config",
"/path/to/databases.json"
]
}
}
}
You can also set the config path via environment variable:
{
"mcpServers": {
"multi-pg": {
"type": "stdio",
"command": "npx",
"args": ["tsx", "/path/to/pg-pool-mcp/src/index.ts"],
"env": {
"MULTI_PG_MCP_CONFIG": "/path/to/databases.json"
}
}
}
}
Restart Claude Code after adding the config.
list_databasesLists all configured databases with their connection status and read-only setting. Call this first to see available database names.
queryRun a SQL query against a named database.
database -- name from your config (e.g. "local", "production")sql -- the SQL to executeIf the database is configured as readOnly: true, queries are wrapped in BEGIN TRANSACTION READ ONLY and rolled back automatically. Write attempts will fail.
list_tablesList all tables in a database with estimated row counts.
database -- name from your configschema -- schema to list (default: "public")describe_tableGet the full schema of a table: columns, types, nullability, defaults, primary keys, and foreign keys.
database -- name from your configtable -- table nameschema -- schema name (default: "public")# Type-check
npx tsc --noEmit
# Run directly
npx tsx src/index.ts --config databases.json
# Build
npm run build
ISC
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"pg-pool-mcp": {
"command": "npx",
"args": []
}
}
}Query your database in natural language
Read-only database access with schema inspection.
Interact with Redis key-value stores.
Database interaction and business intelligence capabilities.