feat(mcp): add event_patterns display type to query tool#2250
Conversation
Port the Event Patterns feature to the MCP server's query tool so Claude can surface recurring log/trace patterns during investigations. - Add displayType 'event_patterns' to hyperdx_query with sampleSize and bodyExpression parameters - Extract shared minePatterns() into @hyperdx/common-utils/drain to eliminate duplication between MCP server and CLI - Auto-detect body column from source kind (Body for logs, SpanName for traces) with explicit override support - Sample random events from ClickHouse, run Drain template mining, return patterns sorted by estimated frequency with time-bucketed trends - Add 8 integration tests covering log/trace sources, filters, custom body expressions, validation, and schema serialization
🦋 Changeset detectedLatest commit: 39e3346 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 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 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
E2E Test Results✅ All tests passed • 177 passed • 3 skipped • 1231s
Tests ran across 4 shards in parallel. |
PR ReviewScope: Adds Findings
Strengths
No critical bugs or security issues. The Lucene/SQL |
Deep ReviewScope: PR #2250 vs Intent: Port the Event Patterns feature to the MCP server as ✅ No critical issues found. The diff has no exploitable injection (the caller-supplied 🟡 P2 -- recommended
🔵 P3 nitpicks (10)
Reviewers (12): correctness, testing, maintainability, project-standards, agent-native, learnings-researcher, security, performance, api-contract, reliability, adversarial, kieran-typescript. Testing gaps:
|
Summary
hyperdx_querytool as a newdisplayType: "event_patterns"optionminePatterns()function into@hyperdx/common-utils/drainto eliminate duplication between the MCP server and CLIScreenshot
MCP

CLI (to ensure backwards compatible)

How it works
hyperdx_querywithdisplayType: "event_patterns"and asourceIdBodyfor logs,SpanNamefor traces), or accepts an explicitbodyExpressionoverridesampleSize) and a total countminePatterns()function from@hyperdx/common-utilsruns the Drain template mining algorithm, groups results by cluster, computes estimated counts, and generates time-bucketed trend data<*>wildcards, estimated/sample counts, trend arrays, and sample body textsReferences
Resolves HDX-4142