mcp-postgres
Allows querying and inspecting a PostgreSQL database schema, including listing tables, describing columns, and executing read-only SQL queries.
Click on "Deploy 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., "@mcp-postgresshow me the columns of the users table"
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.
mcp-postgres
An MCP server that connects to a PostgreSQL database and exposes schema inspection and safe query execution as tools and resources — ready to plug into Claude Desktop or any MCP-compatible client.
Tools
Tool | Description |
| List all tables in the public schema |
| Show columns, types, and nullability for a table |
| Execute a SELECT query and return results (mutating statements are blocked) |
Related MCP server: @yawlabs/postgres-mcp
Resources
URI | Description |
| Full schema dump — all tables with their columns |
Setup
1. Clone and install
git clone <repo-url>
cd mcp-postgres
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .2. Configure environment
cp .env.example .env
# Edit .env — set DATABASE_URL to your PostgreSQL connection string3. Run the server
mcp-postgresOr directly:
python -m mcp_postgres.serverClaude Desktop Integration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"postgres": {
"command": "/path/to/.venv/bin/mcp-postgres",
"env": {
"DATABASE_URL": "postgresql://user:password@localhost:5432/mydb"
}
}
}
}Project Structure
src/mcp_postgres/
__init__.py — package marker
db.py — psycopg2 connection context manager
server.py — FastMCP server, tools, and resourcesSecurity
run_query rejects any statement that does not begin with SELECT. This prevents accidental or malicious data modification through the MCP interface.
This server cannot be deployed
Maintenance
Related MCP Connectors
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Query your Postgres from ChatGPT or Claude without exposing the database or handing over credentials. Run npx boltschema connect next to your database and it dials out over HTTPS — no inbound firewall rule, no open port, works with localhost and VPC-private databases. Read-only is enforced by a SQL guard, a Postgres READ ONLY transaction, and a scoped role generated for you.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables natural language querying of PostgreSQL databases through the Model Context Protocol. It translates user questions into validated SQL, executes read-only queries safely, and returns results to MCP-compatible clients like Claude Desktop.-
- AlicenseAqualityAmaintenanceQuery and manage PostgreSQL databases from Claude Code, Cursor, and any MCP client, with read-only by default and built-in schema introspection, EXPLAIN, and performance diagnostics.232,373 npm6MIT
- AlicenseAqualityDmaintenanceExposes PostgreSQL query execution, EXPLAIN, and schema inspection tools to MCP-compatible clients like Claude Desktop.31MIT
- FlicenseNot gradedqualityDmaintenanceConnects AI assistants to PostgreSQL databases, enabling schema inspection and SQL query execution through MCP tools.-