postgres-mcp

postgres-mcp

Exposes PostgreSQL query execution, EXPLAIN, and schema inspection tools to MCP-compatible clients like Claude Desktop.

Category
Visit Server

README

postgres-mcp

An MCP server that exposes PostgreSQL query, EXPLAIN, and schema inspection tools to Claude Desktop (or any MCP-compatible client).

Tools

Tool Parameters Description
execute_query sql Run any SQL statement; SELECT returns rows as JSON, DML returns affected row count
explain_query sql, analyze (bool, default false) Get the query execution plan. When analyze=true runs EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
get_table_schema table_name, schema (default "public") List columns (type, nullability, default) and indexes for a table

Project layout

src/postgres_mcp/
  server.py   # FastMCP entry point, tool registrations
  tools.py    # SQL execution logic
  db.py       # Connection helper (reads DATABASE_URL)
tests/
  test_tools.py
examples/
  claude_desktop_config.json

Setup

1. Prerequisites

  • Python 3.10+
  • uvbrew install uv
  • A running PostgreSQL instance
  • Claude Desktop (or another MCP client)

2. Clone and install

git clone https://github.com/RachelHuangZW/postgres-mcp
cd postgres-mcp
uv sync

3. Configure your database

Copy .env.example to .env and fill in your connection string:

cp .env.example .env
# edit .env: DATABASE_URL=postgresql://user:password@localhost:5432/dbname

4. Register with Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json and merge in the mcpServers block (see examples/claude_desktop_config.json):

{
  "mcpServers": {
    "postgres-mcp": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/postgres-mcp", "python", "-m", "postgres_mcp.server"],
      "env": {
        "DATABASE_URL": "postgresql://user:password@localhost:5432/dbname"
      }
    }
  }
}

Replace /path/to/postgres-mcp with the absolute path to this repo and fill in your DATABASE_URL. Then fully quit and reopen Claude Desktop.

Tip: You can also run the server directly with uv run postgres-mcp after uv sync.

5. Verify

Open a new Claude Desktop conversation and ask:

"Use get_table_schema to show me the schema for the users table."

Claude should call the tool and return the column list.

Development

uv sync --group dev
uv run pytest

Security note

execute_query runs whatever SQL you pass — use a read-only database role in production, or restrict access to trusted users only.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured