refactor(mcp): split hyperdx_query into 5 display-type-specific tools#2294
refactor(mcp): split hyperdx_query into 5 display-type-specific tools#2294brandon-pereira wants to merge 8 commits into
Conversation
Replace the monolithic hyperdx_query tool (one schema carrying fields for all display types) with five narrow tools, each with only its relevant fields: - hyperdx_timeseries (line + stacked_bar) - hyperdx_table (table + number + pie, with shape auto-upgrade) - hyperdx_search (raw event browsing) - hyperdx_event_patterns (Drain pattern mining) - hyperdx_sql (raw ClickHouse SQL) hyperdx_query is removed from the tool surface. HDX-4252
🦋 Changeset detectedLatest commit: 386984d 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔴 Tier 4 — CriticalTouches auth, data models, config, tasks, OTel pipeline, ClickHouse, or CI/CD. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
E2E Test Results✅ All tests passed • 178 passed • 3 skipped • 1191s
Tests ran across 4 shards in parallel. |
- table.ts: narrow displayType to union type instead of string
- search.ts: remove redundant ?? '' after zod .default('')
- table.ts: note in shape description that groupBy is ignored for number
- sql.ts: note in description that results are always table rows
Also assert on sourceId in missing-field rejection tests to catch schema-required-field regressions.
|
Downgrading tier - changed lots of production code but mostly just moving logic not changing logic. |
…oupBy for number shape
PR ReviewClean, well-scoped refactor. Tests cover schema serialization, functional execution per shape, the auto-upgrade path, and rejection of missing required fields. Breaking change is correctly captured in Issues
Nice catches in this PR
|
…ks, add sampleSize .default()
…rces description, simplify select passthrough
Deep Review🟡 P2 — recommended
🔵 P3 nitpicks (15)
Reviewers (7): correctness, testing, maintainability, project-standards, api-contract, kieran-typescript, security. Testing gaps:
|
Summary
Replaces the monolithic
hyperdx_queryMCP tool with five narrow, display-type-specific tools. Each tool's schema contains only the parameters relevant to its use case — nodisplayTypediscriminator, no fields from other modes, no conditional required parameters.hyperdx_timeseries— line + stacked_bar charts (shapefield, defaults toline)hyperdx_table— table + number + pie aggregations (shapefield, auto-upgradesnumber/pie→tablewhenselect.length > 1)hyperdx_search— raw event/log row browsinghyperdx_event_patterns— Drain algorithm pattern mininghyperdx_sql— raw ClickHouse SQL (the only tool requiringconnectionId)hyperdx_queryis removed from the tool surface.What changed
New files (
packages/api/src/mcp/tools/query/):timeseries.ts,table.ts,search.ts,eventPatterns.ts,sql.ts— one tool registration per filerunEventPatterns.ts— extracted event pattern mining logic (pure code move, no logic changes)schemas.ts— rewritten with shared schema fragments (sourceIdSchema,whereSchema,mcpSelectItemSchema, etc.) and targetedwhere/whereLanguageguidance with WRONG/RIGHT examplesModified files:
index.ts— barrel now registers 5 tools instead of 1queryTool.test.ts— updated to test all 5 tools: schema serialization, functional queries, auto-upgrade behavior, required-field rejection, seeded pattern mininglistSources.ts— description and usage hints reference new tool namessaveDashboard.ts— hint fixed fromhyperdx_query→hyperdx_query_tile(pre-existing bug)content.ts— prompt guide updated for new tool names and event patterns call signatureBreaking change
hyperdx_queryis removed. Any external MCP consumer calling it by name will get a tool-not-found error. The five replacement tools cover all the same functionality with narrower, less error-prone schemas.Changeset is a
patchbecause MCP is still considered beta and subject to change.Ref: HDX-4252