返回市场
邮政数据库

邮政数据库

作者:smithery-ai430 星标更新:2025-05-05

项目介绍

PostgreSQL

smithery 徽章

这是一个提供对PostgreSQL数据库只读访问的Model Context Protocol服务器。此服务器使LLMs能够检查数据库模式并执行只读查询。

组件

工具

  • query
    • 对连接的数据库执行只读SQL查询
    • 输入:sql(字符串):要执行的SQL查询
    • 所有查询都在一个只读事务中执行

资源

该服务器为数据库中的每个表提供模式信息:

  • 表模式 (postgres://<host>/<table>/schema)
    • 每个表的JSON模式信息
    • 包括列名和数据类型
    • 自动从数据库元数据中发现

在Claude Desktop上的使用

要在Claude Desktop应用程序中使用此服务器,请在您的claude_desktop_config.json文件的“mcpServers”部分添加以下配置:

Docker

  • 当在macOS上运行Docker时,如果服务器在网络主机上运行(例如localhost),请使用host.docker.internal
  • 可以将用户名/密码添加到PostgreSQL URL中,格式为postgresql://user:password@host:port/db-name
{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run", 
        "-i", 
        "--rm", 
        "mcp/postgres", 
        "postgresql://host.docker.internal:5432/mydb"]
    }
  }
}

NPX

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ]
    }
  }
}

/mydb替换为您自己的数据库名称。

构建

Docker:

docker build -t mcp/postgres -f src/postgres/Dockerfile .

许可证

此MCP服务器采用MIT许可证。这意味着您可以自由地使用、修改和分发软件,但需遵守MIT许可证的条款和条件。如需更多详情,请参阅项目存储库中的LICENSE文件。