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 文件中的条款使用、修改和分发该软件。

Related MCP Connectors

  • PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.

  • Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.

  • The Grafbase MCP server sits in front of a GraphQL API and exposes an MCP protocol-compliant interface that allows AI agents and LLMs to explore and query GraphQL APIs using natural language. It provides tools to search schemas, introspect types and fields, and execute GraphQL queries while minimizing context bloat by returning only relevant schema subsets, with built-in support for authentication, authorization, and configurable access control.

  • Query your Postgres from ChatGPT or Claude without exposing the database or handing over credentials. Run npx boltschema connect next to your database and it dials out over HTTPS — no inbound firewall rule, no open port, works with localhost and VPC-private databases. Read-only is enforced by a SQL guard, a Postgres READ ONLY transaction, and a scoped role generated for you.

Related MCP Servers

  • -
    license
    Not graded
    quality
    A
    maintenance
    A Model Context Protocol server that provides read-only access to PostgreSQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.
    109,622 npm
    90,629
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that provides read-only access to PostgreSQL databases, enabling LLMs to inspect database schemas and execute read-only queries.
    109,622 npm
    MIT