MCP Server
Query Doctor runs a hosted MCP server at https://api.querydoctor.com/mcp.
Point an MCP client such as Claude Code at
it and the agent gets Query Doctor as tools: optimize a query against your own
database, run a project health check, and read or triage your CI runs.
Nothing to install or run locally: the server is hosted and you register its URL. It speaks Streamable HTTP, so any MCP client that supports the HTTP transport works.
Prerequisites
Section titled “Prerequisites”- An MCP client that supports the HTTP transport and OAuth — e.g. Claude
Code (
claudeCLI). - A Query Doctor account for the tools that act on your projects. The CI read tools work without signing in; optimizing a query and writing triage state require an authorized session (see Authorization).
- To optimize queries: a project with the analyzer connected.
optimize_queryrelays to the analyzer you run against your database — see Connect a database and CI integration.
Install
Section titled “Install”Register the endpoint with Claude Code:
claude mcp add --transport http query-doctor https://api.querydoctor.com/mcpVerify it connected:
claude mcp get query-doctor# Status: ✓ Connected# Transport: http# URL: https://api.querydoctor.com/mcpOther MCP clients
Section titled “Other MCP clients”Any HTTP-transport MCP client works — register the same URL. For clients configured by JSON, the equivalent entry is:
{ "mcpServers": { "query-doctor": { "type": "http", "url": "https://api.querydoctor.com/mcp" } }}Authorization
Section titled “Authorization”The server splits tools by whether they act on your account:
- Read-only CI tools (
find_regressions,get_ci_run,get_query_status, …) work anonymously — no sign-in needed. optimize_query,doctor, and the triage writes (triage_query,set_comparison_branch) act on your projects and require an authorized session.
The server uses OAuth. The first time your agent calls a tool that needs a
session, the client opens your browser to sign in. You don’t paste a token or
set an environment variable. In Claude Code you can also start this from /mcp,
which shows the server’s authorization status.
What the tools do
Section titled “What the tools do”optimize_query— relays a query to your project’s running analyzer. The analyzer plans it against your own database and returns the base cost, whether a new index helps (with theCREATE INDEXdefinition and projected cost), and the before/after explain plans. The query and its data never reach Query Doctor’s servers. Returns aneeds_setupresult if no analyzer is connected for the project.doctor— health check for a project: its linked database, CI and comparison-branch state, the latest run, whether SQLCommenter tags are present, and a list of things to fix. Each item carries the tool call that fixes it.- CI tools — read the runs the analyzer recorded:
find_regressions,list_ci_runs,get_ci_run,get_ci_query,review_ci_run,get_latest_ci_run,get_query_history,get_query_status,get_repo_config.triage_queryandset_comparison_branchwrite triage state.
Companion skill (recommended)
Section titled “Companion skill (recommended)”Query Doctor publishes an agent skill at
docs.querydoctor.com/skill.md. It
takes an agent from an unconfigured repository to a CI run it can read: register
the server, create the project, write the workflow, then read what CI found.
Once the repository is wired, it tells the agent to check a plan before claiming
a query is fast or an index helps.
Skills are loaded from .claude/skills/. Drop it into your project, or into
~/.claude/skills/ for every project:
mkdir -p .claude/skills/query-doctorcurl -fsSL https://docs.querydoctor.com/skill.md \ -o .claude/skills/query-doctor/SKILL.mdRestart your MCP client after adding it.
An agent that can fetch a URL needs no install — point it at the same address and it can follow the guide directly.
Removing
Section titled “Removing”claude mcp remove query-doctorTroubleshooting
Section titled “Troubleshooting”- Tools don’t appear in the agent — confirm
claude mcp get query-doctorreports✓ Connected, then restart the client. - A tool returns an authorization error — sign in via the browser flow (or
/mcpin Claude Code). The CI read tools work anonymously;optimize_queryand the triage writes need a session. optimize_queryreturnsneeds_setup— no analyzer is connected for that project. Start the analyzer against your database (see CI integration) and retry.