本服务器基于模型上下文协议(Model Context Protocol),可提供对 PostgreSQL 数据库的只读访问服务。借助该服务器,大型语言模型(LLM)能够检查数据库架构,并执行只读查询操作。
要将此服务器与Claude Desktop应用程序一起使用,请将以下配置添加到claude_desktop_config.json
文件中的"mcpServers"部分:
host.docker.internal
postgresql://user:password@host:port/db-name
{
"mcpServers": {
"postgres": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/postgres",
"postgresql://host.docker.internal:5432/mydb"
]
}
}
}
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
]
}
}
}
请将/mydb
替换为您的数据库名称。
sql
(字符串),即要执行的 SQL 查询语句。服务器会为每个数据库表提供架构信息:
postgres:////schema)
- 提供每个表的 JSON 架构信息。
- 包含列名和数据类型。
- 该信息会自动从数据库元数据中发现。
📦 安装指南
Docker 构建
docker build -t mcp/postgres -f src/postgres/Dockerfile .
📄 许可证
此 MCP 服务器遵循 MIT 许可证发布。您可以自由使用、修改和分发该软件,但需遵守 MIT 许可证的相关条款和条件。更多详细信息,请查阅项目存储库中的 LICENSE 文件。
请先 登录 后评论
您需要登录后才可以回答问题,
-
0 关注
-
0 收藏,11 浏览
-
system
提出于 2025-09-24 12:48
相似服务问题
发送私信
举报此文章