
mcp-server-postgres

2025.04.17
0
JavaScriptPostgreSQL 数据库服务只读数据库访问数据库模式检查数据库
mcp-server-postgres 是一个基于 Model Context Protocol 的 PostgreSQL 数据库服务,专为 LLMs(大型语言模型)设计,使其能够检查数据库模式并执行只读查询。该服务提供了对 PostgreSQL 数据库的安全、只读访问,支持模式检查和在只读事务中执行查询。
View on GitHub
Overview
基本能力
产品定位
mcp-server-postgres 是一个为 PostgreSQL 数据库设计的 Model Context Protocol 服务器,旨在为 LLMs 提供安全、只读的数据库访问能力。
核心功能
- 对 PostgreSQL 数据库的只读访问
- 数据库模式检查能力
- 在只读事务中安全执行查询
- Docker 支持
- 提供 NPM 包
适用场景
- LLMs 需要查询 PostgreSQL 数据库的场景
- 需要安全、只读访问数据库的应用
- 数据库模式检查和数据分析
工具列表
- Docker:用于容器化部署
- NPM:用于 Node.js 环境安装
- Smithery:用于自动安装
常见问题解答
- 在 macOS 上使用 Docker 时,如果 PostgreSQL 服务器运行在主机网络上,应使用
host.docker.internal
作为主机名。 - 建议为数据库创建只读用户以增强安全性。
使用教程
使用依赖
- Docker(如需容器化部署)
- Node.js(如需使用 NPM 安装)
安装教程
使用 Docker
# Build the Docker image
make docker
# Run with Docker
docker run -i --rm mcp/postgres postgresql://host:port/dbname
使用 NPM
npm install @modelcontextprotocol/server-postgres
使用 Smithery
npx -y @smithery/cli install @yuru-sha/mcp-server-postgres --client claude
调试方式
# Initial setup
make setup
# Build the project
make build
# Format code
make format
# Run linter
make lint