Skip to content

fix(mcp): exclude .navigation paths from list-pages and get-page#1374

Merged
larbish merged 3 commits into
nuxt-content:mainfrom
kjanat:fix/mcp-exclude-navigation-paths
May 27, 2026
Merged

fix(mcp): exclude .navigation paths from list-pages and get-page#1374
larbish merged 3 commits into
nuxt-content:mainfrom
kjanat:fix/mcp-exclude-navigation-paths

Conversation

@kjanat
Copy link
Copy Markdown
Contributor

@kjanat kjanat commented May 24, 2026

Summary

list-pages and get-page MCP tools return .navigation.yml entries as if they were real pages. @nuxt/content indexes .navigation.yml files into the same collection as page docs, and queryCollection().all() has no filter on stem/extension, so they ride straight through into the MCP response with paths ending in /.navigation and (often) empty titles.

An LLM consuming list-pages happily suggests these as real routes, and get-page returns the YAML stub or empty content — looks valid, isn't.

Fix

  • Add isNavigationPath(path) helper to layer/server/utils/content.ts — matches endsWith('.navigation') (covers /foo/.navigation and .navigation) plus includes('/.navigation/') (mid-path case, matching prior intent in sitemap.xml.ts).
  • list-pages: filter results before the map step — perf win and bypasses the type-inference issue chaining .filter after .map.
  • get-page: short-circuit to 404 when a .navigation path is requested directly.
  • sitemap.xml.ts: replace the inline duplicated predicate with the helper (also tightens the original .includes('/.navigation') to /.navigation/ so paths like /foo/.navigationthing don't false-positive).

Reproduction (before fix)

Any Docus site with .navigation.yml files anywhere in content. Call list-pages via MCP — every directory containing a .navigation.yml produces an entry with path ending in /.navigation. Call get-page with one of those paths and it returns the YAML stub instead of 404.

Try it out

If you want to verify the fix in your own Docus site before this lands, you can temporarily override the docus dependency with a prebuilt tarball of this branch:

// package.json
{
  "pnpm": {
    "overrides": {
      "docus": "https://kfc.kjanat.dev/docus/docus-5.11.0-mcp-navigation-fix.tgz",
    },
  },
}

(or the equivalent overrides / resolutions field for your package manager)

⚠️ This tarball is hosted on a personal bucket as a courtesy for review/testing. I will not host it forever — once this PR is merged and released, switch back to the regular docus version from the registry.

Notes

  • The .includes('/.navigation/') branch may be unreachable in practice (.navigation.yml is a leaf data file, no children) but I preserved the original sitemap author's defensive intent rather than silently narrowing behavior.
  • Case-sensitivity intentionally not handled (.Navigation etc.) — .navigation.yml is a fixed Nuxt Content convention; uppercase variants aren't processed as navigation files anyway, so a case-insensitive check would only provide false safety.

queryCollection().all() returns .navigation.yml entries alongside real
pages. MCP clients see them as routes (e.g. /aandoeningen/.navigation),
fetch returns the YAML stub or empty content.

Extract isNavigationPath helper, filter at list-pages, 404 at get-page,
dedupe sitemap.xml.ts.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

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

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docus Ready Ready Preview May 27, 2026 8:09pm

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 27, 2026

Open in StackBlitz

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

commit: fdb4de8

Copy link
Copy Markdown
Collaborator

@larbish larbish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@larbish larbish merged commit 3eb54da into nuxt-content:main May 27, 2026
4 checks passed
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