MEC PostgreSQL 服务器是一个模型上下文协议(Model Context Protocol)服务器,它提供了对 PostgreSQL 数据库的读写访问能力。借助该服务器,大型语言模型(LLM)能够检查数据库架构,并执行读取和写入查询操作。
若要使用此服务器与 Claude Desktop 应用,需将以下配置添加到 claude_desktop_config.json 文件中的 "mcpServers" 部分:
host.docker.internal 如果服务器运行在主机网络(例如 localhost)。postgresql://user:password@host:port/db-name。{
"mcpServers": {
"postgres": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/postgres",
"postgresql://host.docker.internal:5432/mydb"]
}
}
}
请将 /mydb 替换为您的数据库名称。
使用以下命令构建 Docker 镜像:
docker build -t mcp/postgres -f src/postgres/Dockerfile .
sql (字符串):要执行的 SQL 查询。sql (字符串):要执行的 SQL 查询。该服务器提供每个表的架构信息,可通过以下链接获取:
postgres:////schema)
- 每个表的 JSON 架构信息。
- 包括列名和数据类型。
- 自动从数据库元数据中发现。
📚 详细文档
使用 Claude Desktop 注意事项
- 当在 macOS 上运行 docker 时,请使用
host.docker.internal 如果服务器运行在主机网络(例如 localhost)。
- 用户名/密码可以添加到 PostgreSQL URL 中,格式为
postgresql://user:password@host:port/db-name。
配置文件说明
在 claude_desktop_config.json 文件的 "mcpServers" 部分添加如下配置:
{
"mcpServers": {
"postgres": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/postgres",
"postgresql://host.docker.internal:5432/mydb"]
}
}
}
需将 /mydb 替换为您的数据库名称。
📄 许可证
此 MCP 服务器根据 MIT License(MIT 许可证)发布。这意味着您可以自由使用、修改和分发软件,但需遵守 MIT 许可证的条款和条件。如需了解详细信息,请参阅项目存储库中的 LICENSE 文件。
请先 登录 后评论
您需要登录后才可以回答问题,
-
0 关注
-
0 收藏,8 浏览
-
system
提出于 2025-09-24 10:33
相似服务问题
相关AI产品
-
暂无相关AI产品
发送私信
举报此文章