Back
Marketplace/PostgreSQL

TL;DR

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.

🐘

PostgreSQL

Verified 4 tools

Databases

Last updated May 30, 2026 · By MCPizy team

Query and manage PostgreSQL databases

Official homepage

Install PostgreSQL

Via MCPizy CLI (recommended):
mcpizy install postgres
Or run directly:
npx -y @modelcontextprotocol/server-postgres
View on GitHub

Tools exposed

4 tools available
query

Execute a read-only SQL query and return rows

Inputs

  • sqlstringrequired
list_schemas

List all schemas in the database

list_tables

List tables in a given schema

Inputs

  • schemastringoptional
describe_table

Return column names and types for a table

Inputs

  • tablestringrequired

Configuration

Works identically across clients. Only the config file path differs.

Claude Code~/.claude.json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:password@host:5432/dbname"
      ]
    }
  }
}
Cursor.cursor/mcp.json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:password@host:5432/dbname"
      ]
    }
  }
}
Windsurf~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:password@host:5432/dbname"
      ]
    }
  }
}

Authentication setup

  1. 1

    Copy your Postgres connection string from your hosting provider

    Get it POSTGRES_CONNECTION_STRING

What you can do with PostgreSQL MCP

Paste 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

Why PostgreSQL MCP matters

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.

Common pitfalls

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.

How PostgreSQL MCP compares

Honest pros/cons against the closest databases MCP servers.

ServerStrengthsTrade-offs
Supabase MCPFull platform: auth, storage, edge functions, advisorsBigger blast radius, requires Supabase project (not portable)
Neon MCPDatabase branching, autoscaling serverless PostgresTied to Neon; cold-start latency on first query
SQLite MCPZero infra, perfect for local dev / single-file analyticsNo concurrency, not for production multi-writer workloads

Works with

Claude Code
Claude Desktop
Cursor
Windsurf
VS Code + Copilot
Any MCP Client

More Databases MCPs

⚡

DynamoDB

AWS DynamoDB NoSQL database operations

🐬

MariaDB

MariaDB relational database server

🪳

CockroachDB

Distributed SQL database for cloud apps

🗃️

SQLite

Local SQLite database access and management

Alternatives to PostgreSQL

If PostgreSQL doesn't fit your stack, these Databases MCP servers solve similar problems.

🔵

Neo4j

Graph database queries

🔍

Elasticsearch

Full-text search and analytics engine

🎯

Qdrant

Vector similarity search engine

Key Takeaways

  • PostgreSQL exposes 4 tools for databases workflows in Claude Code, Cursor and Windsurf.
  • Authentication: 1 step (POSTGRES_CONNECTION_STRING).
  • Install in 1 command: mcpizy install postgres — config written to your client automatically.
  • Free and open source (GitHub source linked above) — verified compatible with every MCP client (Claude Code, Claude Desktop, Cursor, Windsurf, VS Code + Copilot).
  • Best use case: "List all tables in the `public` schema and count the rows in each".

Frequently asked questions

What is the PostgreSQL MCP server?

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.

How do I install PostgreSQL MCP with Claude Code?

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.

Is PostgreSQL MCP free?

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.

Does PostgreSQL MCP work with Cursor and Windsurf?

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.

What can I do with PostgreSQL MCP?

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.

Manage all your MCPs in one place

Monitor usage, track costs, and discover new MCPs.

Get Started Free