QueryIO
PostgreSQL MCP server for debugging with AI coding agents.
Give your agent a broken record: a user, an invoice, a project. inspect_row returns that row plus bounded samples of its immediate declared foreign-key relationships in both directions, in one call. Your agent compares them with your code and checks its diagnosis with read-only SQL. Works with Claude Code, Codex, and Cursor.
Example: why did this user never activate?
User 4821 verified their email, but their account never activated. Find out why.
{ "table": "public.users", "key": { "id": 4821 } }
One inspect_row call returns the user, their organization, and their memberships, verification tokens, and events. The agent sees org_id = 88 but a membership only in organization 21. A transfer event explains the move. The activation code requires membership in the current organization, so the bug is in the transfer code. Full walkthrough: sample application.
Quick start
Requires Node.js 20+ and a PostgreSQL role that can read the data. Use a dedicated read-only role.
1. Set the database connection
export QUERYIO_DATABASE_URL="postgres://queryio_role:CHANGE_ME_PASSWORD@localhost:5432/app"
PowerShell: $env:QUERYIO_DATABASE_URL = "postgres://..."
2. Check the connection
npx -y queryio check
3. Connect your coding agent
Run this from your application repository:
npx -y queryio setup
The wizard finds Claude Code, Codex, and Cursor and shows each change before it writes. It never asks for the connection string and never writes it to a file. To preselect clients, use npx -y queryio setup --claude, npx -y queryio setup --codex, or npx -y queryio setup --cursor. Start your agent from the terminal where QUERYIO_DATABASE_URL is set. Manual configuration.
4. Ask a debugging question
Invoice 90017 is paid, but its organization is still suspended. Read the billing code and investigate the related records.
Tools
| Tool | What it does |
|---|---|
inspect_row | One row by primary key, plus up to 5 related rows per foreign key, in both directions. |
query | One read-only SQL statement for joins, aggregates, and targeted checks. Results are capped by rows and bytes. |
list_tables | Find tables by table or column name, with estimated row counts. |
describe_tables | Columns, keys, indexes, and planner statistics for several tables at once. |
inspect_row requires a declared primary key and follows only declared foreign keys, one level deep. Related rows are ordered by key, not by recency. Tool reference.
Security
- Every call runs in a PostgreSQL
READ ONLYtransaction that is rolled back, with statement and lock timeouts. - Columns with sensitive names (
password,token, ...) are redacted. Redaction is best-effort. - QueryIO is not a complete security sandbox. Connect with a dedicated read-only role. Security guide.
Learn more
- Reference: tool contracts, errors, configuration, audit log.
- Security: role setup, redaction limits, resource limits.
- When QueryIO fits: use cases and comparison with other servers.
- Benchmark: method, results, and limitations.
- Contributing · Issues · MIT license