mcp-postgres
Allows querying and inspecting a PostgreSQL database schema, including listing tables, describing columns, and executing read-only SQL queries.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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
Hosted PostgreSQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
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.
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,165 npm10MIT
- AlicenseAqualityBmaintenanceExposes 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.-