Skip to content

fix(mcp): use request fetch for raw page content#1304

Merged
larbish merged 1 commit intonuxt-content:mainfrom
onmax:fix/mcp-worker-get-page
Mar 12, 2026
Merged

fix(mcp): use request fetch for raw page content#1304
larbish merged 1 commit intonuxt-content:mainfrom
onmax:fix/mcp-worker-get-page

Conversation

@onmax
Copy link
Contributor

@onmax onmax commented Mar 11, 2026

Follow-up to #1302.

Summary

get-page now derives its url from the incoming request origin, which is correct for proxied and deployed environments. The remaining problem is that it still fetches its markdown body through an absolute self-request.

That works locally, but on Cloudflare Workers the same-worker subrequest returns 404, so list-pages works while get-page fails with Failed to get page.

This keeps the request-origin URL behavior but switches the content fetch to event.$fetch('/raw${path}.md'), which resolves through Nitro's request-bound fetch path instead of an outbound absolute request. That preserves the existing raw markdown response shape and avoids reconstructing markdown from parsed content data.

Reproduction

Variant Source Deployed worker Result
Bug onmax/repros/docus-mcp-get-page-worker-repro docus-mcp-get-page-repro.je-cf9.workers.dev get-page returns Failed to get page
Fix onmax/repros/docus-mcp-get-page-worker-repro-fix docus-mcp-get-page-repro-fix.je-cf9.workers.dev get-page returns the raw markdown content

Verify

Broken worker:

curl -sS \
  -H 'accept: application/json, text/event-stream' \
  -H 'content-type: application/json' \
  -X POST https://docus-mcp-get-page-repro.je-cf9.workers.dev/mcp \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get-page","arguments":{"path":"/test"}}}'

Fixed worker:

curl -sS \
  -H 'accept: application/json, text/event-stream' \
  -H 'content-type: application/json' \
  -X POST https://docus-mcp-get-page-repro-fix.je-cf9.workers.dev/mcp \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get-page","arguments":{"path":"/test"}}}'

Local source verification:

pnpm typecheck

@vercel
Copy link

vercel bot commented Mar 11, 2026

@onmax is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 11, 2026

Open in StackBlitz

npm i https://pkg.pr.new/create-docus@1304
npm i https://pkg.pr.new/docus@1304

commit: d200ef5

@onmax onmax changed the title fix(mcp): read get-page content from content body fix(mcp): use request fetch for raw page content Mar 12, 2026
@onmax onmax force-pushed the fix/mcp-worker-get-page branch from e6ea0b9 to ef9f309 Compare March 12, 2026 06:12
@larbish larbish merged commit 84ddc87 into nuxt-content:main Mar 12, 2026
2 of 3 checks passed
@onmax onmax deleted the fix/mcp-worker-get-page branch March 12, 2026 11:26
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.

2 participants