Skip to main content
Glama
HarjjotSinghh

PostgreSQL Multi-Schema MCP Server

PostgreSQL 多模式 MCP 服务器

模型上下文协议 (MLM) 服务器提供对 PostgreSQL 数据库的只读访问,并增强了多模式支持。该服务器使 LLM 能够跨多个命名空间检查数据库模式,并执行只读查询,同时保持模式隔离。

主要特点

  • 多模式支持:通过命令行配置明确指定要公开的模式

  • 模式隔离:服务器启动时仅对列出的授权模式进行严格的访问控制

  • 跨模式发现:跨多个模式的表的统一视图,同时保持模式边界

  • 元数据安全:过滤系统目录以仅公开指定模式中的用户定义表

Related MCP server: PostgreSQL MCP Server

成分

工具

  • 询问

    • 对连接的数据库执行只读 SQL 查询

    • 输入: sql (字符串):要执行的 SQL 查询

    • 所有查询都在只读事务中执行

    • 通过search_path限制维护的架构上下文

资源

服务器为授权架构中的每个表提供架构信息:

  • 表模式postgres://<host>/<db_schema>/<table>/schema

    • 每个表的 JSON 架构信息

    • 包括列名、数据类型和类型修饰符

    • 从数据库元数据中自动发现

    • 具有显式架构允许列表的多架构支持

用法

服务器需要数据库 URL 并接受以逗号分隔的模式列表来公开:

npx -y mcp-server-postgres-multi-schema <database-url> [schemas]
  • database-url :PostgreSQL 连接字符串(例如, postgresql://localhost/mydb

  • schemas :要公开的模式的逗号分隔列表(如果未指定,则默认为“public”)

示例

# Connect with default public schema
npx -y mcp-server-postgres-multi-schema postgresql://localhost/mydb

# Connect with multiple schemas
npx -y mcp-server-postgres-multi-schema postgresql://localhost/mydb public,analytics,staging

与 Claude Desktop 一起使用

claude_desktop_config.json中配置“mcpServers”部分:

NPX

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-server-postgres-multi-schema",
        "postgresql://localhost/mydb",
        "public,audit"
      ]
    }
  }
}

执照

此多架构 MCP 服务器采用 MIT 许可证。您可以根据 LICENSE 文件中的条款使用、修改和分发该软件。

-
security - not tested
A
license - permissive license
-
quality - not tested

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HarjjotSinghh/mcp-server-postgres-multi-schema'

If you have feedback or need assistance with the MCP directory API, please join our Discord server