Get the FREE Ultimate OpenClaw Setup Guide →

mcp -postgres-multi-schema

A Model Context Protocol server that provides read-only access to PostgreSQL databases with enhanced multi-schema support.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio harjjotsinghh-mcp-server-postgres-multi-schema npx -y mcp-server-postgres-multi-schema <database-url> <schemas>

How to use

This MCP server provides read-only access to one or more PostgreSQL schemas. It exposes a unified view of tables across authorized schemas while enforcing strict schema isolation, so your language models can inspect metadata and run read-only queries without accessing unauthorized objects. The server exposes two core capabilities: a query tool that executes read-only SQL within a restricted transaction context, and metadata access that surfaces table schemas across the allowed schemas. To use it, supply the Postgres connection string and a comma-separated list of schemas you want to expose. By default, if no schemas are provided, the server uses the public schema.

Typical workflow:

  • Start the server with the database URL and an allow-list of schemas (e.g., public,audit,analytics).
  • Use the query tool to run read-only SQL against the connected database. Each query runs in a READ ONLY transaction and respects the configured search_path so results reflect the allowed schemas.
  • Retrieve table schemas and metadata, which are exposed per table across the authorized schemas, enabling schema-aware reasoning while maintaining isolation between schemas.

How to install

Prerequisites:

  • Node.js and npm or npx installed on your system.
  • Access to the target PostgreSQL database.

Installation steps:

  1. Ensure Node.js is installed. You can verify with: node -v npm -v

  2. Use NPX to launch the MCP server without a global install (recommended): npx -y mcp-server-postgres-multi-schema <database-url> <schemas>

    Example: npx -y mcp-server-postgres-multi-schema postgresql://localhost/mydb public,audit

  3. (Optional) If you want to configure Claude Desktop or other clients, add an mcpServers entry with the appropriate command and arguments: { "mcpServers": { "postgres": { "command": "npx", "args": ["-y", "mcp-server-postgres-multi-schema", "postgresql://localhost/mydb", "public,audit"] } } }

Additional notes

Notes and tips:

  • Schemas to expose are explicitly listed; other schemas are not accessible via the server.
  • If you omit schemas, the default behavior is to expose the public schema.
  • The server is read-only; write operations to the database are not permitted through the MCP tools.
  • Ensure the database user referenced in the connection string has read permissions on the exposed schemas.
  • The tooling surfaces table schemas and metadata in a per-table format, supporting cross-schema discovery while maintaining schema boundaries.
  • If you run into connection or permission errors, verify network access to the PostgreSQL host and that the provided schemas exist and are accessible to the user.

Related MCP Servers

Sponsor this space

Reach thousands of developers