Back to MCP directory
publicPublicdnsLocal runtime

postgresql-mcp-server

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

article

README

🚀 PostgreSQL MCP Server

PostgreSQL MCP Server 是一个模型上下文协议(MCP)服务器,它提供直接执行 PostgreSQL 数据库查询的能力。该服务器支持对 PostgreSQL 数据库执行自定义 SQL 查询,支持参数化查询和可配置的超时设置。此项目专为 Cursor IDE 设计。

🚀 快速开始

PostgreSQL MCP Server 是一个模型上下文协议(MCP)服务器,可直接执行 PostgreSQL 数据库查询。支持自定义 SQL 查询、参数化查询和可配置的超时设置,专为 Cursor IDE 打造。

✨ 主要特性

  • 提供直接执行 PostgreSQL 数据库查询的能力。
  • 支持自定义 SQL 查询,包括参数化查询。
  • 具备可配置的超时设置。
  • 专为 Cursor IDE 设计。

📦 安装指南

通过 Smithery 安装

要通过 Smithery 自动安装适用于 Claude Desktop 的 PostgreSQL 数据库查询服务器,请执行以下命令:

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

手动安装

  1. 克隆仓库。
  2. 安装依赖:
npm install
  1. 构建服务器:
npm run build
  1. 添加到 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. 创建拉取请求。
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client