Skip to main content
Glama
garvjoshi1111

mcp-postgres

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_tables

List all tables in the public schema

describe_table(table_name)

Show columns, types, and nullability for a table

run_query(query)

Execute a SELECT query and return results (mutating statements are blocked)

Related MCP server: pg-mcp

Resources

URI

Description

schema://tables

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 string

3. Run the server

mcp-postgres

Or directly:

python -m mcp_postgres.server

Claude 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 resources

Security

run_query rejects any statement that does not begin with SELECT. This prevents accidental or malicious data modification through the MCP interface.

F
license - not found
-
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    -
    quality
    D
    maintenance
    Enables Claude Desktop to query a PostgreSQL brand database through MCP. Supports local stdio and remote HTTP/SSE deployments with API key authentication for secure database access.
  • F
    license
    -
    quality
    D
    maintenance
    Enables 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.
  • A
    license
    A
    quality
    A
    maintenance
    Query 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.
    21
    1,809
    3
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/garvjoshi1111/mcp-postgres'

If you have feedback or need assistance with the MCP directory API, please join our Discord server