PostgreSQL只读访问服务器

PostgreSQL只读访问服务器

一个为LLM提供PostgreSQL数据库只读访问的Model Context Protocol服务器。

快速入门

功能

  • 提供对PostgreSQL表结构的只读访问。
  • 支持执行安全的SQL查询。

使用方法

Docker运行

  1. 确保Docker已安装。
  2. 运行以下命令构建镜像: docker build -t mcp/postgres -f src/postgres/Dockerfile .
  3. 配置claude_desktop_config.json,添加如下内容: { "mcpServers": { "postgres": { "command": "docker", "args": [ "run", "-i", "--rm", "mcp/postgres", "postgresql://host.docker.internal:5432/mydb" ] } } }

NPX运行

  1. 安装Node.js。
  2. 配置claude_desktop_config.json,添加如下内容: { "mcpServers": { "postgres": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb" ] } } }

mydb替换为你的数据库名称。