PostgreSQL MCP Server
OfficialQuery your PostgreSQL database with natural language
The official PostgreSQL MCP server from Anthropic lets your AI assistant read and query any PostgreSQL database. Ask questions in plain English — the AI translates them into SQL and returns results instantly. The server runs locally, so your data and connection credentials never leave your machine. Supports schema inspection, table listing, and arbitrary read queries. Write queries are not supported by default, keeping your data safe.
Install Config
Config file: ~/Library/Application Support/Claude/claude_desktop_config.json· Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres"
],
"env": {
"POSTGRES_URL": "postgresql://user:password@localhost:5432/mydb"
}
}
}
}Required environment variables:
POSTGRES_URL— PostgreSQL connection string(e.g. postgresql://user:password@localhost:5432/mydb)
Available Tools (3)
| Tool name | Description |
|---|---|
| query | Execute a read-only SQL query against the database |
| list_tables | List all tables in the connected database |
| describe_table | Get the full schema for a specific table |
Example Prompts
- “What tables are in my database?”
- “Show me the 10 most recent orders”
- “How many users signed up this week?”
- “What is the schema for the products table?”
- “Find all orders over $500 placed in the last 30 days”
Pros & Cons
Pros
- Official Anthropic-maintained server
- Read-only by default — safe for production
- All data stays on your machine
- Works with all major MCP clients
Cons
- PostgreSQL only — not MySQL or MongoDB
- No write support by default
- Requires a running PostgreSQL instance
Who Is This For?
- ·Developers who want conversational access to their app database
- ·Data analysts wanting AI-assisted SQL generation
- ·Teams demoing data capabilities without writing queries
When to use: Use this server when you have a PostgreSQL database and want to explore your data, generate reports, or answer questions without writing SQL yourself.
Supported Clients
Related Use Cases
Related Servers
SQLite MCP Server
OfficialQuery and analyze SQLite databases with your AI assistant
The official SQLite MCP server gives your AI assistant full access to any SQLite database file. Unlike PostgreSQL, SQLit…
Supabase MCP Server
OfficialFull Supabase access — database, auth, storage, and edge functions
The official Supabase MCP server exposes your entire Supabase project to your AI assistant. Beyond basic database querie…