PostgreSQL MCP Server 配置与使用说明
安装方式npx
风险等级中风险
API Key不需要
客户端3 个支持
PostgreSQL 数据库只读访问,支持查询和 schema 检查
支持客户端
- Claude Desktop
- Cursor
- VS Code / Cline
安装命令
npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@localhost/dbname配置示例
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:pass@localhost/mydb"
]
}
}
}权限范围与安全提示
连接数据库进行查询,建议使用只读账号和测试数据库
- database-read
- network-access
风险评分:4/10
常见报错
- 连接超时
- 确认数据库地址和端口可达
- 认证失败
- 检查用户名密码和数据库名称
- SSL required
- 连接字符串添加 ?sslmode=require
来源
最近核验:2026-05-18。客户端版本和配置格式可能变化,使用前请以官方文档为准。