P
以只读模式连接 PostgreSQL,自动读取表结构与索引信息,方便模型编写并解释 SQL 查询,避免误操作生产数据,适合数据分析与排障场景。
工具能力
query
执行只读 SQL 查询
list_schemas
列出数据库中的所有 schema
list_tables
列出指定 schema 下的表
describe_table
查看表结构与字段类型
安装接入
提供数据库连接字符串作为启动参数,建议使用只读账号。
claude_desktop_config.json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://readonly:pwd@localhost/db"
]
}
}
}
使用场景
用自然语言生成报表查询
排查慢查询与索引缺失问题
给新人快速讲解数据库结构
支持客户端
Claude Desktop完整支持
Cursor完整支持
Cline部分支持