
PostgreSQL MCP Server
Connects Claude to PostgreSQL databases with a full suite of inspection and querying tools. You get schema discovery, read-only query execution with automatic row limits and transaction rollback, query plan explanations, foreign key relationship mapping, and index analysis. The write query tool accepts single INSERT, UPDATE, DELETE, or DDL statements and commits them, so you'll want a read-only user for most workflows. Exposes MCP resources for table lists and schema definitions. Ships with configurable row limits and runs queries in explicit read-only transaction mode for safety. Install via uvx and configure with standard Postgres connection parameters.
- tool
- 1
- auth
- Secret needed
- transport
- STDIO
- env vars
- 6
- last updated
- May 23, 2026
Tools
1 toolsPublic tool metadata for what this MCP can expose to an agent.
execute_custom_queryExecute a custom SQL query against the database. WARNING: Use with care. Do not expose to untrusted input.4 params
Execute a custom SQL query against the database. WARNING: Use with care. Do not expose to untrusted input.
connectionStringstringquerystringtimeoutnumbervaluesarraySponsors
Configuration
POSTGRES_HOST*default: localhostPostgreSQL host
POSTGRES_PORT*default: 5432PostgreSQL port
POSTGRES_USER*PostgreSQL username
POSTGRES_PASSWORDsecretPostgreSQL password
POSTGRES_DB*PostgreSQL database name
POSTGRES_READ_QUERY_LIMITdefault: 1000Maximum rows returned by read queries
Readme
PostgreSQL MCP Server
A Python Model Context Protocol (MCP) server for inspecting and querying PostgreSQL databases from MCP-compatible clients. It provides schema discovery, safe read-only query execution, query explanation, table previews, index analysis, relationship inspection, and PostgreSQL resources for table metadata.
Features
- List public tables and inspect table schemas
- Execute read-only SQL in a PostgreSQL read-only transaction
- Explain query plans without executing the target query directly
- Preview table rows with a fixed limit
- Inspect foreign-key relationships and indexes
- Expose passive MCP resources for table lists and schema details
Safety Model
Details
- Repository
- github.com/musaddiq-dev/postgresql-mcp-server
- Category
- Databases
- Package
mdev-postgresql-mcp-server- Transport
- STDIO
- Auth
- Required
- Registry
- MCP registry, active