home / mcp / postgresql multi-schema mcp server
A Model Context Protocol server that provides read-only access to PostgreSQL databases with enhanced multi-schema support.
Configuration
View docs{
"mcpServers": {
"harjjotsinghh-mcp-server-postgres-multi-schema": {
"command": "npx",
"args": [
"-y",
"mcp-server-postgres-multi-schema",
"postgresql://localhost/mydb",
"public,audit"
]
}
}
}You run a PostgreSQL MCP Server that exposes read-only access to multiple schemas, letting you inspect schemas across namespaces while keeping strict isolation. It provides a single, unified way to query and explore tables across authorized schemas without risking cross-schema access.
You connect to the MCP server from an MCP client by using the provided command, which runs the server in a process you can control from your environment. The server accepts a database URL and a comma-separated list of schemas to expose. It ensures all queries run in a read-only transaction and maintains the correct schema context for every operation.
Prerequisites you need before starting are minimal because you run through a local command with a built-in package runner.
Install Node.js if you do not already have it. You can download it from the official Node.js site or use your system package manager.
Use the following commands to run the server directly with the MCP client. You do not need a separate build step to execute these commands.
npx -y mcp-server-postgres-multi-schema
https://localhost:5432/mydb-multi
public,auditIf you use Claude Desktop, add an MCP server entry in your Claude configuration to run the MCP server through NPX. This enables Claude to interact with the multi-schema server directly.
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"mcp-server-postgres-multi-schema",
"postgresql://localhost/mydb",
"public,audit"
]
}
}
}- The server exposes only the specified schemas to ensure strict schema isolation. Unauthorized schemas are not accessible.
- Querying is read-only by design. Each operation runs within a read-only transaction to prevent schema modification.
- You can discover metadata about user-defined tables across the allowed schemas, with schema boundaries preserved in results.
Access to data is limited to the explicitly allowed schemas supplied at startup. The server does not expose system catalogs beyond what is necessary to describe user-defined tables in those schemas.
- Connect to a single schema, e.g., public, to inspect its tables and run read-only queries.
- Connect to multiple schemas in one session to get a cross-schema view of tables while maintaining their distinct namespaces.
If you encounter connection errors, verify that the database URL is correct and that the server is started with the intended list of schemas. Check that your client points to the correct host and port and that the schemas you requested exist in the database.
Execute read-only SQL queries against the connected database. Accepts input sql as a string. All queries run in a READ ONLY transaction with the schema context maintained via a restricted search_path.