PluginBench
MCP Server
Active
PostgreSQL

io.github.pgEdge/postgres-mcp MCP Server

io.github.pgEdge/postgres-mcp

Enterprise PostgreSQL MCP server with natural language queries, hybrid search, and web UI

What is the io.github.pgEdge/postgres-mcp MCP server?

The pgEdge Postgres MCP Server enables SQL queries against PostgreSQL databases through MCP-compatible clients with natural language support. It provides read-only protection, hybrid search capabilities (BM25+MMR), and integrates with Claude Desktop, Cursor, and other AI tools. Designed for internal tools and trusted developer workflows on PostgreSQL 14+.

This MCP server bridges natural language and SQL by letting AI agents query PostgreSQL databases safely. It includes a web UI, CLI client, hybrid search (combining BM25 and vector embeddings), resource access, and prompt-guided workflows. Built for developers and internal tools where all users are trusted; includes read-only transaction enforcement, user/token authentication, TLS support, and hot-reload configuration.

How to install io.github.pgEdge/postgres-mcp

Copy-paste configuration for popular MCP clients.

transport: stdio
Config generated by PluginBench — verify against the source before use.
~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "postgres-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/pgedge/postgres-mcp:latest"
      ]
    }
  }
}

Tools & capabilities

Tools this server exposes to the agent.

  • Query Execution — Execute SQL queries against PostgreSQL databases in read-only transactions
  • Schema Analysis — Analyze and explore database schema
  • Hybrid Search — Advanced search combining BM25 and MMR (Maximum Marginal Relevance)
  • Embedding Generation — Generate embeddings for semantic search
  • Resource Reading — Access PostgreSQL statistics and resources
  • Natural Language to SQL — Convert natural language questions into SQL queries

Use cases

  • Query PostgreSQL databases using natural language through Claude or Cursor
  • Explore database schemas and statistics with AI assistance
  • Perform hybrid semantic and keyword search across database content
  • Set up and use vector embeddings for semantic search workflows
  • Build internal developer tools with AI-powered database interaction
  • Diagnose query performance and database issues with guided prompts

io.github.pgEdge/postgres-mcp MCP server FAQ

What is the pgEdge Postgres MCP Server?

It's an MCP server that enables AI agents (Claude, Cursor, etc.) to query PostgreSQL databases using natural language. It provides read-only protection, hybrid search, and integrates with multiple clients including a web UI.

Is it free?

The server is open-source under the PostgreSQL License. However, it's designed for internal use only—not for public-facing applications where untrusted users have access.

How do I install it in Claude Desktop or Cursor?

Use the Quick Start guide at docs/guide/quickstart.md. For Claude Desktop, see docs/guide/claude_desktop.md; for Cursor, see docs/guide/cursor.md. Both use stdio transport with the server binary.

What authentication does it support?

User and API token authentication with expiration, SHA256 token hashing, and TLS/HTTPS support. See docs/guide/authentication.md for details.

What PostgreSQL versions are supported?

PostgreSQL 14 and higher.

Can I use it for public-facing applications?

No. This server provides LLMs with read access to your entire database schema and data. For public-facing apps, use the pgEdge RAG Server instead. See docs/guide/mcp-vs-rag.md for comparison.

README (reference)

Source of truth, from the repository.

pgEdge Postgres MCP Server and Natural Language Agent

CI - MCP Server CI - CLI Client CI - Web Client CI - Docker CI - Documentation

The pgEdge Postgres Model Context Protocol (MCP) server enables SQL queries against PostgreSQL databases through MCP-compatible clients. The Natural Language Agent provides supporting functionality that allows you to use natural language to form SQL queries.

Supported Versions: PostgreSQL 14 and higher.

NOT FOR PUBLIC-FACING APPLICATIONS: This MCP server provides LLMs with read access to your entire database schema and data. It should only be used for internal tools, developer workflows, or environments where all users are trusted. For public-facing applications, consider the pgEdge RAG Server instead. See the Choosing the Right Solution guide for details.

Quick Start

The Quick Start guide covers installation and setup for all supported clients:

ClientTransportBest For
CLI (Stdio)StdioLocal single-user development
CLI (HTTP)HTTPMulti-user or remote access
Web UIHTTPBrowser-based chat interface
Claude CodeStdioAnthropic CLI agent
Claude DesktopStdioAnthropic desktop app
CursorStdioAI code editor
WindsurfStdioCodeium code editor
VS Code CopilotStdioGitHub Copilot agent

For a guided demo with sample data, see the Quickstart Demo with Northwind.

Key Features

  • Read-Only Protection - All queries run in read-only transactions by default
  • Resources - Access PostgreSQL statistics and more
  • Tools - Query execution, schema analysis, advanced hybrid search (BM25+MMR), embedding generation, resource reading, and more
  • Prompts - Guided workflows for semantic search setup, database exploration, query diagnostics, and more
  • Production Chat Client - Full-featured Go client with Anthropic prompt caching (90% cost reduction)
  • HTTP/HTTPS Mode - Direct API access with user and token authentication
  • Web Interface - Modern React-based UI with AI-powered chat for natural language database interaction
  • Docker Support - Pre-built images on GitHub Container Registry with Docker Compose deployment
  • Secure - TLS support, user and token auth, read-only enforcement
  • Hot Reload - Automatic reload of authentication files without server restart

Development

Prerequisites

  • Go 1.21 or higher
  • PostgreSQL 14 or higher (for testing)
  • golangci-lint v1.x (for linting)

Setup Linter

The project uses golangci-lint v1.x. Install it with:

go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

Note: The configuration file .golangci.yml is compatible with golangci-lint v1.x (not v2).

Building

git clone https://github.com/pgEdge/pgedge-postgres-mcp.git
cd pgedge-postgres-mcp
make build

Testing

# Run all tests
make test

# Run server tests with a database
export TEST_PGEDGE_POSTGRES_CONNECTION_STRING=\
  "postgres://localhost/postgres?sslmode=disable"
go test ./...

# Run with coverage
go test -v -cover ./...

# Run linting
make lint

Web UI Tests

The web UI has a comprehensive test suite. See web/TEST_SUMMARY.md for details.

cd web
npm test                # Run all tests
npm run test:watch      # Watch mode
npm run test:coverage   # With coverage

Security

  • Read-only transaction enforcement (configurable per database)
  • User and API token authentication with expiration
  • TLS/HTTPS support
  • SHA256 token hashing
  • File permission enforcement (0600)
  • Input validation and sanitization

See the Security Guide for comprehensive security documentation.

Troubleshooting

Tools not visible in Claude Desktop?

  • Use absolute paths in config
  • Restart Claude Desktop completely
  • Check JSON syntax

Database connection errors?

  • Ensure database connection is configured before starting the server (via config file, environment variables, or command-line flags)
  • Verify PostgreSQL is running: pg_isready
  • Check connection parameters are correct

See the Troubleshooting Guide for detailed solutions.

Support

To report an issue with the software, visit: GitHub Issues

For more information, visit docs.pgedge.com

This project is licensed under the PostgreSQL License.

Related MCP servers

x402 pay-per-call agent APIs: LLM inference, Base trading data, SEC filings & scraping

1
JavaScript
MIT
View repository →

x402 MCP web parser: URLs to Markdown for agents. USDC on Base, Polygon, Arbitrum, Ethereum.

0
TypeScript
View repository →

x402-gated LLM token compressor: strip filler, collapse JSON, densify prose. Paid in USDC.

0
TypeScript
View repository →

x402-gated semantic vector cache for agent swarms: Redis-backed similarity lookup. Paid in USDC.

0
TypeScript
View repository →
CACallRail MCP logo

CallRail REST API v3: 57 tools for calls, leads, trackers, tags, users, and agency reporting.

2
Python
MIT
View repository →

MCP server for PostgreSQL performance auditing with actionable SQL fixes.