This document is for AI-assisted code review, patch review, and PR analysis in this repository.
Read AGENTS.md first. If the review touches substantive code paths, read .agents/architecture.md before reviewing.
Prioritize findings in this order:
- Correctness bugs
- Safety regressions (read-only enforcement, destructive-op gating, HTTP/SSE authentication)
- Regressions in observable behavior (tool names, tool argument shapes, tool return shapes, prompt names, environment variable semantics,
/healthcontract) - Public API and compatibility risk
- Backend-enablement regressions across the ClickHouse and chDB combinations
- Packaging and optional dependency regressions, especially around the
chdbextra - Resource and timeout behavior (thread pool, query timeout, pagination cache)
- Missing or weak tests
- Style and nits
When reviewing a change, explicitly check whether it affects:
- tool names, argument names, argument defaults, or return shapes
- prompt names or prompt registration
- environment variable names, defaults, or semantics (update
README.mdif so) - read-only enforcement in
get_readonly_settingandbuild_query_settings - destructive-op detection in
_validate_query_for_destructive_ops(regex breadth, case handling, newline handling, new DDL forms) - HTTP and SSE authentication wiring and the token-or-disabled invariant
/healthresponse contract across the four backend-enablement combinations (ClickHouse on or off, chDB on or off)- behavior when the
chdbextra is missing. The server should warn and skip registration, not crash - config singletons and whether a code path mutates env vars without resetting the singleton
- pagination token lifecycle (creation, reuse across filter changes, TTL eviction)
- query thread pool behavior and the
CLICKHOUSE_MCP_QUERY_TIMEOUTcontract - context-based client config overrides in
create_clickhouse_clientand non-dict handling - middleware loader behavior, including error handling and the
setup_middlewarecontract - compatibility expectations for Python, ClickHouse,
fastmcp, andclickhouse-connectversions covered in CI
For tool-surface changes, confirm the tests exercise the behavior through the MCP client (fastmcp.Client) and not only the underlying function.
- Lead with findings, not summary.
- Order findings by severity.
- Use
file:linereferences. - Be explicit about impact.
- Call out what could break for real MCP clients and users (Claude Desktop configs, existing tool arguments, existing env vars).
- Distinguish confirmed issues from inferred risk.
If no material issues are found, say that explicitly and mention any residual testing or compatibility gaps (for example, chDB path not exercised, HTTP transport not smoke-tested, safety matrix not re-validated).
When a finding or assumption depends on library or server behavior that may have changed, verify it against the upstream source (ClickHouse, clickhouse-connect, FastMCP, chDB) rather than relying on memory. Note the version or commit you checked against. Flag any claim in the diff that looks version-sensitive and was not verified.
Use a structure like this:
- Findings, ordered by severity
- Open questions or assumptions
- Brief change summary, only if useful
Each finding should answer:
- what is wrong
- why it matters
- who or what it could break
- what evidence in the diff or repo context supports the concern
These points should be brief but factual and accurate.
Before saying a change looks good, make sure you understand:
- whether the MCP tool surface (names, arguments, returns) changed, intentionally or not
- whether any environment variable behavior changed and whether
README.mdreflects it - whether safety defaults still hold: read-only by default, DROP gated behind
CLICKHOUSE_ALLOW_DROP, HTTP/SSE auth required unless explicitly disabled - whether the change holds up across the ClickHouse-on, ClickHouse-off, chDB-on, chDB-off matrix
- whether the
chdbextra still being optional is respected - whether transport behavior still works for
stdio,http, andsse - whether tests target the right layer (unit config tests with
monkeypatch, tool tests through a live ClickHouse, or MCP-level tests viafastmcp.Client) - whether any important validation still has not been run, for example a local server round trip or a container-image smoke test