Postgres Mcp

io.github.pgEdge由 GitHub 账号 pgEdge 发布v1.0.0更新于 Oct 25, 2026

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

已验证STDIO仅桌面数据库知识与记忆

概览

AI 生成的概览

一个 MCP 服务器,让助手以 SQL 或自然语言查询 PostgreSQL 数据库,并提供模式分析与混合检索。

可以做什么
对 PostgreSQL 数据库执行 SQL 查询,默认在只读事务中运行,并可通过内置代理用自然语言生成查询。分析数据库模式,读取 PostgreSQL 统计信息及其他资源。执行结合 BM25 与 MMR 的混合检索,并生成嵌入向量。使用引导式提示完成语义检索配置、数据库探索和查询诊断。可选提供网页聊天界面和带用户与令牌认证的 HTTP/HTTPS API。
适用场景
适用于内部开发流程和可信环境,让助手探索并查询 PostgreSQL 14 或更高版本的数据库,包括自然语言查询和数据语义检索。
运行要求
作为本地进程运行,以 GitHub Container Registry 上的容器镜像分发。需要 PostgreSQL 14 或更高版本的数据库,并配置连接信息(配置文件、环境变量或命令行参数)。可选的 HTTP 模式需要设置用户与令牌认证;嵌入功能需要配置提供方。
安装前请注意
该服务器让 LLM 读取整个数据库模式和全部数据,README 明确说明不适用于面向公众的应用,只应在所有用户都可信的环境中使用。只读限制可按数据库配置,因此可能被放宽。HTTP 模式涉及用户与 API 令牌以及加密密钥文件,需要妥善保护。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Postgres Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

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:

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:

bash
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

bash
git clone https://github.com/pgEdge/pgedge-postgres-mcp.gitcd pgedge-postgres-mcpmake build

Testing

bash
# Run all testsmake test
# Run server tests with a databaseexport TEST_PGEDGE_POSTGRES_CONNECTION_STRING=\  "postgres://localhost/postgres?sslmode=disable"go test ./...
# Run with coveragego test -v -cover ./...
# Run lintingmake lint
Web UI Tests

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

bash
cd webnpm test                # Run all testsnpm run test:watch      # Watch modenpm 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.

来源:README.md,提交 d451081

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分