返回 MCP 目录
public公开dns本地运行

postgres-mcp

Postgres MCP Pro 是一个开源 MCP 服务器,为 AI 代理提供数据库索引调优、执行计划分析、健康检查和安全 SQL 执行等全方位支持。

article

README

🚀 Postgres MCP Pro 开发指南

本指南为希望参与 Postgres MCP Pro 开发,或选择从源代码安装 Postgres MCP Pro 的用户提供详细说明。

🚀 快速开始

📦 安装指南

本地开发环境搭建

  1. 安装 uv
curl -sSL https://astral.sh/uv/install.sh | sh
  1. 克隆仓库
git clone https://github.com/crystaldba/postgres-mcp.git
cd postgres-mcp
  1. 安装依赖项
uv pip install -e .
uv sync
  1. 运行服务器
uv run postgres-mcp "postgres://user:password@localhost:5432/dbname"
即贴即用配置

MCP 客户端配置生成器

选择客户端,补齐所需环境变量,再复制根据当前 MCP 公开配置生成的完整文件

terminal
环境变量lock填写内容仅保留在当前浏览器标签页,不会上传或保存
Claude Desktop
{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_URI",
        "crystaldba/postgres-mcp",
        "--access-mode=unrestricted"
      ],
      "env": {
        "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
      }
    }
  }
}
建议保存到claude_desktop_config.json
help

运行方式说明

cloud

托管运行

托管运行通常表示这个 MCP Server 由服务方环境承载,用户一般按页面提供的连接方式或授权流程接入,不需要在本地长期启动一个 MCP 进程

  1. 打开服务方连接页
  2. 完成授权或复制端点
  3. 在 MCP 客户端中连接
terminal

本地运行 / 其它方式

本地运行通常需要用户在自己的电脑或服务器上安装依赖,把 server_config 复制到 MCP 客户端,并按 env_schema 补齐环境变量、密钥或其它配置

  1. 复制 server_config
  2. 安装所需依赖
  3. 补齐环境变量后重启客户端