MCP Directory

How to add Postgres MCP Pro to Cursor

Read/write Postgres access plus index tuning, EXPLAIN plans, and database health analysis for AI agents. Paste the config into ~/.cursor/mcp.json and restart Cursor.

Last updated June 15, 2026 · 2.9k · stdio · apikey

Cursor config for Postgres MCP Pro

uvx postgres-mcp --access-mode=restricted
{
  "mcpServers": {
    "postgres-mcp-pro": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_URI",
        "crystaldba/postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "postgresql://<user>:<password>@<host>:5432/<dbname>"
      }
    }
  }
}

Requires Docker to be installed and running.

Setup steps

  1. 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
  2. 2Paste the Postgres MCP Pro config below into the "mcpServers" object.
  3. 3Fill in placeholder secrets, then save.
  4. 4Cursor reloads MCP servers automatically — check Settings → MCP for a green status dot.
  5. 5Ask Cursor to use one of Postgres MCP Pro's tools to confirm it's connected.

Before you start

  • A reachable PostgreSQL database and a connection string in the form postgresql://user:password@host:5432/dbname
  • Python 3.12+ with the uv or pipx package manager, OR Docker if you prefer the container image
  • Recommended Postgres extensions for full functionality: pg_stat_statements (query stats) and hypopg (hypothetical indexes for tuning)
  • An MCP-capable client (Claude Desktop, Cursor, Windsurf, etc.)

What Postgres MCP Pro can do in Cursor

list_schemas

List all schemas in the database

list_objects

List tables, views, sequences, and extensions within a schema

get_object_details

Get columns, constraints, and indexes for a table/view/object

execute_sql

Run SQL; read-only when the server is in restricted mode

explain_query

Return the execution plan, optionally simulating hypothetical indexes

get_top_queries

Report the slowest/most resource-intensive queries via pg_stat_statements

analyze_workload_indexes

Recommend indexes for the overall workload using greedy search + hypopg

analyze_query_indexes

Recommend indexes for a specific set of SQL queries (up to 10)

Security

The DATABASE_URI contains full Postgres credentials, so store it securely and prefer a least-privilege role. Use --access-mode=restricted (read-only) unless the agent genuinely needs write/DDL access.

Postgres MCP Pro + Cursor FAQ

Where is the Cursor config file?

Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the Postgres MCP Pro config there under the "mcpServers" key and restart the client.

Is Postgres MCP Pro safe to use with Cursor?

The DATABASE_URI contains full Postgres credentials, so store it securely and prefer a least-privilege role. Use --access-mode=restricted (read-only) unless the agent genuinely needs write/DDL access.

Is there an npm package?

No. Postgres MCP Pro is Python-only, distributed on PyPI (pipx/uv) and as a Docker image. There is no Node/npm package.

How do I make it safe for production?

Run with --access-mode restricted, which limits operations to read-only transactions and applies resource/time limits, and connect with a least-privilege database role.

Why do I need pg_stat_statements and hypopg?

pg_stat_statements powers slow-query analysis, and hypopg lets the server simulate indexes to test their impact without creating them. Without them, tuning and top-query features are limited.

View repo Full Postgres MCP Pro page