PostgreSQL数据库协议服务器

为PostgreSQL数据库提供只读访问和模式检查功能的协议服务器,支持Docker和NPM包安装。

  • by yuru-sha
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 yuru-sha/mcp-server-postgres

使用说明

mcp服务器postgres

PostgreSQL数据库的模型上下文协议服务器。此服务器使LLM能够检查数据库模式并执行只读查询。

特性

  • PostgreSQL数据库的只读访问
  • 模式检查功能
  • 在只读事务中安全执行查询
  • Docker支持
  • NPM包可用

安装

使用Docker

# Build the Docker image
make docker

# Run with Docker
docker run -i --rm mcp/postgres postgresql://host:port/dbname

通过Smithery安装

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

npx -y @smithery/cli install @yuru-sha/mcp-server-postgres --client claude

用法

使用克劳德桌面

将以下配置添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp/postgres",
        "postgresql://host:port/dbname"
      ]
    }
  }
}

注意:在macOS上使用Docker时,请使用 host.docker.internal 如果PostgreSQL服务器正在主机网络上运行。

连接URL格式

postgresql://[user][:password]@host[:port]/database

替换 /database 使用您的数据库名称。

发展

# Initial setup
make setup

# Build the project
make build

# Format code
make format

# Run linter
make lint

许可证

该项目发布于 MIT许可证.

安全

此服务器强制执行只读访问以保护您的数据库。所有查询都在只读事务中执行。

为了增强安全性,我们建议创建只读用户。

贡献

欢迎投稿!请随时提交拉取请求。