PostgreSQL MCP 服务器
一个模型上下文协议 (MCP) 服务器,提供直接执行 PostgreSQL 数据库查询的功能。该服务器支持针对 PostgreSQL 数据库执行自定义 SQL 查询,并支持参数化查询和可配置的超时。该项目专为与 Cursor IDE 配合使用而设计。
先决条件
Node.js >= 18.0.0
PostgreSQL 服务器(用于目标数据库操作)
对目标 PostgreSQL 实例的网络访问
安装
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 PostgreSQL 数据库查询服务器:
npx -y @smithery/cli install @1Levick3/postgresql-mcp-server --client claude
手动安装
克隆存储库
安装依赖项:
npm install构建服务器:
npm run build添加到 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
- 运行 ESLintnpm test
运行测试
安全注意事项
连接安全
使用连接池
实现连接超时
验证连接字符串
支持 SSL/TLS 连接
贡献
分叉存储库
创建功能分支
提交你的更改
推送到分支
创建拉取请求
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Tools
模型上下文协议服务器,可与 PostgreSQL 数据库交互,以分析设置、调试问题、管理模式、迁移数据和监控性能。
Related MCP Servers
- -securityFlicense-qualityA Model Context Protocol server providing both read and write access to PostgreSQL databases, enabling LLMs to query data, modify records, and manage database schemas.Last updated -6088
- AsecurityAlicenseAqualityA Model Context Protocol server that enables powerful PostgreSQL database management capabilities including analysis, schema management, data migration, and monitoring through natural language interactions.Last updated -181,751126AGPL 3.0
- -securityFlicense-qualityA Model Context Protocol server that enables performing PostgreSQL database operations (create, read, update, delete) on User and Post entities through MCP tools.Last updated -
- -securityAlicense-qualityA Model Context Protocol server that enables interaction with PostgreSQL databases to list tables, retrieve schemas, and execute read-only SQL queries.Last updated -22MIT License