Skip to content

Resolve .md page URLs in the MCP getPage tool - #4580

Open
drodriguezhdez wants to merge 1 commit into
GitbookIO:mainfrom
drodriguezhdez:fix/mcp-getpage-md-urls
Open

Resolve .md page URLs in the MCP getPage tool#4580
drodriguezhdez wants to merge 1 commit into
GitbookIO:mainfrom
drodriguezhdez:fix/mcp-getpage-md-urls

Conversation

@drodriguezhdez

Copy link
Copy Markdown

getPage returned Page not found for the Markdown URL of a page (<page>.md), which is the form llms.txt lists and the "View as Markdown" action links to. The HTTP middleware already strips .md before routing; the MCP path resolves URLs through extractPagePath, which did not.

This adds a removeMarkdownExtension helper and applies it in extractPagePath, so getPage and askQuestion accept both forms. Only a trailing .md is stripped.

Repro on production: getPage with https://gitbook.com/docs/getting-started/llm-ready-docs.md fails, the same URL without .md succeeds, and the .md form is what https://gitbook.com/docs/llms.txt emits.

Follow-up to #4166, which fixed the root-domain case in the same function.

@changeset-bot

changeset-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a1ce243

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gitbook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant