pgEdge Postgres MCP Server

pgEdge Postgres MCP Server

Enables SQL queries against PostgreSQL databases through MCP-compatible clients and includes a natural language agent for forming SQL queries from natural language.

Category
Visit Server

README

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:

Client Transport Best For
CLI (Stdio) Stdio Local single-user development
CLI (HTTP) HTTP Multi-user or remote access
Web UI HTTP Browser-based chat interface
Claude Code Stdio Anthropic CLI agent
Claude Desktop Stdio Anthropic desktop app
Cursor Stdio AI code editor
Windsurf Stdio Codeium code editor
VS Code Copilot Stdio GitHub 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.

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
Qdrant Server

Qdrant Server

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

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