返回市场
麦普.pg模式

麦普.pg模式

作者:vinsidious4 星标更新:2025-02-14

项目介绍

PostgreSQL

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

组件

工具

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

资源

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

  • 表模式 (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文件。