Repository navigation
fix(mcp): bind interval params in clickstack_sql - #3353
Conversation
clickstack_sql rendered its query as a table tile, and raw SQL only binds
{intervalSeconds} and {intervalMilliseconds} for time-series display types.
Every interval parameter and macro the tool description advertises
($__interval_s, $__timeInterval, $__timeInterval_ms), including its own
time-series example, failed with "Substitution intervalSeconds is not set".
Render as a line tile instead. displayType only picks which params to bind,
rows come back the same, and ClickHouse ignores params a query never uses.
🦋 Changeset detectedLatest commit: 586c9d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@squaredg is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
PR Review✅ No issues found. |
|
Deep Review✅ No critical issues found. The change switches 🔵 P3 nitpicks (2)
Reviewers (5 returned): correctness, maintainability, project-standards, previous-comments, learnings-researcher. Coverage: 4 of 9 dispatched reviewers (testing, api-contract, kieran-typescript, agent-native) had not returned at synthesis time and are not reflected above; the api-contract response-shape question they would have examined was independently resolved by the correctness reviewer's trace of the raw-SQL render path. The Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
The $__timeInterval tests queried otel_traces, which this suite never seeds, so they passed on an empty result. Seed logs and assert each bucket starts on an interval boundary and holds one row.
|
Re: Deep Review P3s
Re: second-round P3s — no change for either.
That's two rounds of automated review, so I'm leaving the rest to a maintainer. @brandon-pereira could you review and merge when you have a moment? |
…mes (#3354) ## Summary Agents using `clickstack_sql` have no tool that tells them which table a source reads from, so they guess. The tool's own examples make the guess for them: `FROM otel_logs` and `TimestampTime`. - An unqualified `otel_logs` only resolves when the tables are in the connection's default database. That's true for the default install and false for most other deployments. - The seed `otel_logs` schema has no `TimestampTime` column, so the time-series example fails even on a default install. - `clickstack_list_sources` returns each source's `timestampColumn` and key columns, but not its database or table. - Unknown-table errors come back with no hint. Changes: - `clickstack_list_sources` returns `table` (`<database>.<table>`) for every source with a table, and `database` for metric sources, whose tables are already listed in `metricTables`. - The `sql` parameter examples use `<table>` and `<timestampColumn>` placeholders, with one line saying where both come from. - Unknown-table and unknown-database errors get a hint pointing at the `table` from `clickstack_list_sources`. Unknown-column errors keep the `clickstack_describe_source` hint. Tests (all failed before the change): - `list_sources` includes the database-qualified table for log and trace sources, and the database for metric sources. - The `sql` examples use only placeholders, and run once those are filled from a source. - Real ClickHouse unknown-table messages produce the new hint, both from `errorHint` and end to end through `clickstack_sql`. Not in this PR: - Dashboard prompt and schema examples (`prompts/dashboards/content.ts`, `tools/dashboards/schemas.ts`) still hard-code `otel_traces` and `TimestampTime`. Raw SQL tiles can use `$__sourceTable` there, so that's a separate change. - Adding `sourceId` and `$__sourceTable` to `clickstack_sql` itself. I'll propose that separately. ### How to test on Vercel preview N/A — non-UI change. ### References - Linear Issue: HDX-5683 - Related PRs: #3353 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…es (#3355) ## Summary `clickstack_sql` takes only a `connectionId`, so an agent has to write the table name itself, and it often guesses wrong (#3354 covers the guessing). `$__sourceTable` already exists in common-utils, and raw SQL dashboard tiles resolve it through `runConfigTile`. The MCP SQL tool just never accepted a source. This adds an optional `sourceId` to `clickstack_sql` and passes it to the tile, so `$__sourceTable` expands to that source's `database.table`. It reuses the existing `runConfigTile` path that dashboard tiles use. Checks on the input: - A `sourceId` that doesn't exist or belongs to another team is rejected as "Source not found". - A source whose connection differs from `connectionId` is rejected. Otherwise `$__sourceTable` would expand against a table on another server. - `$__sourceTable` without a `sourceId` is rejected with an error that says to pass one. Today the renderer's message comes through instead ("requires a source to be selected"), which is written for the dashboard UI. The time-series example now reads `FROM $__sourceTable`. The table example keeps `FROM <table>` to show the path for tables that aren't registered as sources. Tests (all failed before the change): - `$__sourceTable` resolves to the source's table (counts seeded rows). - `$__sourceTable` without `sourceId` is rejected, and the error says to pass one. - An unknown `sourceId` and another team's `sourceId` are both rejected as not found. - A source on a different connection than `connectionId` is rejected. - The tool schema exposes an optional `sourceId`. - The time-series example uses `$__sourceTable` and the table example uses `<table>`. This matches the `sourceId` handling in our enterprise build, which has had it since source filters were added. That build also scopes it with source filters and RBAC, which aren't part of OSS and aren't included here. ### How to test on Vercel preview N/A — non-UI change. ### References - Linear Issue: HDX-5684 - Related PRs: #3353, #3354 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
clickstack_sql's description advertises{intervalSeconds:Int64},{intervalMilliseconds:Int64},$__interval_s,$__timeIntervaland$__timeInterval_ms, but every one of them failed withSubstitution intervalSeconds is not set. That includes the tool's own time-series example, so an agent following the description gets an error.The cause: the tool renders its query as a
tabletile. For raw SQL,displayTypeonly selects which query params get bound (QUERY_PARAMS_BY_DISPLAY_TYPEincommon-utils/src/rawSqlParams.ts), and only time-series types bind the interval params.The fix renders the query as a
linetile instead. Rows come back the same for any display type, and ClickHouse ignores params a query doesn't reference, so queries without interval macros are unaffected.Tests added to
queryTool.int.test.ts:$__interval_sresolve to the same bucket size (ms = s × 1000)$__timeIntervaland$__timeInterval_msrunThe first two failed before the fix with the substitution error.
Not in this PR: the description's examples also filter on
TimestampTime, which the seedotel_logsschema doesn't have. I'll fix that separately.How to test on Vercel preview
N/A — non-UI change.
References
🤖 Generated with Claude Code