From 3512c2404b3be1627693b529ec36cebd42694bd9 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 04:30:43 +0000 Subject: [PATCH] fix(get-doc): Say where an off-site redirect goes and that stale search results fail docs.sentry.io now redirects some pages, such as ai/mcp.md, to mcp.sentry.dev. get_doc reported those as missing and told the agent to run search_docs, which returns the same stale path. Name the redirect target instead, and tell the agent that a failing search_docs result is out of date so it picks another result. Refs getsentry/toolkit#2491 --- packages/mcp-core/src/tools/catalog/get-doc.test.ts | 8 ++++++-- packages/mcp-core/src/tools/catalog/get-doc.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/mcp-core/src/tools/catalog/get-doc.test.ts b/packages/mcp-core/src/tools/catalog/get-doc.test.ts index af093adb2..652c546b2 100644 --- a/packages/mcp-core/src/tools/catalog/get-doc.test.ts +++ b/packages/mcp-core/src/tools/catalog/get-doc.test.ts @@ -298,7 +298,11 @@ describe("get_doc", () => { const fetchSpy = vi.spyOn(global, "fetch"); await expect( getDoc.handler({ path: "/product/offsite.md" }, context), - ).rejects.toThrow(UserInputError); + ).rejects.toThrow( + new UserInputError( + "This documentation page redirects to https://sentry.io/auth/login/, outside the docs sites that get_doc can read. Do not retry this path.", + ), + ); expect(fetchSpy.mock.calls.map(([input]) => (input as URL).href)).toEqual([ "https://docs.sentry.io/product/offsite.md", ]); @@ -338,7 +342,7 @@ describe("get_doc", () => { ), ).rejects.toThrow( new UserInputError( - "Documentation not found at this path. The page may have been moved or removed. Use `search_docs()` to find the current path, and pass the `path` from its results exactly.", + "Documentation not found at this path. The page may have been moved or removed. Use `search_docs()` to find the current path, and pass the `path` from its results exactly. If `search_docs()` returned this path, that result is out of date: try a different result instead of this path again.", ), ); }); diff --git a/packages/mcp-core/src/tools/catalog/get-doc.ts b/packages/mcp-core/src/tools/catalog/get-doc.ts index ec193f565..fa9e3d7ea 100644 --- a/packages/mcp-core/src/tools/catalog/get-doc.ts +++ b/packages/mcp-core/src/tools/catalog/get-doc.ts @@ -7,7 +7,7 @@ import { defineTool } from "../../internal/tool-helpers/define"; import { getUserAgent } from "../../version"; const DOC_NOT_FOUND_MESSAGE = - "Documentation not found at this path. The page may have been moved or removed. Use `search_docs()` to find the current path, and pass the `path` from its results exactly."; + "Documentation not found at this path. The page may have been moved or removed. Use `search_docs()` to find the current path, and pass the `path` from its results exactly. If `search_docs()` returned this path, that result is out of date: try a different result instead of this path again."; // docs.sentry.io answers unknown paths with 200 and a "Page Not Found" page, // marked with this header. @@ -107,7 +107,12 @@ export default defineTool({ break; } const nextUrl = resolveDocUrl(location, docUrl); - if (!nextUrl || redirects >= MAX_REDIRECTS) { + if (!nextUrl) { + throw new UserInputError( + `This documentation page redirects to ${location}, outside the docs sites that get_doc can read. Do not retry this path.`, + ); + } + if (redirects >= MAX_REDIRECTS) { throw new UserInputError(DOC_NOT_FOUND_MESSAGE); } docUrl = nextUrl;