Set it up
- 1
Turn on PostgreSQL in your AI
In Claude: open Settings → Connectors and add PostgreSQL. In ChatGPT: Settings → Apps & Connectors.
- 2
Add it to your app once
Copy the short config below into your app. It just tells your AI where to find PostgreSQL.
- 3
Just ask
Tell it what you want in plain words — no special commands.
For example, say
“List all tables in my database and show row counts for each”
Need the exact config? Show it +
Add to your client
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@host:5432/dbname"]
}
}
}Paste into your client's MCP configuration file.
Quick skills
Copy one, paste it to your AI, watch it work.
Schema Exploration
“Describe the schema of my database — list tables, key columns, and how they relate to each other”
Data Investigation
“How many orders were placed in the last 24 hours and what's the total revenue?”
Query Drafting
“Write a query to find users who signed up in the last 30 days but haven't made a purchase”
In the wild
“I have been using the old MCP for months, and when I look at the Sonnet 3.5 generated migrations, there are always misunderstandings that I must correct”
Good to know
- · Use a read-only database user for AI queries — giving write access to production is risky
- · Connection strings contain credentials — never paste them into shared logs or chats
- · Large SELECT queries without LIMIT can return millions of rows and blow your context window
When to use
- ✓ You want to explore an unfamiliar database schema
- ✓ You need to run ad-hoc SELECT queries to investigate data or bugs
- ✓ You're learning SQL and want AI to draft queries you can review
- ✓ You're doing analytics on a read replica and want conversational queries
When not to use
- × You use MySQL, SQLite, or MongoDB (use those specific servers)
- × You want to give AI unrestricted write access to production
- × You need streaming replication or CDC — that's outside this server's scope
About
Imagine asking your AI: 'What tables are in my database and how are they related?' or 'Show me the top 10 slowest queries from the last hour' — and it connects directly to your Postgres database. This server lets your AI query and inspect Postgres databases through conversation, without you writing SQL by hand.
The official PostgreSQL MCP server provides read-only access to PostgreSQL databases. AI assistants can explore schemas, run SELECT queries, inspect table structures, and analyze data — with safety constraints that prevent accidental data modification.
Used by developers to let Claude help with database exploration, query optimization, and data analysis without risk.
Workflows That Use PostgreSQL MCP
Skip the SQL client. Ask product questions in plain English; get charts, insights, and ad-hoc reports.
Point Claude at Postgres, MongoDB, Redis, SQLite or a managed cloud DB and ask questions in plain language.
Works With
Also Consider
FAQ
What does PostgreSQL MCP do? +
Imagine asking your AI: 'What tables are in my database and how are they related?' or 'Show me the top 10 slowest queries from the last hour' — and it connects directly to your Postgres database. This server lets your AI query and inspect Postgres databases through conversation, without you writing SQL by hand.
Do I need to know how to code? +
No. Turn it on in your AI's settings and ask in plain English — no terminal, no coding.
When should I use PostgreSQL MCP? +
Reach for it when you need to: You want to explore an unfamiliar database schema; You need to run ad-hoc SELECT queries to investigate data or bugs; You're learning SQL and want AI to draft queries you can review; You're doing analytics on a read replica and want conversational queries.
When should I avoid PostgreSQL MCP? +
Skip it when: You use MySQL, SQLite, or MongoDB (use those specific servers); You want to give AI unrestricted write access to production; You need streaming replication or CDC — that's outside this server's scope.
How do I install PostgreSQL MCP? +
In Claude Code, run: claude mcp add postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@host:5432/dbname. Copy-paste configs for Claude Desktop, Cursor, and Windsurf are at the top of this page.