Skip to content

feat: add query_logs tool for custom log queries (CI mirror of #333) - #341

Open
jordienr wants to merge 12 commits into
mainfrom
claude/mcp-query-logs-direct
Open

feat: add query_logs tool for custom log queries (CI mirror of #333)#341
jordienr wants to merge 12 commits into
mainfrom
claude/mcp-query-logs-direct

Conversation

@jordienr

Copy link
Copy Markdown
Member

Same changes as #333, pushed to a branch on the repo (not a fork) so the e2e tests run with CI secrets — #333's test check can't pass from the fork because forks don't receive secrets.

Do not merge this in place of #333 unless we decide to; it exists to verify the e2e suite goes green with secrets available. #333 remains the review PR.

Identical head commit as #333 (c1bdc7f).

jordienr added 12 commits July 16, 2026 16:24
Adds a query_logs debugging tool that runs a custom read-only ClickHouse
SQL query against a project's unified logs stream, for cases where the
get_logs service presets are too coarse. Reuses the existing analytics
logs endpoint and validates that queries are SELECT/WITH only.
- add function_edge_logs to the sql source-hint list so models can reach
  edge function invocation logs
- require a non-empty sql query (.min(1)), matching execute_sql
- add execution tests for query_logs: sql passthrough + timestamp
  defaulting, custom window forwarding, and empty-query rejection
- mark get_logs as deprecated on hosted projects in favour of query_logs,
  while keeping it as the path for CLI/self-hosted
- document that query_logs (ClickHouse) is hosted-only and will not work
  on CLI/self-hosted yet
The permissive mention of iso_timestamp_start/iso_timestamp_end wasn't
steering model behaviour, so narrow time-range questions silently inherited
the 24h default and over-counted. Make it a directive instruction in both
get_logs and query_logs, matching the mechanism that flipped tool selection.
The description promises iso_timestamp_start defaults to 24h before the end,
but the handler always computed start from now(), so supplying only
iso_timestamp_end produced an inverted/empty window. Derive the end first
(supplied or now), then default start to end - 24h, shared by get_logs and
query_logs.
@jordienr
jordienr requested a review from a team as a code owner July 22, 2026 08:23
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 29903778647

Coverage increased (+0.1%) to 96.432%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 94 of 94 lines across 3 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 2972
Covered Lines: 2887
Line Coverage: 97.14%
Relevant Branches: 363
Covered Branches: 329
Branch Coverage: 90.63%
Branches in Coverage %: Yes
Coverage Strength: 48.27 hits per line

💛 - Coveralls

@barryroodt

Copy link
Copy Markdown
Contributor

Structured review done against this head (c1bdc7f, same SHA as #333, so everything transfers). CI green here confirms the #333 failures were fork-secrets only. The resolveLogWindow fix is right, and server.test.ts:1718 pins the end-anchored contract properly.

One blocker before the checkmark: the types regen drops fields that exist on main. management-api/types.ts at this head removes 10 id: string fields from the SAML provider/domain response shapes vs current origin/main. Stale OpenAPI snapshot by the look of it (the Pgsodium/PlanGate hunks are fine, already on main). Fix is mechanical: rebase, re-run the regen.

Optional while you're in there: resolveLogWindow throws a raw Invalid time value on a malformed iso_timestamp_end. Caught by the framework, but a parseability check (and start < end) would give models a clear validation error instead.

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.

3 participants