
How to add Postgres MCP Pro to Windsurf
Read/write Postgres access plus index tuning, EXPLAIN plans, and database health analysis for AI agents. Paste the config into ~/.codeium/windsurf/mcp_config.json and restart Windsurf.
Last updated June 15, 2026 · 2.9k★ · stdio · apikey
Windsurf 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
- 1Open Windsurf → Cascade → the hammer/MCP icon → Configure (or edit ~/.codeium/windsurf/mcp_config.json).
- 2Paste the Postgres MCP Pro config below.
- 3Fill in placeholder secrets, then save.
- 4Click Refresh in the MCP panel.
- 5Postgres MCP Pro's tools become available to Cascade.
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 Windsurf
list_schemasList all schemas in the database
list_objectsList tables, views, sequences, and extensions within a schema
get_object_detailsGet columns, constraints, and indexes for a table/view/object
execute_sqlRun SQL; read-only when the server is in restricted mode
explain_queryReturn the execution plan, optionally simulating hypothetical indexes
get_top_queriesReport the slowest/most resource-intensive queries via pg_stat_statements
analyze_workload_indexesRecommend indexes for the overall workload using greedy search + hypopg
analyze_query_indexesRecommend 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 + Windsurf FAQ
Where is the Windsurf config file?
Windsurf reads MCP servers from ~/.codeium/windsurf/mcp_config.json. Paste the Postgres MCP Pro config there under the "mcpServers" key and restart the client.
Is Postgres MCP Pro safe to use with Windsurf?
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.