MCP Directory

How to add PGMCP - PostgreSQL Model Context Protocol Server to Cursor

Query any PostgreSQL database in natural language via MCP, with safe read-only SQL and streaming. Paste the config into ~/.cursor/mcp.json and restart Cursor.

Last updated June 14, 2026 · 536 · http · apikey

Cursor config for PGMCP - PostgreSQL Model Context Protocol Server

brew tap subnetmarco/homebrew-tap && brew install pgmcp
{
  "mcpServers": {
    "pgmcp---postgresql-model-context-protocol-server": {
      "url": "http://localhost:8080/mcp",
      "type": "streamable-http"
    }
  }
}

Remote server — no local install needed. Restart the client after saving the config.

Setup steps

  1. 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
  2. 2Paste the PGMCP - PostgreSQL Model Context Protocol Server 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 PGMCP - PostgreSQL Model Context Protocol Server's tools to confirm it's connected.

Before you start

  • PostgreSQL database (existing database with your schema)
  • OpenAI API key (optional, for AI-powered SQL generation)

What PGMCP - PostgreSQL Model Context Protocol Server can do in Cursor

ask

Natural language questions converted to SQL queries with automatic streaming.

search

Free-text search across all database text columns.

stream

Advanced streaming for very large result sets with pagination.

Security

Read-only enforcement blocks write operations (INSERT, UPDATE, DELETE, etc.) and runs all queries in read-only transactions. Query timeouts prevent long-running queries; input validation sanitizes and validates user input. Optional Bearer-token authentication via the AUTH_BEARER environment variable. Natural-language-to-SQL generation sends schema/queries to the OpenAI API when OPENAI_API_KEY is configured.

PGMCP - PostgreSQL Model Context Protocol Server + Cursor FAQ

Where is the Cursor config file?

Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the PGMCP - PostgreSQL Model Context Protocol Server config there under the "mcpServers" key and restart the client.

Is PGMCP - PostgreSQL Model Context Protocol Server safe to use with Cursor?

Read-only enforcement blocks write operations (INSERT, UPDATE, DELETE, etc.) and runs all queries in read-only transactions. Query timeouts prevent long-running queries; input validation sanitizes and validates user input. Optional Bearer-token authentication via the AUTH_BEARER environment variable. Natural-language-to-SQL generation sends schema/queries to the OpenAI API when OPENAI_API_KEY is configured.

Is it safe to point this at my production database?

It enforces read-only access, blocking write operations (INSERT, UPDATE, DELETE, etc.) and running all queries in read-only transactions, with query timeouts and input validation. No schema modifications are required.

Do I need an OpenAI API key?

It is optional. OPENAI_API_KEY enables AI-powered natural-language-to-SQL generation; the default model is gpt-4o-mini and can be overridden with OPENAI_MODEL.

How do I connect it to Claude Desktop or Cursor?

Start the server (it listens on http://localhost:8080/mcp by default), then add an mcpServers entry with an http transport pointing to that URL in your client config.

View repo Full PGMCP - PostgreSQL Model Context Protocol Server page