PostgreSQL MCP Server 配置与使用说明

📦
安装方式npx
⚠️
风险等级中风险
🔑
API Key不需要
💻
客户端3 个支持

PostgreSQL 数据库只读访问,支持查询和 schema 检查

中风险 场景:数据库与数据查询 核验:2026-05-18 状态:已核验

支持客户端

安装命令

npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@localhost/dbname

配置示例

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:pass@localhost/mydb"
      ]
    }
  }
}

权限范围与安全提示

连接数据库进行查询,建议使用只读账号和测试数据库

风险评分:4/10

常见报错

连接超时
确认数据库地址和端口可达
认证失败
检查用户名密码和数据库名称
SSL required
连接字符串添加 ?sslmode=require

来源

最近核验:2026-05-18。客户端版本和配置格式可能变化,使用前请以官方文档为准。

相关工具