feat(mcp): add hyperdx_describe_source tool and slim list_sources to catalog#2309
Conversation
…catalog Addresses the #1 MCP error class (39% of failures): LLMs guessing column names that don't exist (TimestampTime, service.name, count, etc.). New tool: hyperdx_describe_source - Full column schema (name, CH type, JS type) from DESCRIBE TABLE - Map attribute keys (SpanAttributes, ResourceAttributes, etc.) - Sampled low-cardinality values for columns like SeverityText, StatusCode, ServiceName — uses existing rollup tables via getAllKeyValues for performance, falls back to getMapValues - Sampled map attribute values for top-10 keys per map column - 10-second hard timeout with structured AbortError handling - Team-scoped access control via getSource(teamId, sourceId) Slimmed hyperdx_list_sources to a lightweight catalog: - Returns only id/name/kind/connectionId/keyColumns from MongoDB - No ClickHouse queries — instant response - Includes nextStep hint pointing to describe_source Moved source tools to dedicated module: - New packages/api/src/mcp/tools/sources/ directory - Registered as sourcesTools in mcpServer.ts - Dedicated test file: sources.test.ts (11 tests) Updated all tool descriptions and prompts: - All 5 split query tools reference describe_source - content.ts workflow updated to 5-step flow - SeverityText/StatusCode guidance references lowCardinalityValues - MCP.md documents the two-step discovery workflow
🦋 Changeset detectedLatest commit: 51d8327 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 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 • 1253s
Tests ran across 4 shards in parallel. |
PR ReviewSolid refactor with good test coverage (cross-team access, metric-source edge case, partial-result handling). A few items worth addressing:
No security issues (team scoping via |
Deep Review✅ No critical issues found. 🟡 P2 -- recommended
🔵 P3 nitpicks (10)
Reviewers (7): ce-correctness-reviewer, ce-reliability-reviewer, ce-security-reviewer, ce-kieran-typescript-reviewer, ce-testing-reviewer, ce-adversarial-reviewer, ce-maintainability-reviewer. Testing gaps:
|
|
Will fix P0 ObjectId validation separately - several tools affected. |
…nflict getLoggedInAgent(server) with default MOCK_USER credentials returns 409 Conflict when called twice in the same test run because the user already exists from beforeEach. Pass unique credentials for the second team registration.
…factor # Conflicts: # packages/api/src/mcp/prompts/dashboards/content.ts
| * Core schema-discovery logic. Extracted so the caller can wrap it in | ||
| * Promise.race for wall-clock timeout enforcement. | ||
| */ | ||
| async function describeSourceSchema( |
There was a problem hiding this comment.
I'm a bit worried about the perf of this method. There are a lot of db calls, and I wonder if we really need all of them
There was a problem hiding this comment.
Will explore reducing DB calls if the need arises - currently this helps reduce LLM hallucinations
Problem
The #1 MCP error class (39% of clickstack failures, 9 of 23 errors) is unknown column or identifier — the LLM invents column names like
TimestampTime,service.name,count,Timestamp,rows_read,memory_usagethat don't exist in the ClickHouse schema.Root causes:
hyperdx_list_sourcesreturned full column schemas for ALL sources in one response (50KB+), which overwhelms LLM contextSeverityText:errorwhen the real data usesERRORorErrorSolution
New tool:
hyperdx_describe_sourcePer-source schema discovery that returns:
DESCRIBE TABLELowCardinality(String)columns like SeverityText, StatusCode, ServiceName — uses existinggetAllKeyValues()rollup tables for performancegetSource(teamId, sourceId)Slimmed
hyperdx_list_sourcesNow a lightweight MongoDB-only catalog:
nextStephint pointing todescribe_sourceTwo-step workflow
Changes
tools/sources/describeSource.tshyperdx_describe_sourcetooltools/sources/index.tstools/sources/listSources.tstools/dashboards/listSources.tstools/dashboards/index.tsmcpServer.tssourcesToolsmoduletools/query/{search,table,timeseries,sql,eventPatterns}.tsdescribe_sourceprompts/dashboards/content.ts__tests__/sources.test.ts__tests__/dashboards.test.tsMCP.mdNo changes to
common-utils— reuses existinggetAllKeyValues()andgetMapValues()methods.Changeset
Patch release — this is a new tool addition and behavioral change to
list_sources, but the MCP server is still in beta (version: ${CODE_VERSION}-beta), so a patch bump is appropriate.Testing
Ensure agents call the new tool locally, and it queries the correct SeverityText (not hallucinate)

make ci-lint— passes (0 errors)make ci-unit— 957 tests pass across 19 suites