P

MCP Entry

Postgres MCP

Enables AI agents to execute read-only SQL queries against PostgreSQL databases, inspect table schemas, and analyze query performance. Agents can debug data issues or prepare analytics without requiring direct database credentials in the conversation. Supports connection pooling and multiple database targets.

Category Database
Install docker
Runtime Postgres
databasesqlanalytics

Use cases

  • On-call agent queries recent error logs from the database during an incident
  • Analytics agent generates weekly reports by aggregating sales data across tables
  • Developer agent inspects schema to understand table relationships before writing migrations
  • QA agent verifies test data in the database matches expected values after test runs
  • Data analyst agent explores datasets with ad-hoc SQL to answer business questions

Key features

  • Claude Desktop
  • Cursor
  • Codex

Frequently Asked Questions

Can this MCP server write data or only read?
By default it is read-only for safety. You can enable write operations by setting the MCP_SERVER_READ_ONLY environment variable to false, though this is not recommended for production.
How does the agent handle SQL injection risks?
The MCP server uses parameterized queries when possible. You should still follow least-privilege principles and ensure the database user has only necessary permissions.
What connection string formats are supported?
Standard PostgreSQL connection URLs are supported: postgresql://user:pass@host:5432/database. Connection pooling is handled automatically via the server.

Related

Related

3 Indexed items

MongoDB MCP

Database

Allows AI agents to run queries, inspect collections, execute aggregation pipelines, and analyze explain plans against MongoDB clusters. Debug document models and performance issues by having the agent explore data structures directly. Supports MongoDB Atlas federated queries and Atlas Search.

DuckDB MCP community extension (`duckdb_mcp`)

Database

The DuckDB-distributed community extension `duckdb_mcp` embeds MCP client and server capabilities directly inside DuckDB. Installers load it via `INSTALL duckdb_mcp FROM community` followed by `LOAD duckdb_mcp`, after which SQL can attach remote MCP servers (stdio/TCP/WebSocket transports), enumerate resources (`mcp_list_resources`), invoke remote tools (`mcp_call_tool`), and wrap responses with `read_csv`/`read_json`/`read_parquet` URIs routed through `mcp://`. In reverse direction, DuckDB can publish tables, queries, and execution-bound tools (`mcp_publish_table`, `mcp_publish_query`, `mcp_publish_execution_tool`) while `mcp_server_start` exposes them to external MCP-compatible clients.

Postgres MCP

DatabaseFree / Open Source

pg-mcp-server is a Model Context Protocol server implementation that connects AI agents to PostgreSQL databases. It registers database schemas as MCP resource templates and exposes SQL execution as an MCP tool. Agents can introspect table structures, run parameterized queries, and manage transactions without leaving the chat interface. Designed as a reference implementation for database MCP integrations.