Postgres MCP
MCP server for any Postgres database. Claude can inspect schema, run queries, and explain plans.
What it does
The Postgres MCP server works against any Postgres database — not just Supabase. Use it for self-hosted Postgres, RDS, or Neon. Claude can list tables, describe columns, run SELECTs, and ANALYZE query plans to help you find missing indexes.
How to install
Which tool are you using?
Not sure? Claude.ai is the website. Claude Code is the command-line tool you install separately. Cursor is a code editor that reads .cursorrules.
- 01
Open your MCP config
Claude Desktop reads MCP config from ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, or %APPDATA%/Claude/claude_desktop_config.json on Windows.
terminalshellopen ~/Library/Application\ Support/Claude/claude_desktop_config.json - 02
Add the Postgres server block
Merge the JSON below into the "mcpServers" object. If the file is empty, paste the full block.
- 03
Replace placeholder credentials
Swap the placeholder values with your real tokens / URLs. Never commit this file.
- 04
Restart Claude Desktop
Fully quit Claude and reopen. The MCP server will be available as tools in every new chat.
- 05
Verify
Start a new chat and ask Claude to list available tools. You should see Postgres tools in the list.
The mcp server file
Copy the full contents below, or download the file directly.
{ "mcpServers": { "postgres": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-postgres", "postgresql://USER:PASSWORD@HOST:5432/DBNAME" ] } }}Example output
What Claude does before and after you install this mcp server.
You switch to psql, run \d, copy the schema back to Claude, paste the slow query plan separately.
Claude queries the schema and EXPLAIN plan directly, spots the missing index on user_id, and proposes the CREATE INDEX. 30 seconds.
Customization tips
Use a read-only role for production. Create a separate role per developer with minimum grants. Never use the postgres superuser role.
Related resources
Supabase MCP
MCP server that lets Claude run queries, inspect schema, and manage your Supabase project from chat.
Supabase + Next.js Rules
Cursor rules for Supabase + Next.js App Router. Client separation, RLS, auth middleware, server actions for mutations.
Node.js + Express Rules
Cursor rules for Node.js + Express backends. Structure, middleware, error handling, database, testing conventions.
Frequently asked questions
Supports any Postgres version?
Yes — 12+ recommended. Older versions work with limited features.
Works with Neon?
Yes — use the Neon connection string.
Does it write?
Only if the connection string has write permission. Prefer read-only.
Can I connect to SSH-tunneled DBs?
Open the tunnel first; point the connection string at localhost.
Does it handle row-level security?
Yes — RLS applies per the connection role.
Want more like this?
Browse the full RohanKit library — free resources for Claude and Cursor.