From 2958784da7b6aaf552a792211c00f1056b548919 Mon Sep 17 00:00:00 2001 From: srest2021 Date: Fri, 20 Nov 2026 14:54:56 -0800 Subject: [PATCH 1/5] fix(mcp): Link Seer credit failures to the auto-reload modal When Seer stops because the org is out of credits or hit its daily spend limit, analyze_issue_with_seer now links to the billing page with the auto-reload modal open, adding the 402's denial reason when Sentry sends one. Only SaaS has a billing page, so other hosts get no link. --- packages/mcp-core/src/api-client/client.ts | 5 ++ .../src/internal/tool-helpers/seer.test.ts | 79 +++++++++++++------ .../src/internal/tool-helpers/seer.ts | 21 +++-- .../catalog/analyze-issue-with-seer.test.ts | 10 +-- .../tools/catalog/analyze-issue-with-seer.ts | 3 +- packages/mcp-core/src/utils/url-utils.test.ts | 16 ++++ packages/mcp-core/src/utils/url-utils.ts | 17 ++++ 7 files changed, 117 insertions(+), 34 deletions(-) diff --git a/packages/mcp-core/src/api-client/client.ts b/packages/mcp-core/src/api-client/client.ts index 7f848ce725..7677788e37 100644 --- a/packages/mcp-core/src/api-client/client.ts +++ b/packages/mcp-core/src/api-client/client.ts @@ -113,6 +113,7 @@ import { getReleaseUrl as getReleaseUrlUtil, getReplaysSearchUrl as getReplaysSearchUrlUtil, getReplayUrl as getReplayUrlUtil, + getSeerAutoReloadUrl as getSeerAutoReloadUrlUtil, getTraceMetricsExploreUrl, getTraceUrl as getTraceUrlUtil, getUptimeMonitorUrl as getUptimeMonitorUrlUtil, @@ -861,6 +862,10 @@ export class SentryApiService { return getTraceUrlUtil(this.host, organizationSlug, traceId, this.protocol); } + getSeerAutoReloadUrl(organizationSlug: string): string | null { + return getSeerAutoReloadUrlUtil(this.host, organizationSlug, this.protocol); + } + getLogUrl(organizationSlug: string, logId: string): string { return getLogUrlUtil(this.host, organizationSlug, logId, this.protocol); } diff --git a/packages/mcp-core/src/internal/tool-helpers/seer.test.ts b/packages/mcp-core/src/internal/tool-helpers/seer.test.ts index e082bfc556..98322a4756 100644 --- a/packages/mcp-core/src/internal/tool-helpers/seer.test.ts +++ b/packages/mcp-core/src/internal/tool-helpers/seer.test.ts @@ -150,45 +150,80 @@ describe("seer-utils", () => { }); describe("getSeerPaymentRequiredMessage", () => { + const autoReloadUrl = "https://my-org.sentry.io/billing#modal"; + it("explains each 402 code from the API schema", () => { expect( - getSeerPaymentRequiredMessage({ - detail: "Out of credits", - code: "seer_out_of_credits", - }), - ).toBe(SEER_START_OUT_OF_CREDITS_MESSAGE); + getSeerPaymentRequiredMessage( + { + detail: "Out of credits", + code: "seer_out_of_credits", + }, + autoReloadUrl, + ), + ).toBe( + `${SEER_START_OUT_OF_CREDITS_MESSAGE}\n\nConfigure auto-reload: https://my-org.sentry.io/billing#modal`, + ); expect( - getSeerPaymentRequiredMessage({ - detail: "No quota", - code: "seer_out_of_quota", - }), + getSeerPaymentRequiredMessage( + { + detail: "No quota", + code: "seer_out_of_quota", + }, + autoReloadUrl, + ), ).toContain("not have enough Seer quota"); }); it.each([ - ["daily_cap_exceeded", "daily Seer spend limit"], - ["not_enough_credits", SEER_START_OUT_OF_CREDITS_MESSAGE], - [null, SEER_START_OUT_OF_CREDITS_MESSAGE], - ["constructor", SEER_START_OUT_OF_CREDITS_MESSAGE], + ["daily_cap_exceeded", "daily Seer spend limit", ":daily_cap_exceeded"], + [ + "not_enough_credits", + SEER_START_OUT_OF_CREDITS_MESSAGE, + ":not_enough_credits", + ], + [null, SEER_START_OUT_OF_CREDITS_MESSAGE, ""], + ["constructor", SEER_START_OUT_OF_CREDITS_MESSAGE, ""], ])( "explains an out-of-credits 402 with denial reason %s", - (denialReason, message) => { - expect( - getSeerPaymentRequiredMessage({ + (denialReason, message, link) => { + const result = getSeerPaymentRequiredMessage( + { detail: "Out of credits", code: "seer_out_of_credits", denialReason, - }), - ).toContain(message); + }, + autoReloadUrl, + ); + expect(result).toContain(message); + expect(result).toContain( + `Configure auto-reload: https://my-org.sentry.io/billing#modal${link}`, + ); }, ); + it("leaves out the link when there is no billing page", () => { + expect( + getSeerPaymentRequiredMessage( + { + detail: "Out of credits", + code: "seer_out_of_credits", + denialReason: "daily_cap_exceeded", + }, + null, + ), + ).not.toContain("Configure auto-reload"); + }); + it("treats a 402 without a known code as out of quota", () => { - expect(getSeerPaymentRequiredMessage("No budget")).toContain( - "not have enough Seer quota", - ); expect( - getSeerPaymentRequiredMessage({ detail: "x", code: "constructor" }), + getSeerPaymentRequiredMessage("No budget", autoReloadUrl), + ).toContain("not have enough Seer quota"); + expect( + getSeerPaymentRequiredMessage( + { detail: "x", code: "constructor" }, + autoReloadUrl, + ), ).toContain("not have enough Seer quota"); }); }); diff --git a/packages/mcp-core/src/internal/tool-helpers/seer.ts b/packages/mcp-core/src/internal/tool-helpers/seer.ts index 2e6d35f634..54a8910300 100644 --- a/packages/mcp-core/src/internal/tool-helpers/seer.ts +++ b/packages/mcp-core/src/internal/tool-helpers/seer.ts @@ -155,17 +155,25 @@ function lookupKnownKey( * Sentry versions send the out-of-quota 402 as a bare string with no code, so * anything that isn't out of credits is treated as out of quota. */ -export function getSeerPaymentRequiredMessage(responseBody: unknown): string { +export function getSeerPaymentRequiredMessage( + responseBody: unknown, + autoReloadUrl: string | null, +): string { if ( !isPlainObject(responseBody) || !lookupKnownKey(SEER_OUT_OF_CREDITS_CODES, responseBody["code"]) ) { return SEER_NO_QUOTA_MESSAGE; } - return ( - lookupKnownKey(SEER_DENIAL_MESSAGES, responseBody["denialReason"]) ?? - SEER_START_OUT_OF_CREDITS_MESSAGE - ); + const denialReason = responseBody["denialReason"]; + const message = lookupKnownKey(SEER_DENIAL_MESSAGES, denialReason); + return message + ? `${message}${formatAutoReloadLink(autoReloadUrl && `${autoReloadUrl}:${denialReason as string}`)}` + : `${SEER_START_OUT_OF_CREDITS_MESSAGE}${formatAutoReloadLink(autoReloadUrl)}`; +} + +function formatAutoReloadLink(url: string | null): string { + return url ? `\n\nConfigure auto-reload: ${url}` : ""; } /** @@ -194,9 +202,10 @@ export function getSeerSetupRequiredMessage( */ export function getFailureReasonGuidance( failureReason: string | null | undefined, + autoReloadUrl: string | null, ): string { if (failureReason === "out_of_credits") { - return `\n${SEER_CONTINUE_OUT_OF_CREDITS_MESSAGE}\n`; + return `\n${SEER_CONTINUE_OUT_OF_CREDITS_MESSAGE}${formatAutoReloadLink(autoReloadUrl)}\n`; } return ""; } 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 91954344ba..79a5b7472d 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 @@ -434,7 +434,7 @@ describe("analyze_issue_with_seer", () => { "Your organization does not have enough credits to start an Autofix run.", code: "seer_out_of_credits", }, - "Your organization does not have enough credits to start an Autofix run. Someone with billing access can adjust Seer spend and auto-reload in Sentry.", + "Your organization does not have enough credits to start an Autofix run. Someone with billing access can adjust Seer spend and auto-reload in Sentry.\n\nConfigure auto-reload: https://sentry-mcp-evals.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal", ], [ "out of credits, not enough credits", @@ -444,7 +444,7 @@ describe("analyze_issue_with_seer", () => { code: "seer_out_of_credits", denialReason: "not_enough_credits", }, - "Your organization does not have enough credits to start an Autofix run. Someone with billing access can adjust Seer spend and auto-reload in Sentry.", + "Your organization does not have enough credits to start an Autofix run. Someone with billing access can adjust Seer spend and auto-reload in Sentry.\n\nConfigure auto-reload: https://sentry-mcp-evals.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal:not_enough_credits", ], [ "out of credits, null denial reason", @@ -454,7 +454,7 @@ describe("analyze_issue_with_seer", () => { code: "seer_out_of_credits", denialReason: null, }, - "Your organization does not have enough credits to start an Autofix run. Someone with billing access can adjust Seer spend and auto-reload in Sentry.", + "Your organization does not have enough credits to start an Autofix run. Someone with billing access can adjust Seer spend and auto-reload in Sentry.\n\nConfigure auto-reload: https://sentry-mcp-evals.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal", ], [ "daily spend limit reached", @@ -464,7 +464,7 @@ describe("analyze_issue_with_seer", () => { code: "seer_out_of_credits", denialReason: "daily_cap_exceeded", }, - "Your organization has reached its daily Seer spend limit. Someone with billing access can raise the limit in Sentry, or you can try again tomorrow.", + "Your organization has reached its daily Seer spend limit. Someone with billing access can raise the limit in Sentry, or you can try again tomorrow.\n\nConfigure auto-reload: https://sentry-mcp-evals.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal:daily_cap_exceeded", ], [ "out of quota", @@ -786,7 +786,7 @@ describe("analyze_issue_with_seer", () => { expect(result).toContain("## Analysis Failed"); expect(result).toContain( - "Your organization does not have enough credits to continue your Autofix run. Someone with billing access can adjust Seer spend and auto-reload in Sentry.", + "Your organization does not have enough credits to continue your Autofix run. Someone with billing access can adjust Seer spend and auto-reload in Sentry.\n\nConfigure auto-reload: https://sentry-mcp-evals.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal", ); }); 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 3526080805..c036e890e7 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 @@ -118,7 +118,7 @@ export default defineTool({ // Sentry answers 402 before starting a run when the org is out of // Seer credits or quota. if (error instanceof ApiError && error.status === 402) { - output += `## Analysis Not Started\n\n${getSeerPaymentRequiredMessage(error.responseBody)}\n`; + output += `## Analysis Not Started\n\n${getSeerPaymentRequiredMessage(error.responseBody, apiService.getSeerAutoReloadUrl(orgSlug))}\n`; // The failed run may already hold paid-for analysis, e.g. a root // cause found before the org ran out of credits. const previousOutput = previousRun @@ -213,6 +213,7 @@ export default defineTool({ output += `\n**Status**: ${status}\n`; output += getFailureReasonGuidance( autofixState.autofix.failure_reason, + apiService.getSeerAutoReloadUrl(orgSlug), ); output += getHumanInterventionGuidance(status); } diff --git a/packages/mcp-core/src/utils/url-utils.test.ts b/packages/mcp-core/src/utils/url-utils.test.ts index bfd2a07422..721e54e9bc 100644 --- a/packages/mcp-core/src/utils/url-utils.test.ts +++ b/packages/mcp-core/src/utils/url-utils.test.ts @@ -11,6 +11,7 @@ import { getReleaseUrl, getReplaysSearchUrl, getReplayUrl, + getSeerAutoReloadUrl, getTraceMetricsExploreUrl, getTraceUrl, getUptimeMonitorUrl, @@ -169,6 +170,21 @@ describe("url-utils", () => { }); }); + describe("getSeerAutoReloadUrl", () => { + it("links the org's billing page on SaaS", () => { + expect(getSeerAutoReloadUrl("us.sentry.io", "myorg")).toBe( + "https://myorg.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal", + ); + }); + + it.each(["sentry.example.com", "acme.my.sentry.io"])( + "returns null for %s, which has no billing page", + (host) => { + expect(getSeerAutoReloadUrl(host, "myorg")).toBeNull(); + }, + ); + }); + describe("getReleaseUrl", () => { it("should encode release versions in the path segment", () => { const result = getReleaseUrl( diff --git a/packages/mcp-core/src/utils/url-utils.ts b/packages/mcp-core/src/utils/url-utils.ts index 3fb5c07031..ae8dd247b1 100644 --- a/packages/mcp-core/src/utils/url-utils.ts +++ b/packages/mcp-core/src/utils/url-utils.ts @@ -346,6 +346,23 @@ export function getIssueUrl( ); } +/** + * Generates a link to the billing page with the Seer auto-reload modal open. + * @param host The Sentry host (may include regional subdomain for API access) + * @param organizationSlug Organization identifier + * @returns The billing URL, or null off SaaS, which has no billing page + */ +export function getSeerAutoReloadUrl( + host: string, + organizationSlug: string, + protocol: SentryProtocol = "https", +): string | null { + if (!isPublicSentryHost(host)) { + return null; + } + return `${protocol}://${organizationSlug}.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal`; +} + /** * Generates a Sentry dashboard URL. * @param host The Sentry host (may include regional subdomain for API access) From 5a480fefdd155aacaba43f5d5b0fb9c811488d1a Mon Sep 17 00:00:00 2001 From: srest2021 Date: Fri, 20 Nov 2026 15:21:04 -0800 Subject: [PATCH 2/5] ref(mcp): Link Seer credit failures to billing on every host Credit checks only deny orgs with token-billed Seer, which self-hosted doesn't have, so the SaaS-only check never applied. --- packages/mcp-core/src/api-client/client.ts | 2 +- .../mcp-core/src/internal/tool-helpers/seer.test.ts | 13 ------------- packages/mcp-core/src/internal/tool-helpers/seer.ts | 10 +++++----- packages/mcp-core/src/utils/url-utils.test.ts | 11 +++++------ packages/mcp-core/src/utils/url-utils.ts | 12 ++++++------ 5 files changed, 17 insertions(+), 31 deletions(-) diff --git a/packages/mcp-core/src/api-client/client.ts b/packages/mcp-core/src/api-client/client.ts index 7677788e37..300630ca6c 100644 --- a/packages/mcp-core/src/api-client/client.ts +++ b/packages/mcp-core/src/api-client/client.ts @@ -862,7 +862,7 @@ export class SentryApiService { return getTraceUrlUtil(this.host, organizationSlug, traceId, this.protocol); } - getSeerAutoReloadUrl(organizationSlug: string): string | null { + getSeerAutoReloadUrl(organizationSlug: string): string { return getSeerAutoReloadUrlUtil(this.host, organizationSlug, this.protocol); } diff --git a/packages/mcp-core/src/internal/tool-helpers/seer.test.ts b/packages/mcp-core/src/internal/tool-helpers/seer.test.ts index 98322a4756..818651a7f9 100644 --- a/packages/mcp-core/src/internal/tool-helpers/seer.test.ts +++ b/packages/mcp-core/src/internal/tool-helpers/seer.test.ts @@ -202,19 +202,6 @@ describe("seer-utils", () => { }, ); - it("leaves out the link when there is no billing page", () => { - expect( - getSeerPaymentRequiredMessage( - { - detail: "Out of credits", - code: "seer_out_of_credits", - denialReason: "daily_cap_exceeded", - }, - null, - ), - ).not.toContain("Configure auto-reload"); - }); - it("treats a 402 without a known code as out of quota", () => { expect( getSeerPaymentRequiredMessage("No budget", autoReloadUrl), diff --git a/packages/mcp-core/src/internal/tool-helpers/seer.ts b/packages/mcp-core/src/internal/tool-helpers/seer.ts index 54a8910300..defde4b64b 100644 --- a/packages/mcp-core/src/internal/tool-helpers/seer.ts +++ b/packages/mcp-core/src/internal/tool-helpers/seer.ts @@ -157,7 +157,7 @@ function lookupKnownKey( */ export function getSeerPaymentRequiredMessage( responseBody: unknown, - autoReloadUrl: string | null, + autoReloadUrl: string, ): string { if ( !isPlainObject(responseBody) || @@ -168,12 +168,12 @@ export function getSeerPaymentRequiredMessage( const denialReason = responseBody["denialReason"]; const message = lookupKnownKey(SEER_DENIAL_MESSAGES, denialReason); return message - ? `${message}${formatAutoReloadLink(autoReloadUrl && `${autoReloadUrl}:${denialReason as string}`)}` + ? `${message}${formatAutoReloadLink(`${autoReloadUrl}:${denialReason as string}`)}` : `${SEER_START_OUT_OF_CREDITS_MESSAGE}${formatAutoReloadLink(autoReloadUrl)}`; } -function formatAutoReloadLink(url: string | null): string { - return url ? `\n\nConfigure auto-reload: ${url}` : ""; +function formatAutoReloadLink(url: string): string { + return `\n\nConfigure auto-reload: ${url}`; } /** @@ -202,7 +202,7 @@ export function getSeerSetupRequiredMessage( */ export function getFailureReasonGuidance( failureReason: string | null | undefined, - autoReloadUrl: string | null, + autoReloadUrl: string, ): string { if (failureReason === "out_of_credits") { return `\n${SEER_CONTINUE_OUT_OF_CREDITS_MESSAGE}${formatAutoReloadLink(autoReloadUrl)}\n`; diff --git a/packages/mcp-core/src/utils/url-utils.test.ts b/packages/mcp-core/src/utils/url-utils.test.ts index 721e54e9bc..25a7e0e22b 100644 --- a/packages/mcp-core/src/utils/url-utils.test.ts +++ b/packages/mcp-core/src/utils/url-utils.test.ts @@ -177,12 +177,11 @@ describe("url-utils", () => { ); }); - it.each(["sentry.example.com", "acme.my.sentry.io"])( - "returns null for %s, which has no billing page", - (host) => { - expect(getSeerAutoReloadUrl(host, "myorg")).toBeNull(); - }, - ); + it("links the billing settings path on other hosts", () => { + expect(getSeerAutoReloadUrl("sentry.example.com", "myorg")).toBe( + "https://sentry.example.com/settings/myorg/billing/overview/#open-seer-auto-reload-modal", + ); + }); }); describe("getReleaseUrl", () => { diff --git a/packages/mcp-core/src/utils/url-utils.ts b/packages/mcp-core/src/utils/url-utils.ts index ae8dd247b1..f331e0c5f8 100644 --- a/packages/mcp-core/src/utils/url-utils.ts +++ b/packages/mcp-core/src/utils/url-utils.ts @@ -350,17 +350,17 @@ export function getIssueUrl( * Generates a link to the billing page with the Seer auto-reload modal open. * @param host The Sentry host (may include regional subdomain for API access) * @param organizationSlug Organization identifier - * @returns The billing URL, or null off SaaS, which has no billing page + * @returns The complete billing URL */ export function getSeerAutoReloadUrl( host: string, organizationSlug: string, protocol: SentryProtocol = "https", -): string | null { - if (!isPublicSentryHost(host)) { - return null; - } - return `${protocol}://${organizationSlug}.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal`; +): string { + const base = isPublicSentryHost(host) + ? `${protocol}://${organizationSlug}.sentry.io/settings/billing/overview/` + : `${protocol}://${host}/settings/${organizationSlug}/billing/overview/`; + return `${base}#open-seer-auto-reload-modal`; } /** From a6ea486ed7b0930f16c35a59c202d6e8910b9c61 Mon Sep 17 00:00:00 2001 From: srest2021 Date: Fri, 20 Nov 2026 15:37:10 -0800 Subject: [PATCH 3/5] ref(mcp): Build the auto-reload link like other web links and trim tests Use the shared getSentryWebBaseUrl instead of a SaaS/self-hosted branch, drop URL tests the tool tests already cover, and test that an unknown denial reason stays out of the link. --- .../src/internal/tool-helpers/seer.test.ts | 49 +++++++++++-------- packages/mcp-core/src/utils/url-utils.test.ts | 15 ------ packages/mcp-core/src/utils/url-utils.ts | 10 ++-- 3 files changed, 34 insertions(+), 40 deletions(-) diff --git a/packages/mcp-core/src/internal/tool-helpers/seer.test.ts b/packages/mcp-core/src/internal/tool-helpers/seer.test.ts index 818651a7f9..4f3451d3f2 100644 --- a/packages/mcp-core/src/internal/tool-helpers/seer.test.ts +++ b/packages/mcp-core/src/internal/tool-helpers/seer.test.ts @@ -161,9 +161,7 @@ describe("seer-utils", () => { }, autoReloadUrl, ), - ).toBe( - `${SEER_START_OUT_OF_CREDITS_MESSAGE}\n\nConfigure auto-reload: https://my-org.sentry.io/billing#modal`, - ); + ).toContain(SEER_START_OUT_OF_CREDITS_MESSAGE); expect( getSeerPaymentRequiredMessage( { @@ -176,31 +174,40 @@ describe("seer-utils", () => { }); it.each([ - ["daily_cap_exceeded", "daily Seer spend limit", ":daily_cap_exceeded"], - [ - "not_enough_credits", - SEER_START_OUT_OF_CREDITS_MESSAGE, - ":not_enough_credits", - ], - [null, SEER_START_OUT_OF_CREDITS_MESSAGE, ""], - ["constructor", SEER_START_OUT_OF_CREDITS_MESSAGE, ""], + ["daily_cap_exceeded", "daily Seer spend limit"], + ["not_enough_credits", SEER_START_OUT_OF_CREDITS_MESSAGE], + [null, SEER_START_OUT_OF_CREDITS_MESSAGE], + ["constructor", SEER_START_OUT_OF_CREDITS_MESSAGE], ])( "explains an out-of-credits 402 with denial reason %s", - (denialReason, message, link) => { - const result = getSeerPaymentRequiredMessage( + (denialReason, message) => { + expect( + getSeerPaymentRequiredMessage( + { + detail: "Out of credits", + code: "seer_out_of_credits", + denialReason, + }, + autoReloadUrl, + ), + ).toContain(message); + }, + ); + + it("links without a reason when the denial reason is unknown", () => { + expect( + getSeerPaymentRequiredMessage( { detail: "Out of credits", code: "seer_out_of_credits", - denialReason, + denialReason: "constructor", }, autoReloadUrl, - ); - expect(result).toContain(message); - expect(result).toContain( - `Configure auto-reload: https://my-org.sentry.io/billing#modal${link}`, - ); - }, - ); + ), + ).toBe( + `${SEER_START_OUT_OF_CREDITS_MESSAGE}\n\nConfigure auto-reload: ${autoReloadUrl}`, + ); + }); it("treats a 402 without a known code as out of quota", () => { expect( diff --git a/packages/mcp-core/src/utils/url-utils.test.ts b/packages/mcp-core/src/utils/url-utils.test.ts index 25a7e0e22b..bfd2a07422 100644 --- a/packages/mcp-core/src/utils/url-utils.test.ts +++ b/packages/mcp-core/src/utils/url-utils.test.ts @@ -11,7 +11,6 @@ import { getReleaseUrl, getReplaysSearchUrl, getReplayUrl, - getSeerAutoReloadUrl, getTraceMetricsExploreUrl, getTraceUrl, getUptimeMonitorUrl, @@ -170,20 +169,6 @@ describe("url-utils", () => { }); }); - describe("getSeerAutoReloadUrl", () => { - it("links the org's billing page on SaaS", () => { - expect(getSeerAutoReloadUrl("us.sentry.io", "myorg")).toBe( - "https://myorg.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal", - ); - }); - - it("links the billing settings path on other hosts", () => { - expect(getSeerAutoReloadUrl("sentry.example.com", "myorg")).toBe( - "https://sentry.example.com/settings/myorg/billing/overview/#open-seer-auto-reload-modal", - ); - }); - }); - describe("getReleaseUrl", () => { it("should encode release versions in the path segment", () => { const result = getReleaseUrl( diff --git a/packages/mcp-core/src/utils/url-utils.ts b/packages/mcp-core/src/utils/url-utils.ts index f331e0c5f8..6f38d7546d 100644 --- a/packages/mcp-core/src/utils/url-utils.ts +++ b/packages/mcp-core/src/utils/url-utils.ts @@ -357,10 +357,12 @@ export function getSeerAutoReloadUrl( organizationSlug: string, protocol: SentryProtocol = "https", ): string { - const base = isPublicSentryHost(host) - ? `${protocol}://${organizationSlug}.sentry.io/settings/billing/overview/` - : `${protocol}://${host}/settings/${organizationSlug}/billing/overview/`; - return `${base}#open-seer-auto-reload-modal`; + return getSentryWebBaseUrl( + host, + organizationSlug, + "/settings/billing/overview/#open-seer-auto-reload-modal", + protocol, + ); } /** From fdb5136971b470396fd6712aee26cdc3bfee26ac Mon Sep 17 00:00:00 2001 From: srest2021 Date: Fri, 20 Nov 2026 15:45:09 -0800 Subject: [PATCH 4/5] test(mcp): Check the auto-reload link in the denial reason table --- .../src/internal/tool-helpers/seer.test.ts | 45 ++++++++----------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/packages/mcp-core/src/internal/tool-helpers/seer.test.ts b/packages/mcp-core/src/internal/tool-helpers/seer.test.ts index 4f3451d3f2..a5d02a08da 100644 --- a/packages/mcp-core/src/internal/tool-helpers/seer.test.ts +++ b/packages/mcp-core/src/internal/tool-helpers/seer.test.ts @@ -174,40 +174,31 @@ describe("seer-utils", () => { }); it.each([ - ["daily_cap_exceeded", "daily Seer spend limit"], - ["not_enough_credits", SEER_START_OUT_OF_CREDITS_MESSAGE], - [null, SEER_START_OUT_OF_CREDITS_MESSAGE], - ["constructor", SEER_START_OUT_OF_CREDITS_MESSAGE], + ["daily_cap_exceeded", "daily Seer spend limit", ":daily_cap_exceeded"], + [ + "not_enough_credits", + SEER_START_OUT_OF_CREDITS_MESSAGE, + ":not_enough_credits", + ], + [null, SEER_START_OUT_OF_CREDITS_MESSAGE, ""], + ["constructor", SEER_START_OUT_OF_CREDITS_MESSAGE, ""], ])( "explains an out-of-credits 402 with denial reason %s", - (denialReason, message) => { - expect( - getSeerPaymentRequiredMessage( - { - detail: "Out of credits", - code: "seer_out_of_credits", - denialReason, - }, - autoReloadUrl, - ), - ).toContain(message); - }, - ); - - it("links without a reason when the denial reason is unknown", () => { - expect( - getSeerPaymentRequiredMessage( + (denialReason, message, reasonSuffix) => { + const result = getSeerPaymentRequiredMessage( { detail: "Out of credits", code: "seer_out_of_credits", - denialReason: "constructor", + denialReason, }, autoReloadUrl, - ), - ).toBe( - `${SEER_START_OUT_OF_CREDITS_MESSAGE}\n\nConfigure auto-reload: ${autoReloadUrl}`, - ); - }); + ); + expect(result).toContain(message); + expect(result.split("\n").at(-1)).toBe( + `Configure auto-reload: ${autoReloadUrl}${reasonSuffix}`, + ); + }, + ); it("treats a 402 without a known code as out of quota", () => { expect( From 9c1a11b495c601b4ae141516a4f2b880ee06ec06 Mon Sep 17 00:00:00 2001 From: srest2021 Date: Fri, 20 Nov 2026 16:09:44 -0800 Subject: [PATCH 5/5] fix(mcp): Use the settings billing path for the auto-reload link on dedicated hosts Sentry serves billing at /settings//billing/, not under /organizations//, so build the path directly as the CLI does. --- packages/mcp-core/src/utils/url-utils.test.ts | 9 +++++++++ packages/mcp-core/src/utils/url-utils.ts | 10 ++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/mcp-core/src/utils/url-utils.test.ts b/packages/mcp-core/src/utils/url-utils.test.ts index bfd2a07422..05412e06aa 100644 --- a/packages/mcp-core/src/utils/url-utils.test.ts +++ b/packages/mcp-core/src/utils/url-utils.test.ts @@ -11,6 +11,7 @@ import { getReleaseUrl, getReplaysSearchUrl, getReplayUrl, + getSeerAutoReloadUrl, getTraceMetricsExploreUrl, getTraceUrl, getUptimeMonitorUrl, @@ -169,6 +170,14 @@ describe("url-utils", () => { }); }); + describe("getSeerAutoReloadUrl", () => { + it("links the org's billing settings on a dedicated host", () => { + expect(getSeerAutoReloadUrl("acme.my.sentry.io", "myorg")).toBe( + "https://acme.my.sentry.io/settings/myorg/billing/overview/#open-seer-auto-reload-modal", + ); + }); + }); + describe("getReleaseUrl", () => { it("should encode release versions in the path segment", () => { const result = getReleaseUrl( diff --git a/packages/mcp-core/src/utils/url-utils.ts b/packages/mcp-core/src/utils/url-utils.ts index 6f38d7546d..f331e0c5f8 100644 --- a/packages/mcp-core/src/utils/url-utils.ts +++ b/packages/mcp-core/src/utils/url-utils.ts @@ -357,12 +357,10 @@ export function getSeerAutoReloadUrl( organizationSlug: string, protocol: SentryProtocol = "https", ): string { - return getSentryWebBaseUrl( - host, - organizationSlug, - "/settings/billing/overview/#open-seer-auto-reload-modal", - protocol, - ); + const base = isPublicSentryHost(host) + ? `${protocol}://${organizationSlug}.sentry.io/settings/billing/overview/` + : `${protocol}://${host}/settings/${organizationSlug}/billing/overview/`; + return `${base}#open-seer-auto-reload-modal`; } /**