PostgreSQL只读访问服务器
一个为LLM提供PostgreSQL数据库只读访问的Model Context Protocol服务器。
快速入门
功能
- 提供对PostgreSQL表结构的只读访问。
- 支持执行安全的SQL查询。
使用方法
Docker运行
- 确保Docker已安装。
- 运行以下命令构建镜像: docker build -t mcp/postgres -f src/postgres/Dockerfile .
- 配置
claude_desktop_config.json
,添加如下内容: { "mcpServers": { "postgres": { "command": "docker", "args": [ "run", "-i", "--rm", "mcp/postgres", "postgresql://host.docker.internal:5432/mydb" ] } } }
NPX运行
- 安装Node.js。
- 配置
claude_desktop_config.json
,添加如下内容: { "mcpServers": { "postgres": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb" ] } } }
将mydb
替换为你的数据库名称。