feat: support edge function runtime logs in get_logs#326
Conversation
Adds an edge-function-runtime service to get_logs exposing edge function
console output (function_logs), which was previously unreachable via MCP.
Migrates the cloud logs path from the deprecated BigQuery logs.all
endpoint to the ClickHouse /v1/projects/{ref}/analytics/endpoints/logs
endpoint; the BigQuery query builder is retained for self-hosted
deployments, which cannot use the ClickHouse endpoint.
All get_logs output is now wrapped in the same untrusted-data
prompt-injection boundary as execute_sql, via a shared helper.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review feedback: expose optional iso_timestamp_start/iso_timestamp_end on get_logs (24h default window unchanged; API caps ranges at 24h) and drop the Log Drains pointer from the tool description while keeping the no-polling guidance. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Coverage Report for CI Build 29495866070Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.08%) to 96.325%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions35 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
|
THANKS @barryroodt would you mind adding edge func name resolution to the tool before merge? that way an agent can ask for the logs of x func instead of first grabbing the UUID (changes per deployment) I did a sample implementation here https://github.com/sourman/supabase-mcp/tree/feat/function-logs-nameres I ran your PR against my live supabase though and it looks good. |
|
I added the I used the preview MCP build to deploy an edge fn hitting all 5 console levels, invoked it, and confirmed new MCP's |
|
Re:
I think we're clear to remove this old BigQuery branch, because self-hosted retains its own copy of these queries in the supabase repo, invoked here in its |
getLogQuery had no production callers: getLogs (api-platform) uses only getClickHouseLogQuery, and self-hosted routes through studio's own copy of these queries, not this package. Drop the builder, its tests, and the stale logs.all MSW handler.
commit: |
Thanks so much for this @sourman, and for running it against your live project, that end to end confirmation is really reassuring 🙏 I've tracked your request (name resolution) as its own follow-up, with your branch linked as the reference implementation. One thing I want to confirm in the follow-up is which log attribute to filter on so we capture a function's logs across all of its deployments in the window (the query exposes both |
Thanks for validating the update! |
Done and pushed in c48d1e4 |
Sync generated types with the upstream OpenAPI spec (new /analytics/endpoints/metrics endpoint + ssl_enforcement_required enum value). Purely additive upstream drift, unrelated to the logs change; required to pass the 'Check for diff' CI gate.
Problem
The
get_logsMCP tool only exposes edge function invocation logs (function_edge_logs). Edge function runtime logs —console.logoutput, the dashboard's per-function "Logs" view (function_logs) — are unreachable via MCP. Reported independently by two users in April; confirmed as a gap inlogs.ts(Linear: AI-651).The tool also still queries the deprecated BigQuery
logs.allendpoint (Linear: AI-890 / platform PR supabase/platform#35096 context).Changes
edge-function-runtimeservice onget_logs, returning edge function console output.edge-functionkeeps meaning invocation logs (backward compatible).getLogsnow calls/v1/projects/{ref}/analytics/endpoints/logswith ClickHouse SQL against the unifiedlogstable (newgetClickHouseLogQuerybuilder). The endpoint already exists in the generated management API types — no type regen.getLogQueryhad no production callers (onlygetClickHouseLogQueryis wired intogetLogs), and self-hosted routes through Studio's own copy of these queries, not this package. Dropped the builder, its tests, and the stalelogs.allMSW handler (thanks @mattrossman for the catch).get_logsoutput is now wrapped in the same UUID-salted<untrusted-data>boundary asexecute_sql, extracted into a sharedwrapWithUntrustedDataBoundaryhelper (log content is arbitrary user text).logs.test.tscovering the ClickHouse builder for every service.Notes for reviewers
branch-actionmaps tosource = 'workflow_run_logs'withlog_attributes['workflow_run']— matches platform PR #35096 (source added to the endpoint 2 Jul). It's not yet inshared-data/log-constants.ts; flagged to the observability team to confirm.source = 'edge_logs'for theapiservice (per the ClickHouse logs query reference) where #35096 uses'api', and it does not repurpose the existingedge-functionvalue. Both raised on the Linear tickets.Verification
AI-assisted (Claude + Codex via verified-swarm harness); human-reviewed by @barryroodt. Evidence:
pnpm typecheck— cleanCI=true pnpm test:unit— 174/174 pass (11 files)pnpm format:check(biome) — cleanexecute_sql, API shape/backward compat) — findings adjudicated and folded inLinear: AI-651, AI-890
🤖 Generated with Claude Code