Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
25ad7ee
fix(mcp): tighten tool and input descriptions
brandon-pereira Oct 16, 2026
063d287
fix(mcp): address review feedback on tool descriptions
brandon-pereira Oct 16, 2026
0c0ed30
fix(mcp): address inline review minors on tool descriptions
brandon-pereira Oct 16, 2026
121e998
fix(mcp): clarify alert schedule and chart-level whereLanguage defaults
brandon-pereira Oct 16, 2026
198947c
refactor(mcp): move dashboard sub-schema descriptions into common-uti…
brandon-pereira Oct 16, 2026
2ba7990
test(mcp): narrow input-description walker without a type assertion
brandon-pereira Oct 16, 2026
7635679
test(mcp): fix walker type error
brandon-pereira Oct 16, 2026
22c59b1
fix(mcp): correct return-shape, threshold, and alertable-tile descrip…
brandon-pereira Oct 16, 2026
12d4720
fix(mcp): use totalTimeMs consistently in trace breakdown description
brandon-pereira Oct 16, 2026
22deef6
test(mcp): narrow schema node with in instead of a cast
brandon-pereira Oct 16, 2026
17d1449
fix(mcp): clarify saved-search whereLanguage and event-delta topDelta…
brandon-pereira Oct 16, 2026
cbca7c2
fix(mcp): color rules compare the raw value; exponential histograms a…
brandon-pereira Oct 19, 2026
36f4c53
fix(mcp): default whereLanguage to lucene when creating a saved search
brandon-pereira Oct 19, 2026
9400561
Merge branch 'main' into agent/mcp-saved-search-where-language
brandon-pereira Oct 19, 2026
4ffb744
Merge branch 'main' into agent/mcp-saved-search-where-language
kodiakhq[bot] Oct 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mcp-saved-search-where-language.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/api': patch
---

fix(mcp): store whereLanguage as lucene when clickstack_save_saved_search creates a search without one, so its alerts no longer parse a Lucene filter as SQL
19 changes: 19 additions & 0 deletions packages/api/src/mcp/__tests__/savedSearches.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ describe('MCP Saved Search Tools', () => {
expect(output.where).toBe('');
expect(output.select).toBe('');
expect(output.tags).toEqual([]);
expect(output.whereLanguage).toBe('lucene');
});

it('should create a saved search with SQL where language', async () => {
Expand Down Expand Up @@ -378,6 +379,24 @@ describe('MCP Saved Search Tools', () => {
expect(updated?.where).toBe('StatusCode:Ok');
});

it('should keep the stored whereLanguage when an update omits it', async () => {
const savedSearch = await createTestSavedSearch({
where: "StatusCode = 'Error'",
whereLanguage: 'sql',
});

const result = await callTool(client, 'clickstack_save_saved_search', {
id: savedSearch._id.toString(),
name: 'Renamed',
sourceId: traceSource._id.toString(),
where: "StatusCode = 'Ok'",
});

expect(result.isError).toBeFalsy();
const updated = await SavedSearch.findById(savedSearch._id);
expect(updated?.whereLanguage).toBe('sql');
});

it('should return error for non-existent saved search on update', async () => {
const fakeId = '000000000000000000000000';
const result = await callTool(client, 'clickstack_save_saved_search', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export function registerSaveSavedSearch({
name: input.name,
select: input.select ?? '',
where: input.where ?? '',
whereLanguage: input.whereLanguage,
// Alerts read a missing whereLanguage as sql while the app reads it as
// lucene, so a new search must store it explicitly.
whereLanguage: input.whereLanguage ?? (isUpdate ? undefined : 'lucene'),
Comment thread
brandon-pereira marked this conversation as resolved.
Resolved
Comment thread
brandon-pereira marked this conversation as resolved.
Resolved
Comment thread
brandon-pereira marked this conversation as resolved.
Resolved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 major — Saved searches already stored without whereLanguage keep running their alerts as SQL

This change only fixes searches created from now on. Searches that clickstack_save_saved_search already created with no whereLanguage still have the field missing. checkAlerts (packages/api/src/tasks/checkAlerts/index.ts:176, 802) passes that missing value on, and buildSearchChartConfig (packages/common-utils/src/core/searchChartConfig.ts:165) turns it into 'sql'. So an existing search with where: "level:error" still breaks its alerts. An MCP update that leaves out whereLanguage keeps the field missing too, which the new update test now locks in. Fix: add a backfill migration under packages/api/migrations/mongo that sets whereLanguage: 'lucene' on saved searches where it does not exist. Another option is to default a missing value to lucene where alerts read saved searches, which matches how the app already reads it.

Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond

orderBy: input.orderBy,
source: input.sourceId,
tags: input.tags ?? [],
Expand Down
Loading