Provides comprehensive PostgreSQL database management tools including schema inspection, SQL execution, query explanation with EXPLAIN plans, index tuning recommendations, workload analysis, and database health checks with support for pg_stat_statements and hypopg extensions.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pgsql-mcpshow me the top 5 slowest queries from the last hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pgsql-mcp
A PostgreSQL MCP server with index tuning, explain plans, health checks, and safe SQL execution.
Features
Database Health - analyze index health, connection utilization, buffer cache, vacuum health, and more
Index Tuning - find optimal indexes for your workload using industrial-strength algorithms
Query Plans - review EXPLAIN plans and simulate hypothetical indexes
Schema Intelligence - context-aware SQL generation
Safe SQL Execution - configurable read-only mode for production use
Quick Start
Claude Code / Cloud IDEs
For Claude Code or cloud-based IDEs, add to your MCP configuration:
VS Code / Cursor / Windsurf
Using SSE (recommended for IDEs):
Start the server:
Add to your MCP config (
mcp.jsonfor Cursor,mcp_config.jsonfor Windsurf):
Note: Windsurf uses
serverUrlinstead ofurl.
Using stdio:
Docker
Run with stdio:
Run with SSE:
Python Installation
Access Modes
--access-mode=unrestricted- Full read/write access (development)--access-mode=restricted- Read-only with resource limits (production)
Optional: Postgres Extensions
For full index tuning capabilities, install these extensions:
Available Tools
Tool | Description |
| List all database schemas |
| List tables, views, sequences in a schema |
| Get columns, constraints, indexes for an object |
| Execute SQL (read-only in restricted mode) |
| Get query execution plans with hypothetical index support |
| Find slowest queries via pg_stat_statements |
| Recommend indexes for your workload |
| Recommend indexes for specific queries |
| Run comprehensive health checks |
License
MIT