Skip to content

Add native SQL query formatting tool - #32

Merged
rmorehig merged 1 commit into
mainfrom
rafa/query-format
Oct 16, 2026
Merged

rmorehig merged 1 commit into
mainfrom
rafa/query-format

Conversation

@rmorehig

@rmorehig rmorehig commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Add the query-format MCP tool and RawTreeClient.formatQuery, using authenticated POST /v1/query-format without executing SQL. The tool preserves complete SQL and the full { "formatted": "..." } response, follows existing organization/cluster/database defaults and explicit-scope mode, validates success response shape, and forwards MCP cancellation to the HTTP request.

Example tool arguments:

{ "sql": "select 1; select 'hello'", "organization": "acme", "cluster": "production" }

The API accepts 50 MiB JSON requests, 100 MiB formatted output, and a 30-second formatting timeout. Native inline INSERT VALUES data is preserved verbatim without completeness/schema validation. Raise the bundled HTTP (previously 100 KiB) and stdio (previously 10 MiB) request limits to a bounded 51 MiB for the API payload plus MCP envelope. Client/hosting gateway limits can still be smaller; document that boundary.

Bump MCP 0.3.5 → 0.3.6 and add the changelog entry. The frozen pnpm lockfile needs no change because it does not record the root package version. No release is published.

Dependency: Platform #1468, inspected at 397dc652846ad5820073641c19301ea154289cce. Deployment is required; this PR does not establish production endpoint availability.

Validation:

  • Frozen pnpm dependency installation, pnpm lint, pnpm test (197 passed), and pnpm build passed.
  • Tests cover authenticated route/body, defaults and overrides, explicit-scope discovery, full large SQL/output, structured error statuses, malformed responses, and MCP cancellation.
  • Four real transport tests round-trip 11 MiB documents over HTTP and stdio in both legacy and modern protocol modes, using the built stdio entrypoint.
  • Executable HTTP cancellation proof confirms active API requests close for both protocol modes.
  • Existing local Platform #1468 stack: real native 11 MiB formatting and syntax errors verified through legacy and modern stdio. No Platform files changed.
  • Codex autoreview (--mode local --max-priority P3) and thermo-nuclear maintainability review complete; final review has no actionable findings. TruffleHog clean. The earlier empty-SQL finding was rejected against the Platform handler, which explicitly rejects empty/whitespace SQL; corrected review passed.

Companion: CLI #82.


Note

Low Risk
Read-only formatting with no SQL execution; main operational change is higher MCP request buffers, which can increase memory use for very large payloads.

Overview
Adds a query-format MCP tool and RawTreeClient.formatQuery, calling authenticated POST /v1/query-format to return the full { "formatted": "..." } payload without executing SQL or writing query logs. Scope follows existing organization/cluster/database defaults and explicit-scope mode; success responses are validated and MCP cancellation is forwarded to the outbound HTTP request via a new AbortSignal on the API client.

HTTP and stdio transports now accept MCP requests up to 51 MiB (MAX_MCP_REQUEST_BYTES) so large SQL can fit under the API’s 50 MiB JSON cap plus MCP envelope overhead. Package version is 0.3.6 with README/changelog updates; tests cover the tool, errors, cancellation, and ~11 MiB round-trips over real HTTP/stdio paths.

Requires Platform POST /v1/query-format (Platform PR #1468).

Reviewed by Cursor Bugbot for commit 29bfde7. Bugbot is set up for automated code reviews on this repo. Configure here.

@rmorehig
rmorehig merged commit 54d7210 into main Oct 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant