home / mcp / postgresql mcp server
Read-only, multi-tenant MCP server for PostgreSQL with schema introspection and cross-schema querying.
Configuration
View docs{
"mcpServers": {
"ahmetkca-mcp-server-postgres": {
"command": "npx",
"args": [
"-y",
"@ahmetkca/mcp-server-postgres",
"postgres://user:password@host:5432/database"
]
}
}
}You can deploy and use a multi-tenant MCP server for PostgreSQL that lets you read from multiple tenant schemas securely, introspect schema details, and execute read-only queries across schemas. This guide walks you through practical installation steps, how to run the server locally, and how to use it with MCP clients to explore your PostgreSQL data models.
Start the MCP server using one of the provided runtime commands, then connect your MCP client to query across tenant schemas in a read-only mode. You will be able to request schema overviews, inspect table structures, and read function definitions across multiple tenants without modifying data.
Prerequisites you need before installing and running the MCP server:
Recommended installation and initial run flow using npm and npx:
# Install the MCP server globally (recommended)
npm install -g @ahmetkca/mcp-server-postgres
# Run directly with a connection string
npx @ahmetkca/mcp-server-postgres "postgres://user:password@host:port/database"If you prefer to start via a local command after installation, you can run the server with a direct URL as well.
# Direct execution (local or remote URL)
mcp-server-postgres "postgres://user:password@host:port/database"You can add the MCP server to Claude Desktop by configuring the MCP server entry within the Claude settings. This enables you to invoke the MCP server from Claude alongside other clients.
Executes read-only SQL queries across multiple tenant schemas. Supports complex SQL with JOINs, CTEs, window functions, and aggregations. Runs inside read-only transactions for safety.
Discovers all available tenant schemas with statistics like table and function counts to help you understand the multi-tenant layout.
Provides comprehensive information about a specific tenant schema, including table counts, function definitions, and overall metadata for analysis.