What Is PostgreSQL MCP Server?
PostgreSQL MCP Server connects Claude to a PostgreSQL database, exposing tools for schema inspection, query execution, and data analysis. It is maintained by the Model Context Protocol team as part of the official modelcontextprotocol/servers monorepo.
Quick Facts
| Field | Value |
|---|---|
| Package | @modelcontextprotocol/server-postgres |
| Install | npx @modelcontextprotocol/server-postgres postgresql://localhost/mydb |
| Compatible with | Claude Code, Claude Desktop |
| Status | active |
| GitHub | github.com/modelcontextprotocol/servers/…/postgres |
What You Can Do With It
- Run SQL queries: Send SELECT, INSERT, UPDATE, or DELETE statements directly through Claude’s conversation interface.
- Inspect schema: Retrieve table definitions, column types, indexes, and constraints without opening a separate database client.
- Analyze data: Ask Claude to summarize, aggregate, or identify patterns across rows in your database.
- Generate database documentation: Claude can describe table relationships and column semantics based on live schema introspection.
How to Set It Up
Prerequisites: Node.js (≥18) and a running PostgreSQL instance accessible via connection string.
1. Test the server with npx (no install required):
npx @modelcontextprotocol/server-postgres postgresql://localhost/mydb
Replace `postgresql://localhost/mydb` with your actual connection string, including credentials if required:
```bash
npx @modelcontextprotocol/server-postgres postgresql://user:password@host:5432/mydb
2. Add to Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@localhost:5432/mydb"
]
}
}
}
On macOS, claude_desktop_config.json is located at ~/Library/Application Support/Claude/claude_desktop_config.json.
3. Add to Claude Code (.claude/mcp.json in your project root):
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@localhost:5432/mydb"
]
}
}
}
Restart Claude Desktop or reload your Claude Code session after editing either config file.
Works Best With
This server is documented as compatible with Claude Code and Claude Desktop. Claude Code is the better fit for development workflows — schema inspection and query execution integrate naturally with code generation tasks in an active project directory. Claude Desktop suits ad-hoc data exploration and documentation generation outside of a coding context.
Known Limitations
- Credentials in config: The connection string, including username and password, is passed as a plain argument. Avoid committing config files with credentials to version control. Use environment variable substitution or a secrets manager where your deployment supports it.
- No built-in query guardrails: The server does not restrict which SQL statements Claude can execute. If Claude has write access, it can issue INSERT, UPDATE, or DELETE. Connect with a read-only database role if mutation is not needed.
- No connection pooling: Each server instance holds a single connection. High-concurrency use cases are not the intended target.
- Schema visibility: The server can only introspect objects the connecting user has permission to access. Missing tables or columns are often a permissions issue, not a bug.
- Large result sets: Returning very large query results through an MCP tool call may hit context window limits or time out depending on your client configuration.
Community Resources
- GitHub repository and source code
- GitHub Issues — bug reports and feature requests
- MCP Discord server —
#serverschannel covers community questions about official servers including postgres - r/ClaudeAI on Reddit — search “postgres MCP” for community setup threads



