PostgreSQL 数据库模式读取工具

PostgreSQL 数据库模式读取工具

一个通过 MCP 协议提供 PostgreSQL 数据库只读访问功能的服务器,支持模式查看与查询执行。

快速入门

功能简介

  • 提供数据库表结构信息(JSON 格式)
  • 支持只读 SQL 查询

使用方法

Docker 配置

运行以下命令启动服务: docker run -i --rm mcp/postgres postgresql://host.docker.internal:5432/mydb

NPX 配置

使用如下命令启动: npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb

Claude Desktop 配置

claude_desktop_config.json 文件中添加以下内容:

Docker 配置示例: "postgres": { "command": "docker", "args": [ "run", "-i", "--rm", "mcp/postgres", "postgresql://host.docker.internal:5432/mydb" ] }

NPX 配置示例: "postgres": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb" ] }

/mydb 替换为实际数据库名称。

构建

运行以下命令构建 Docker 镜像: docker build -t mcp/postgres -f src/postgres/Dockerfile .