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;