PostgreSQL Multi-Schema MCP Server

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides read-only access to PostgreSQL databases with multi-schema support, allowing inspection of database schemas across multiple namespaces and execution of read-only SQL queries while maintaining schema isolation.

PostgreSQL 多模式 MCP 服务器

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

主要特点

  • 多模式支持:通过命令行配置明确指定要公开的模式
  • 模式隔离:服务器启动时仅对列出的授权模式进行严格的访问控制
  • 跨模式发现:跨多个模式的表的统一视图,同时保持模式边界
  • 元数据安全:过滤系统目录以仅公开指定模式中的用户定义表

成分

工具

  • 询问
    • 对连接的数据库执行只读 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

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

  1. Key Features
    1. Components
      1. Tools
      2. Resources
    2. Usage
      1. Examples
    3. Usage with Claude Desktop
      1. NPX
    4. License
      ID: w9o0l826lr