From a042eac2bde26c2a79a1dedb57864cdd043694ed Mon Sep 17 00:00:00 2001 From: Sebastian Shanus Date: Mon, 26 Oct 2026 16:03:00 -0400 Subject: [PATCH 1/3] fix(mcp-core): send analyze_issue_with_seer instruction as user_context Sentry's autofix endpoint reads `user_context` and ignores unknown keys, so the `instruction` key MCP sent has been dropped since getsentry/sentry#116162 routed every request to the agent path. Send the instruction as `user_context`, omit it when empty, and drop the unused `event_id`. Note in the tool description that the instruction only applies when starting a new analysis. Fixes AIML-3769 --- packages/mcp-core/src/api-client/client.ts | 9 +++--- packages/mcp-core/src/toolDefinitions.json | 2 +- .../catalog/analyze-issue-with-seer.test.ts | 28 ++++++++++++++----- .../tools/catalog/analyze-issue-with-seer.ts | 4 ++- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/packages/mcp-core/src/api-client/client.ts b/packages/mcp-core/src/api-client/client.ts index 09f675447..74dfd6db3 100644 --- a/packages/mcp-core/src/api-client/client.ts +++ b/packages/mcp-core/src/api-client/client.ts @@ -5401,12 +5401,10 @@ export class SentryApiService { { organizationSlug, issueId, - eventId, - instruction = "", + instruction, }: { organizationSlug: string; issueId: string; - eventId?: string; instruction?: string; }, opts?: RequestOptions, @@ -5415,9 +5413,10 @@ export class SentryApiService { apiPath`/organizations/${organizationSlug}/issues/${issueId}/autofix/`, { method: "POST", + // Sentry ignores unknown keys, so the instruction must go in + // `user_context`. Omit it when empty. body: JSON.stringify({ - event_id: eventId, - instruction, + user_context: instruction || undefined, }), }, opts, diff --git a/packages/mcp-core/src/toolDefinitions.json b/packages/mcp-core/src/toolDefinitions.json index c5113dba6..bbeb7c520 100644 --- a/packages/mcp-core/src/toolDefinitions.json +++ b/packages/mcp-core/src/toolDefinitions.json @@ -142,7 +142,7 @@ }, "instruction": { "type": "string", - "description": "Optional custom instruction for the AI analysis" + "description": "Optional custom instruction for the AI analysis. Only applied when starting a new analysis." } } }, diff --git a/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.test.ts b/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.test.ts index e5b68895d..9cb6d0f24 100644 --- a/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.test.ts +++ b/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.test.ts @@ -368,8 +368,9 @@ describe("analyze_issue_with_seer", () => { ); }); - it("handles start autofix with instruction", async () => { + async function startNewAnalysis(instruction: string | undefined) { let getCallCount = 0; + let requestBody: unknown; mswServer.use( http.get( @@ -387,11 +388,7 @@ describe("analyze_issue_with_seer", () => { http.post( "https://sentry.io/api/0/organizations/sentry-mcp-evals/issues/CLOUDFLARE-MCP-NEW/autofix/", async ({ request }) => { - const body = await request.json(); - expect(body).toEqual({ - event_id: undefined, - instruction: "Focus on memory leaks", - }); + requestBody = await request.json(); return HttpResponse.json({ run_id: 123, }); @@ -404,7 +401,7 @@ describe("analyze_issue_with_seer", () => { organizationSlug: "sentry-mcp-evals", regionUrl: null, issueId: "CLOUDFLARE-MCP-NEW", - instruction: "Focus on memory leaks", + instruction, }, { constraints: { @@ -419,12 +416,29 @@ describe("analyze_issue_with_seer", () => { await vi.runAllTimersAsync(); const result = await promise; + return { result, requestBody }; + } + + it("sends the instruction to Seer as user_context", async () => { + const { result, requestBody } = await startNewAnalysis( + "Focus on memory leaks", + ); + expect(requestBody).toEqual({ user_context: "Focus on memory leaks" }); expect(result).toContain("Starting new analysis..."); expect(result).toContain("Analysis started with Run ID: 123"); expect(result).toContain("## Analysis Complete"); }); + it.each([undefined, ""])( + "omits user_context when the instruction is %j", + async (instruction) => { + const { requestBody } = await startNewAnalysis(instruction); + + expect(requestBody).toEqual({}); + }, + ); + it("returns unsupported message for metric issues without calling Seer", async () => { let autofixRequests = 0; diff --git a/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts b/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts index 954576341..f2f82b301 100644 --- a/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts +++ b/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts @@ -82,7 +82,9 @@ export default defineTool({ issueUrl: ParamIssueUrl.optional(), instruction: z .string() - .describe("Optional custom instruction for the AI analysis") + .describe( + "Optional custom instruction for the AI analysis. Only applied when starting a new analysis.", + ) .optional(), }, annotations: { From ad536d6a00fc3ce1920ffb7fea14004b33fbfd42 Mon Sep 17 00:00:00 2001 From: Sebastian Shanus Date: Mon, 26 Oct 2026 16:04:43 -0400 Subject: [PATCH 2/3] ref(mcp-core): drop user_context comment in startAutofix --- packages/mcp-core/src/api-client/client.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/mcp-core/src/api-client/client.ts b/packages/mcp-core/src/api-client/client.ts index 74dfd6db3..bca9557f1 100644 --- a/packages/mcp-core/src/api-client/client.ts +++ b/packages/mcp-core/src/api-client/client.ts @@ -5413,8 +5413,6 @@ export class SentryApiService { apiPath`/organizations/${organizationSlug}/issues/${issueId}/autofix/`, { method: "POST", - // Sentry ignores unknown keys, so the instruction must go in - // `user_context`. Omit it when empty. body: JSON.stringify({ user_context: instruction || undefined, }), From 90b73e115352efc76c79b267575e35e3af0dc5ed Mon Sep 17 00:00:00 2001 From: Sebastian Shanus Date: Mon, 26 Oct 2026 16:36:07 -0400 Subject: [PATCH 3/3] ref(mcp-core): revert analyze_issue_with_seer instruction description --- packages/mcp-core/src/toolDefinitions.json | 2 +- .../mcp-core/src/tools/catalog/analyze-issue-with-seer.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/mcp-core/src/toolDefinitions.json b/packages/mcp-core/src/toolDefinitions.json index bbeb7c520..c5113dba6 100644 --- a/packages/mcp-core/src/toolDefinitions.json +++ b/packages/mcp-core/src/toolDefinitions.json @@ -142,7 +142,7 @@ }, "instruction": { "type": "string", - "description": "Optional custom instruction for the AI analysis. Only applied when starting a new analysis." + "description": "Optional custom instruction for the AI analysis" } } }, diff --git a/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts b/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts index f2f82b301..954576341 100644 --- a/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts +++ b/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts @@ -82,9 +82,7 @@ export default defineTool({ issueUrl: ParamIssueUrl.optional(), instruction: z .string() - .describe( - "Optional custom instruction for the AI analysis. Only applied when starting a new analysis.", - ) + .describe("Optional custom instruction for the AI analysis") .optional(), }, annotations: {