---
title: "Postgres MCP Pro：Claude、Cursor、Codex 配置指南 · DotsAgent"
description: "提供 Postgres 查询、架构检查、索引调优和健康检查，替代已归档的参考服务器。 在 13 个 MCP 客户端中配置 Postgres MCP Pro。"
url: https://dotsagent.io/zh/mcp/servers/postgres-mcp-pro
---

数据 · Crystal DBA

# 配置 Postgres MCP Pro

提供 Postgres 查询、架构检查、索引调优和健康检查，替代已归档的参考服务器。

- **发布者**: Crystal DBA 社区
- **本地运行**: `uvx postgres-mcp --access-mode=restricted`
- **传输方式**: stdio, sse
- **身份验证**: 通过 DATABASE_URI 设置的 Postgres 连接字符串。
- **环境变量**: `DATABASE_URI`
- **可访问内容**: 受限模式为只读；不受限模式可读写。
- **许可证**: MIT
- **源码**: [github.com/crystaldba/postgres-mcp](https://github.com/crystaldba/postgres-mcp)
- **状态**: 活跃

## 安装

此服务器会在你的本机上作为客户端的子进程运行。你需要安装其命令所用的运行时，例如 npx 需要 Node.js、uvx 需要 uv，或者使用 Docker；还需要设置 Environment 下列出的变量。

### Claude Code

`shell`

```
claude mcp add --scope project --env DATABASE_URI='<DATABASE_URI>' postgres-mcp-pro -- uvx postgres-mcp --access-mode=restricted
```

### Cursor

`.cursor/mcp.json`

```
{
  "mcpServers": {
    "postgres-mcp-pro": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "${env:DATABASE_URI}"
      }
    }
  }
}
```

### Codex

`~/.codex/config.toml`

```
[mcp_servers.postgres-mcp-pro]
command = "uvx"
args = ["postgres-mcp", "--access-mode=restricted"]
env_vars = ["DATABASE_URI"]
```

[其他客户端的配置 →](https://dotsagent.io/zh/mcp/config#add=postgres-mcp-pro)

对于任何重要数据库，请保留 --access-mode=restricted；不受限模式允许 agent 写入。

## 数据 中的其他服务器

- [Airtable](https://dotsagent.io/zh/mcp/servers/airtable): 在 Airtable base 中查询、创建和更新记录，访问范围仅限于你授权的 base。

- [BigQuery](https://dotsagent.io/zh/mcp/servers/google-bigquery): 由 Google 托管的 endpoint，可浏览 BigQuery 数据集并运行 SQL。Cloud SQL 和 Spanner 各有独立的 endpoint。

- [MCP Toolbox for Databases](https://dotsagent.io/zh/mcp/servers/mcp-toolbox-databases): 一个服务器提供预置的工具集，支持 Postgres、MySQL、BigQuery、AlloyDB、Spanner 等数据库。

- [Supabase](https://dotsagent.io/zh/mcp/servers/supabase): 通过代理管理 Supabase 项目：运行 SQL、应用迁移、读取日志和部署 Edge Functions。

- [Neon](https://dotsagent.io/zh/mcp/servers/neon): 创建 Neon Postgres 项目和分支、执行 SQL，并进行基于分支的迁移。适用于开发环境。

- [MongoDB](https://dotsagent.io/zh/mcp/servers/mongodb): 使用连接字符串或 Atlas 服务账号查询和管理 MongoDB 数据库及 Atlas 集群。

## 来源

1. [github.com](https://github.com/crystaldba/postgres-mcp)/crystaldba/postgres-mcp

为 AI agent 开发者提供的独立参考资料。与此处提及的任何厂商均无关联。

© 2026 DotsAgent · 事实核查日期：2026年10月1日
