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
jordienr requested a review from a team as a code owner July 22, 2026 08:23
@coveralls

coveralls commented Jul 22, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 30825182795

Warning

No base build found for commit 5cda067 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 96.315%

Details

  • Patch coverage: 4 uncovered changes across 1 file (103 of 107 lines covered, 96.26%).

Uncovered Changes

File Changed Covered %
packages/mcp-server-supabase/src/tools/debugging-tools.ts 81 77 95.06%
Total (3 files) 107 103 96.26%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 2992
Covered Lines: 2903
Line Coverage: 97.03%
Relevant Branches: 373
Covered Branches: 338
Branch Coverage: 90.62%
Branches in Coverage %: Yes
Coverage Strength: 49.22 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.

jeremenichelli pushed a commit to supabase/supabase that referenced this pull request Jul 31, 2026
Removes content that depends on supabase/agent-skills#112 and
supabase/mcp#341 before those PRs have merged:
- Delete ai-agents.mdx (new page documenting query_logs / get_logs / skill)
- Remove MCP tip admonition from debugging.mdx
- Remove telemetry-ai ContentListings panel from overview
- Remove telemetryAI export from telemetry.data.ts
- Remove telemetryAI from content-listings index
- Remove "AI & automation" nav group from NavigationMenu.constants.ts

These changes move to docs/telemetry-mcp-tools which targets this branch
as its base and will not merge until the two external PRs land.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jordienr added 11 commits August 3, 2026 16:49
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.
resolveLogWindow now rejects a malformed iso_timestamp_start/end with a
clear error instead of throwing a raw "Invalid time value", and rejects a
start at or after the end. Also rebases onto main to pick up the
regenerated management API types.
@jordienr
jordienr force-pushed the claude/mcp-query-logs-direct branch from c1bdc7f to 09e521e Compare August 3, 2026 14:52
Both tools currently ship an identical description to every client
regardless of platform (hosted vs local/self-hosted), so labeling get_logs
"Deprecated" risked a client universally hiding or deprioritizing it, which
would break self-hosted users since get_logs is their only working logs
tool. Reframe as environment-scoped preference (prefer query_logs on
hosted, use get_logs on local/self-hosted) instead of an unqualified
deprecation.
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