Pg Pool
FreeNot checkedA PostgreSQL MCP server that enables querying and managing multiple databases through a single configuration file without needing separate server instances. It
About
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.
README
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.
Why?
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:
- One MCP server, many databases -- configure once, query any database by name
- Lazy connection pooling -- connects on first use, not at startup
- Read-only by default -- queries are wrapped in read-only transactions unless you opt in to writes
- Query timeouts -- prevents runaway queries from hanging your session
- Environment variable interpolation -- keep secrets out of your config file
Setup
git clone <repo-url>
cd pg-pool-mcp
npm install
Configuration
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).
Per-database options
| 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 |
Environment variable interpolation
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"
}
Register with Claude Code
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.
Tools
list_databases
Lists all configured databases with their connection status and read-only setting. Call this first to see available database names.
query
Run a SQL query against a named database.
database-- name from your config (e.g."local","production")sql-- the SQL to execute
If the database is configured as readOnly: true, queries are wrapped in BEGIN TRANSACTION READ ONLY and rolled back automatically. Write attempts will fail.
list_tables
List all tables in a database with estimated row counts.
database-- name from your configschema-- schema to list (default:"public")
describe_table
Get 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")
Development
# Type-check
npx tsc --noEmit
# Run directly
npx tsx src/index.ts --config databases.json
# Build
npm run build
License
ISC
Installing Pg Pool
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/sam-david/pg-pool-mcpFAQ
Is Pg Pool MCP free?
Yes, Pg Pool MCP is free — one-click install via Unyly at no cost.
Does Pg Pool need an API key?
No, Pg Pool runs without API keys or environment variables.
Is Pg Pool hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Pg Pool in Claude Desktop, Claude Code or Cursor?
Open Pg Pool on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
wenb1n-dev/SmartDB_MCP
A universal database MCP server supporting simultaneous connections to multiple databases. It provides tools for database operations, health analysis, SQL optim
by wenb1n-devPostgres Server
This server enables interaction with PostgreSQL databases through the Model Context Protocol, optimized for the AWS Bedrock AgentCore Runtime. It provides tools
by madhurprashPostgres
Query your database in natural language
by AnthropicPostgreSQL
Read-only database access with schema inspection.
by modelcontextprotocolCompare Pg Pool with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All data MCPs
