这是一个专为Claude Desktop和其他MCP客户端打造的MCP协议(Model Context Protocol)服务器实现,可在只读模式下对PostgreSQL数据库进行查询,为数据查询提供安全可靠的解决方案。
本项目实现了以下功能:
# 克隆仓库
git clone https://github.com/RathodDarshil/mcp-postgres-query-server.git
cd mcp-postgres-query-server
# 安装依赖项
npm install
# 构建项目
npm run build
您可以按以下步骤配置Claude Desktop,使其自动启动并连接到MCP服务器:
claude_desktop_config.json
的mcpServers
部分添加postgres-query-server:{
"mcpServers": {
"postgres-query": {
"command": "node",
"args": [
"/path/to/your/mcp-postgres-query-server/dist/index.js",
"postgresql://username:password@hostname:port/database"
]
}
}
}
/path/to/your/
。以下是一个包含postgres-query的完整配置文件示例:
{
"mcpServers": {
"postgres-query": {
"command": "node",
"args": [
"/path/to/mcp-postgres-query-server/dist/index.js",
"postgresql://user:password@localhost:5432/mydatabase"
]
}
}
}
npm run build
。node dist/index.js
。通过以上步骤,您可以轻松设置一个安全、高效的PostgreSQL查询服务器,实现与Claude Desktop或其他MCP客户端的无缝集成。