# postgres-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/pgEdge/pgedge-postgres-mcp  
**GitHub Stars:** 223  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/postgres-mcp-2

## Description
Enterprise PostgreSQL MCP server with NL queries, hybrid search (pgvector+BM25), and web UI

## Claude Desktop Quick Installation
Heuristic fallback — verify the package name and runner against the repository README before running it. Uses `npx` (confidence: low):

```json
"mcpServers": {
  "postgres-mcp": {
    "command": "npx",
    "args": ["-y","postgres-mcp-2"]
  }
}
```

## Documentation & README

# pgEdge Postgres MCP Server and Natural Language Agent

[![CI - MCP Server](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-server.yml/badge.svg?branch=main)](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-server.yml?query=branch%3Amain)
[![CI - CLI Client](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-cli-client.yml/badge.svg?branch=main)](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-cli-client.yml?query=branch%3Amain)
[![CI - Web Client](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-web-client.yml/badge.svg?branch=main)](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-web-client.yml?query=branch%3Amain)
[![CI - Docker](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-docker.yml/badge.svg?branch=main)](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-docker.yml?query=branch%3Amain)
[![CI - Documentation](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-docs.yml/badge.svg?branch=main)](https://github.com/pgEdge/pgedge-postgres-mcp/actions/workflows/ci-docs.yml?query=branch%3Amain)

- About the pgEdge Postgres MCP Server
    - [pgEdge Postgres MCP Server](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/index.md)
    - [Choosing the Right Solution](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/mcp-vs-rag.md)
    - [Best Practices - Querying the Server](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/querying.md)
- Installing the MCP Server
    - [Quick Start](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/quickstart.md)
    - [Quickstart Demo with Northwind](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/quickstart_demo.md)
    - [Deploying on Docker](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/deploy_docker.md)
    - [Deploying from Source](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/deploy_source.md)
    - [Testing the MCP Server Deployment](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/test_server.md)
- Configuring the MCP Server
    - [Specifying Configuration Preferences](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/configuration.md)
    - [Using Environment Variables to Specify Options](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/env_variable_config.md)
    - [Including Provider Embeddings in a Configuration File](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/provider_config.md)
    - [Configuring the Agent for Multiple Databases](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/multiple_db_config.md)
    - [Configuring Supporting Services; HTTP, systemd, and nginx](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/services_config.md)
    - [Using an Encryption Secret File](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/encryption_secret.md)
    - [Enabling or Disabling Features](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/feature_config.md)
- Configuring and Using a Client Application
    - [Connecting with the Web Client](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/web-client.md)
    - [Using the Go Chat Client](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/cli-client.md)
    - [Configuring the Server for use with Claude Desktop](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/claude_desktop.md)
    - [Configuring the Server for use with Cursor](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/cursor.md)
- [Reviewing Server Logs](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/server_logs.md)
- Authentication and Security
    - [Authentication - Overview](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/authentication.md)
    - [Authentication - User Management](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/auth_user.md)
    - [Authentication - Token Management](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/auth_token.md)
    - [Security Checklist](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/security.md)
    - [Security Management](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/security_mgmt.md)
- Reference
    - [Using MCP Tools](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/reference/tools.md)
    - [Using MCP Resources](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/reference/resources.md)
    - [Using MCP Prompts](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/reference/prompts.md)
    - [Error Reference](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/reference/error-reference.md)
    - [Server Configuration File](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/reference/config-examples/server.md)
    - [API Token Configuration File](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/reference/config-examples/tokens.md)
    - [CLI Client Configuration Details](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/reference/config-examples/cli-client.md)
- Advanced Topics
    - [Creating Custom Definitions](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/advanced/custom-definitions.md)
    - [Configuring and Using Knowledgebase Search](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/advanced/knowledgebase.md)
    - [Using the LLM Proxy](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/advanced/llm-proxy.md)
    - [Row-Level and Column-Level Security](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/advanced/row-level-security.md)
    - [Distributed Deployment](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/advanced/distributed-deployment.md)
- For Developers
    - [For Developers - Overview](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/developers/overview.md)
    - [MCP Protocol](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/developers/mcp-protocol.md)
    - [API Reference](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/developers/api-reference.md)
    - [API Browser](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/api/browser.md)
    - [Client Examples](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/developers/client-examples.md)
    - Building Chat Clients
        - [Overview](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/developers/building-chat-clients.md)
        - [Python (Stdio + Claude)](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/developers/stdio-anthropic-chatbot.md)
        - [Python (HTTP + Ollama)](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/developers/http-ollama-chatbot.md)
- Contributing
    - [Development Setup](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/contributing/development.md)
    - [Architecture](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/contributing/architecture.md)
    - [Internal Architecture](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/contributing/internal-architecture.md)
    - [Testing](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/contributing/testing.md)
    - [CI/CD](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/contributing/ci-cd.md)
- [Accessing Online Help](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/help.md)
- [Troubleshooting](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/troubleshooting.md)
- [Release Notes](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/changelog.md)
- [Licence](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/LICENSE.md)

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](https://github.com/pgedge/pgedge-rag-server)
> instead. See the
> [Choosing the Right Solution](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/mcp-vs-rag.md) guide
> for details.

## Quick Start

The [Quick Start](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/quickstart.md) 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](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/quickstart_demo.md).

## 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](https://github.com/orgs/pgEdge/packages?repo_name=pgedge-postgres-mcp)
  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:

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

Note: The configuration file [`.golangci.yml`](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/.golangci.yml)
is compatible with golangci-lint v1.x (not v2).

### Building

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

### Testing

```bash
# 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](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/web/TEST_SUMMARY.md) for details.

```bash
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](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/security.md) 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](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/docs/guide/troubleshooting.md)
for detailed solutions.

## Support

To report an issue with the software, visit:
[GitHub Issues](https://github.com/pgEdge/pgedge-postgres-mcp/issues)

For more information, visit
[docs.pgedge.com](https://docs.pgedge.com)

This project is licensed under the
[PostgreSQL License](https://github.com/pgEdge/pgedge-postgres-mcp/blob/HEAD/LICENSE.md).

