PostgreSQL数据库查询服务器

一个提供直接PostgreSQL数据库查询执行能力的MCP服务器,支持参数化查询和可配置超时,专为Cursor IDE设计。

  • by 1Levick3
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 1levick3/postgresql-mcp-server

使用说明

PostgreSQL MCP服务器

一种模型上下文协议(MCP)服务器,提供直接的PostgreSQL数据库查询执行功能。此服务器支持对PostgreSQL数据库执行自定义SQL查询,并支持参数化查询和可配置超时。此项目是专门为与Cursor IDE一起使用而设计的。

先决条件

  • Node.js>=18.0.0
  • PostgreSQL服务器(用于目标数据库操作)
  • 目标PostgreSQL实例的网络访问

安装

通过Smithery安装

通过以下方式自动安装用于Claude Desktop的PostgreSQL数据库查询服务器 史密瑟里:

npx -y @smithery/cli install @1Levick3/postgresql-mcp-server --client claude

手动安装

  1. 克隆存储库
  2. 安装依赖项:
    npm install
    
  3. 构建服务器:
    npm run build
    
  4. 添加到MCP设置文件:
     {
       "mcpServers": {
         "postgresql-mcp": {
           "command": "node",
           "args": ["/Users/1Levick3/Desktop/postgresql-mcp-server/build/index.js"],
           "disabled": false,
           "alwaysAllow": [],
           "env": {
             "POSTGRES_CONNECTION_STRING": "postgresUrl",
             "POSTGRES_SSL_CERT_PATH": "/Users/1levick3/Desktop/root.crt"
           }
         }
       }
     }
    

发展

  • npm run dev -使用热重新加载启动开发服务器
  • npm run lint -运行ESLint
  • npm test -运行测试

安全考虑

  1. 连接安全性
    • 使用连接池
    • 实现连接超时
    • 验证连接字符串
    • 支持SSL/TLS连接

贡献

  1. 分叉存储库
  2. 创建要素分支
  3. 提交您的更改
  4. 推到分支
  5. 创建拉取请求