Kaiva Postgres MCP — Claude Code MCP server: setup and usage
Connects assistants to PostgreSQL with guaranteed read-only execution. Replaces the archived official Postgres MCP package without breaking existing workflows.
claude mcp add kaiva-postgres-mcp -- npx -y @kaiva/postgres-mcpWhat Kaiva Postgres MCP does
Serves as a direct drop-in alternative to the unsupported @modelcontextprotocol/server-postgres. It restricts incoming SQL to single read-safe statements like SELECT, SHOW, TABLE, VALUES or EXPLAIN. Calls to dangerous database internals such as server file readers, dblink, advisory locks or COPY ... TO PROGRAM are rejected upfront.
Queries run inside isolated read-only transactions using the extended query protocol. Every statement auto-terminates with a rollback and DISCARD ALL to purge temporary session state. Standard execution caps returned data at 1,000 rows with a 15-second timeout. Without --allow-superuser, connecting as a superuser to remote hosts will fail immediately.
What it helps with
- inspect database schema, column types, and foreign key relations
- run analytical SQL queries without risking table updates or drops
- evaluate query performance via
EXPLAIN - cap large result sets automatically to prevent context overflow
Example prompts for the agent
- Inspect the columns, keys, and indexes of the
userstable - Run an
EXPLAINquery on the recent subscriptions report - List all available database schemas and tables with row estimates
How to install Kaiva Postgres MCP
Platform CLI
claude mcp add kaiva-postgres-mcp -- npx -y @kaiva/postgres-mcpPlatform CLI
codex mcp add kaiva-postgres-mcp -- npx -y @kaiva/postgres-mcpConfig file
{
"mcpServers": {
"kaiva-postgres-mcp": {
"command": "npx",
"args": [
"-y",
"@kaiva/postgres-mcp"
]
}
}
}Config file
{
"servers": {
"kaiva-postgres-mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@kaiva/postgres-mcp"
]
}
}
}Platform CLI
gemini mcp add kaiva-postgres-mcp npx -y @kaiva/postgres-mcpStep by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Kaiva Postgres MCP
How to install Kaiva Postgres MCP in Claude Code?
Run claude mcp add kaiva-postgres-mcp -- npx -y @kaiva/postgres-mcp. Pass your connection string as an argument or export it inside DATABASE_URL.
What does Kaiva Postgres MCP do?
It gives your AI client safe inspection tools (query, list_tables, describe_table) to read database contents without write permissions.
Why replace the archived server-postgres?
Anthropic archived the original server in 2025. Unlike the original, which let chained commands bypass read-only mode after COMMIT, this server strictly enforces single statements.