1

1Levick3

@1Levick3/postgresql-mcp-server
0 Stars 23 次浏览 1Levick3 更新于 2026-08-23

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "postgresql-mcp": {
      "alwaysAllow": [],
      "args": [
        "/Users/1Levick3/Desktop/postgresql-mcp-server/build/index.js"
      ],
      "command": "node",
      "disabled": false,
      "env": {
        "POSTGRES_CONNECTION_STRING": "postgresUrl",
        "POSTGRES_SSL_CERT_PATH": "/Users/1levick3/Desktop/root.crt"
      }
    }
  }
}

服务介绍

PostgreSQL MCP 服务器

smithery 徽章

这是一个提供直接执行 PostgreSQL 数据库查询功能的 Model Context Protocol (MCP) 服务器。该服务器支持针对 PostgreSQL 数据库执行自定义 SQL 查询,并支持参数化查询和可配置的超时时间。该项目特别为与 Cursor IDE 一起使用而设计。

前提条件

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

安装

通过 Smithery 安装

要通过 Smithery 自动安装适用于 Claude Desktop 的 PostgreSQL 数据库查询服务器:

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

手动安装

  1. 克隆仓库

  2. 安装依赖项:
    bash
    npm install

  3. 构建服务器:
    bash
    npm run build

  4. 添加到 MCP 设置文件中:
    json
    {
    "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. 创建一个 Pull Request

相关 MCP 服务