
postgres_mcp
MCP server giving AI clients read-first access to PostgreSQL databases
The repository was last updated 19 days ago and is published under MIT.
postgres_mcp is an open-source MCP server for databases. It is available on CLI, Self-hosted and API.
- Pricing
- Open source
- Platforms
- CLI, Self-hosted, API
- What it can do
- Can change data (1 tool)
- GitHub stars
- 12
- Last commit
- Language
- Python
Similar MCP servers
About postgres_mcp
Lets an AI assistant inspect and query PostgreSQL databases through the Model Context Protocol. Schemas, tables, views, functions, indexes and constraints can be browsed, and SQL can be run with read-only enforcement on by default. Writes are only possible when explicitly enabled.
Several connections can be declared under aliases so one client session can work across a production replica and a local database, with each connection carrying its own write permission. Credentials stay in environment variables and are never returned by tools. Optional layers mask emails, phone numbers, card numbers and other personal identifiers, or restrict results to an allow list of columns before the model sees them.
The server is published in TypeScript and Python builds and works with Claude Code, Claude Desktop, Cursor and other MCP-compatible clients. It suits developers and analysts who want an assistant to explore schemas, draft queries, check query plans or document a database.
Tools this server provides (15)
Taken from the project documentation; the running server may differ.
From the tool list in its README, going by the names, 1 of 15 tools changes data; 1 name doesn't say.
From the server's own tool labels and tool names; not verified by us.
- queryName suggests: reads
- Execute read-only SQL queries against the database
- executeName suggests: changes
- Execute write operations (INSERT/UPDATE/DELETE) when enabled
- explain_queryName suggests: reads
- Get EXPLAIN plan for query optimization
- list_schemasName suggests: reads
- List all schemas in the database
- list_tablesName suggests: reads
- List tables in a specific schema
- describe_tableName suggests: reads
- Get table structure (columns, types, constraints)
- list_viewsName suggests: reads
- List views in a schema
- describe_viewName suggests: reads
- Get view definition and columns
- list_functionsName suggests: reads
- List functions and procedures
- table_stats
- Get table statistics (row count, size, bloat)
- list_indexesName suggests: reads
- List indexes for a table
- list_constraintsName suggests: reads
- List constraints (PK, FK, UNIQUE, CHECK)
- get_database_infoName suggests: reads
- Get database version and connection info
- search_columnsName suggests: reads
- Search for columns by name across all tables
- list_databasesName suggests: reads
- List the configured connections by alias
What it does
- Read-only by default
- Write statements are blocked unless ALLOW_WRITE_OPERATIONS or a per-connection setting enables them.
- Schema exploration tools
- Lists and describes schemas, tables, views, functions, indexes and constraints.
- Query plan analysis
- Runs EXPLAIN on queries and reports table statistics such as row count and size.
- Multiple named connections
- Declares several databases by alias and selects one per call without exposing credentials.
- Personal-data redaction
- Optionally masks detected personal identifiers, denied columns or all columns outside an allow list.
- Guided prompts and resources
- Provides prompts for exploration and data dictionaries plus browsable markdown views of the schema.
Good for
- Exploring an unfamiliar PostgreSQL database through natural-language questions
- Drafting and checking SQL queries against a development database
- Diagnosing slow queries with EXPLAIN output and index listings
- Generating a data dictionary for a schema
- Querying a production replica while keeping personal data masked
Pricing
Open source
Free under the MIT licence; self-hosted.
More servers for the same service
postgres_mcp FAQ
Can the assistant change data by default?
No. Write operations such as INSERT, UPDATE and DELETE are blocked unless ALLOW_WRITE_OPERATIONS is set to true or the connection allows writes.
Which clients does postgres_mcp work with?
It is documented for Claude Code, Claude Desktop, Cursor and any MCP-compatible client.
Are database passwords sent to the model?
Credentials come only from environment variables and are not returned by any tool, including the one that lists connections.
Which languages is postgres_mcp available in?
It is published as a TypeScript package installable through npm and as a Python package installable through pipx.
Is postgres_mcp free?
Yes. postgres_mcp is open source, so you can use and self-host it for free.
What are the best alternatives to postgres_mcp?
The closest alternatives to postgres_mcp are MCP Postgres, PostgreSQL MCP Server, sql-query-mcp, postgres-mcp and Postgres.
Where this comes from
- Description: written from the project's README.

