Enables querying and analyzing PostgreSQL databases through SQL execution, table schema inspection, and sample data retrieval with optional write operations support
Postgres MCP Server
A Model Context Protocol server for PostgreSQL databases. Enables LLMs to query and analyze PostgreSQL databases through a controlled interface.
Installation
Add to your MCP client settings:
Configuration
DATABASE_URL
- PostgreSQL connection string (required)DANGEROUSLY_ALLOW_WRITE_OPS
- Enable writes (default:false
)DEBUG
- Enable debug logging (default:false
)PG_SSL_ROOT_CERT
- Optional path to a TLS CA bundle (e.g., AWS RDS global bundle)
Usage
Transports
- Default transport is stdio. Switch to HTTP with the
--transport
flag. - HTTP mode serves the MCP Streamable HTTP endpoint at
/mcp
onPORT
(default3000
). - Clients that support Streamable HTTP should connect to
http://localhost:3000/mcp
.
Start commands:
Tools
query
- Execute SQL queries
Resources
postgres://tables
- List all tablespostgres://table/{schema}/{table}
- Get table schema and sample data
Example Prompts
Here's an example prompt to test if your MCP server is working:
Quick Start with Docker
Sample tables included: users
, products
, orders
, order_items
Development
Use local build in MCP client settings:
Releases
This repo auto-creates a GitHub Release when you push a tag that matches the version in package.json
:
- Update
CHANGELOG.md
and bump the version inpackage.json
. - Commit the changes on
main
(or your release branch). - Create and push a matching tag:
The GitHub Actions workflow will validate that the tag (e.g. v0.1.0
) matches package.json
, then use gh
to create a release with generated notes, and publish to npm.
License
MIT - see LICENSE
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables LLMs to query and analyze PostgreSQL databases through a controlled interface. Supports SQL query execution, table schema inspection, and optional write operations with safety controls.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server providing LLMs read-only access to PostgreSQL databases for inspecting schemas and executing queries.Last updated -18,07822MIT License
- AsecurityAlicenseAqualityFacilitates management and optimization of PostgreSQL databases, offering analysis, setup guidance, and debugging, while ensuring secure and efficient database operations.Last updated -3016AGPL 3.0
- -securityAlicense-qualityEnables LLMs to interact with MySQL databases by inspecting schemas and executing safe, read-only queries within transactions.Last updated -38MIT License
- -securityFlicense-qualityProvides read-only access to PostgreSQL databases, enabling LLMs to inspect database schemas and execute read-only SQL queries within a secure transaction context.Last updated -18,0781