PostgreSQL MCP Server — 27 tools for queries, schema, CRUD, DBA, HA & server management
Config is the same across clients — only the file and path differ.
{
"mcpServers": {
"postgres": {
"env": {
"POSTGRES_CONFIG_FILE": "/path/to/databases.yaml"
},
"args": [
"@itunified.io/mcp-postgres"
],
"command": "npx"
}
}
}Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
A comprehensive PostgreSQL MCP (Model Context Protocol) server providing 27 tools for database management and administration.
Run this in your terminal to verify the server starts. Then let us know if it worked — your result helps other developers.
npx -y '@itunified.io/mcp-postgres' 2>&1 | head -1 && echo "✓ Server started successfully"
After testing, let us know if it worked:
Five weighted categories — click any category to see the underlying evidence.
No known CVEs.
Checked @itunified.io/mcp-postgres against OSV.dev.
Click any tool to inspect its schema.
Be the first to review
Have you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Others in data
Query and manage PostgreSQL databases directly from AI assistants
🔥 Official Firecrawl MCP Server - Adds powerful web scraping and search to Cursor, Claude and any other LLM clients.
Manage Supabase projects — databases, auth, storage, and edge functions
Real-time financial market data: stocks, forex, crypto, commodities, and economic indicators
MCP Security Weekly
Get CVE alerts and security updates for io.github.itunified-io/postgres and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
A comprehensive PostgreSQL MCP (Model Context Protocol) server providing 27 tools for database management and administration.
npm install @itunified.io/mcp-postgres
Or run directly:
npx @itunified.io/mcp-postgres
Set one of the following environment variables:
# Option 1: Connection string (preferred)
export POSTGRES_CONNECTION_STRING="postgresql://myuser:mypassword@your-database.example.com:5432/mydb"
# Option 2: Individual variables
export PGHOST="your-database.example.com"
export PGPORT="5432"
export PGUSER="myuser"
export PGPASSWORD="mypassword"
export PGDATABASE="mydb"
export PGSSLMODE="require" # optional
Create a config file at ~/.config/mcp-postgres/databases.yaml:
databases:
production:
host: db.example.com
port: 5432
user: admin
password: ${DB_PROD_PASSWORD}
database: myapp
ssl: true
staging:
host: staging-db.example.com
port: 5432
user: admin
password: ${DB_STAGING_PASSWORD}
database: myapp
default: production
Environment variables in ${VAR_NAME} syntax are automatically expanded.
Config file discovery order:
POSTGRES_CONFIG_FILE env var (explicit path)~/.config/mcp-postgres/databases.yaml or databases.jsonPOSTGRES_CONNECTION_STRING env var (single database)PG* env vars (single database)Override the config path with POSTGRES_CONFIG_FILE env var:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["@itunified.io/mcp-postgres"],
"env": {
"POSTGRES_CONFIG_FILE": "/path/to/databases.yaml"
}
}
}
}
Use pg_list_connections to see all configured databases, pg_switch_database to change the active one.
mcp-postgres supports opportunistic secret loading from HashiCorp Vault via AppRole authentication. When configured, it fetches PostgreSQL credentials from a KV v2 path — so you never need to put database passwords in environment variables or config files.
How it works:
NAS_VAULT_ADDR, NAS_VAULT_ROLE_ID, and NAS_VAULT_SECRET_ID in the environmentPOSTGRES_CONNECTION_STRING and PG* env vars from the Vault secret — but only for vars not already setPrecedence: Explicit env vars → Vault → config file fallback → (error if nothing set)
| Variable | Required | Description |
|---|---|---|
NAS_VAULT_ADDR | Yes* | Vault server address (e.g., https://vault.example.com:8200) |
NAS_VAULT_ROLE_ID | Yes* | AppRole role ID for this server |
NAS_VAULT_SECRET_ID | Yes* | AppRole secret ID for this server |
NAS_VAULT_KV_MOUNT | No | KV v2 mount path (default: kv) |
* Only required if using Vault. Without these, the server uses env vars / config files directly.
Vault KV v2 secret structure:
# Path: kv/your/postgres/secret
{
"connection_string": "postgresql://myuser:mypassword@your-database.example.com:5432/
... [View full README on GitHub](https://github.com/itunified-io/mcp-postgres#readme)