PostgreSQL is a Databases MCP server that lets Claude Code, Cursor, Windsurf and any MCP-compatible AI agent query and manage PostgreSQL databases. Install in 1 minute with mcpizy install postgres.
Databases
Query and manage PostgreSQL databases
Official homepagemcpizy install postgresnpx -y @modelcontextprotocol/server-postgresqueryExecute a read-only SQL query and return rows
Inputs
sqlstringrequiredlist_schemasList all schemas in the database
list_tablesList tables in a given schema
Inputs
schemastringoptionaldescribe_tableReturn column names and types for a table
Inputs
tablestringrequiredWorks identically across clients. Only the config file path differs.
~/.claude.json{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@host:5432/dbname"
]
}
}
}.cursor/mcp.json{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@host:5432/dbname"
]
}
}
}~/.codeium/windsurf/mcp_config.json{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@host:5432/dbname"
]
}
}
}Copy your Postgres connection string from your hosting provider
POSTGRES_CONNECTION_STRINGPaste any of these prompts into Claude Code, Cursor or another MCP-compatible client.
“List all tables in the `public` schema and count the rows in each”
Uses: list_tables, query
“Describe the structure of the `orders` table”
Uses: describe_table
“Find the top 10 customers by total revenue in the last 30 days”
Uses: query
“Show me the 5 slowest queries from `pg_stat_statements`”
Uses: query
Postgres MCP is the smallest, fastest, most general-purpose database MCP server in the catalog. It does one thing well: hand a connection string to your AI agent and let it run SQL. No auth platform layer, no storage, no functions — just `query`, `list_schemas`, `describe_table`. That tight surface is exactly what you want for read-heavy data analysis or for letting Claude reason about a schema before writing application code.
The right use cases: ad-hoc analytics ("how many active users registered in the last 7 days, broken down by referrer"), schema exploration ("describe every table that references `users.id`"), and read-only data-pull workflows. We pair it with Claude Sonnet for production querying — 4 tools is small enough that the model never gets confused about which to call. For migrations and platform-level work, switch to Supabase MCP or Neon MCP, which expose richer primitives.
Token cost is the lowest of any DB MCP — describe-table on a 20-column table costs ~600 tokens; a query returning 50 rows of 5 columns is ~1.5k. Connection security is the core risk: if you hand the agent a connection string with full DDL rights, it can drop tables. The server has no built-in sandbox; use a read-only Postgres role for analysis workflows, switch to a write role only when explicit human approval gates the action.
Postgres MCP runs SQL verbatim — there's no query planner safety check. An agent that decides to "see all rows" will run `SELECT * FROM events` against a 50M-row table and hang. Always include a `LIMIT` instruction in your prompt or pre-create read-only views with sane defaults.
The `query` tool returns rows as JSON, which inflates token cost on wide tables. For analytics on > 100 rows, ask the agent to use `SELECT … GROUP BY` aggregates rather than fetching raw rows.
Connection pooling: each tool call opens a new connection unless you front the server with PgBouncer. For agents running long sessions with many sequential queries, point the connection string at the pooler port (typically 6543 on managed Postgres) to avoid exhausting `max_connections`.
Schema introspection is fast on small DBs but slow on Postgres clusters with thousands of tables (some Supabase users hit this). If `list_schemas` takes > 5s, restrict the role's `search_path` to the schemas the agent actually needs.
Honest pros/cons against the closest databases MCP servers.
| Server | Strengths | Trade-offs |
|---|---|---|
| Supabase MCP | Full platform: auth, storage, edge functions, advisors | Bigger blast radius, requires Supabase project (not portable) |
| Neon MCP | Database branching, autoscaling serverless Postgres | Tied to Neon; cold-start latency on first query |
| SQLite MCP | Zero infra, perfect for local dev / single-file analytics | No concurrency, not for production multi-writer workloads |
If PostgreSQL doesn't fit your stack, these Databases MCP servers solve similar problems.
The PostgreSQL MCP server is an Databases Model Context Protocol server that lets Claude Code, Cursor, Windsurf, VS Code with Copilot, and other MCP-compatible AI agents query and manage PostgreSQL databases. It exposes PostgreSQL's capabilities as tools the AI can call directly from your editor or CLI.
The fastest way is the MCPizy CLI: run `mcpizy install postgres` and MCPizy will add the server to your `.claude.json` automatically. You can also install it manually by adding an entry under `mcpServers` in `.claude.json` with the command `npx -y @modelcontextprotocol/server-postgres` and restarting Claude Code.
Yes. The PostgreSQL MCP server is free and open source (see the GitHub repository linked on this page). You may still need a PostgreSQL account or API key to connect the server to the underlying service, but the MCP layer itself has no MCPizy subscription cost.
Yes. Any MCP-compatible client works — including Claude Code, Claude Desktop, Cursor (via `.cursor/mcp.json`), Windsurf, VS Code with Copilot Chat, and custom agents built on the MCP SDK. The same install command targets all of them; only the config file path differs.
Once installed, your AI agent can query and manage PostgreSQL databases directly inside your conversation. Typical use cases include asking Claude Code or Cursor to run PostgreSQL operations, inspect results, chain PostgreSQL with other MCP servers (see our Workflow Recipes), and automate repetitive databases tasks without leaving your editor.