
How to add PGMCP - PostgreSQL Model Context Protocol Server to Claude Desktop
Query any PostgreSQL database in natural language via MCP, with safe read-only SQL and streaming. Paste the config into ~/Library/Application Support/Claude/claude_desktop_config.json and restart Claude Desktop.
Last updated June 14, 2026 ยท 536โ ยท http ยท apikey
Claude Desktop config for PGMCP - PostgreSQL Model Context Protocol Server
brew tap subnetmarco/homebrew-tap && brew install pgmcp{
"mcpServers": {
"pgmcp---postgresql-model-context-protocol-server": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://localhost:8080/mcp"
]
}
}
}Claude Desktop connects to remote servers through the `mcp-remote` proxy (installed on first run via npx). Restart Claude Desktop after saving.
Setup steps
- 1Open Claude Desktop โ Settings โ Developer โ Edit Config (this opens ~/Library/Application Support/Claude/claude_desktop_config.json).
- 2Paste the PGMCP - PostgreSQL Model Context Protocol Server config below under the top-level "mcpServers" key.
- 3Fill in any placeholder secrets (API keys, paths) in the snippet.
- 4Save the file, then fully quit and reopen Claude Desktop.
- 5Open a chat and confirm PGMCP - PostgreSQL Model Context Protocol Server's tools appear under the ๐ tools menu.
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 Claude Desktop
askNatural language questions converted to SQL queries with automatic streaming.
searchFree-text search across all database text columns.
streamAdvanced 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 + Claude Desktop FAQ
Where is the Claude Desktop config file?
Claude Desktop reads MCP servers from ~/Library/Application Support/Claude/claude_desktop_config.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 Claude Desktop?
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.