Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions packages/mcp-core/src/tools/catalog/get-doc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]);
Expand Down Expand Up @@ -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.",
),
);
});
Expand Down
9 changes: 7 additions & 2 deletions packages/mcp-core/src/tools/catalog/get-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
Loading