Skip to content

fix(mcp): resolve legacy documentation paths and update tool examples#2268

Open
santiagodeheza wants to merge 2 commits into
nuxt:mainfrom
santiagodeheza:fix/mcp-documentation-path-aliases
Open

fix(mcp): resolve legacy documentation paths and update tool examples#2268
santiagodeheza wants to merge 2 commits into
nuxt:mainfrom
santiagodeheza:fix/mcp-documentation-path-aliases

Conversation

@santiagodeheza

Copy link
Copy Markdown

Summary

The official Nuxt MCP server at https://nuxt.com/mcp returns 404 for several paths listed in the get_documentation_page tool description — most notably Nuxt 4 directory-structure pages.

Root cause: The tool's COMMON PAGES examples still use Nuxt 3-era URLs (/docs/4.x/guide/directory-structure/composables, etc.). The nuxt.com site already redirects those URLs in the browser (nuxt.config.ts routeRules), but MCP resolves documentation via queryCollection(event, collection).path(path) and does not follow HTTP redirects.

This causes AI assistants to fail when they trust the MCP tool metadata or Nuxt 3 muscle memory, even though list_documentation_pages returns the correct paths.

Changes

  1. resolveDocumentationPath() in server/utils/mcp.ts — maps legacy guide/directory-structure/* paths to current content paths (mirroring existing route redirects; includes app/ segment for Nuxt 4+ app dirs).

  2. fetchPageMarkdown() — applies path resolution before every content lookup, so all MCP doc tools benefit.

  3. get-documentation-page.ts — updates COMMON PAGES, inputExamples, and guidance to Nuxt 4 canonical paths (/docs/4.x/directory-structure/app/*).

Reproduction (before fix)

get_documentation_page({ path: "/docs/4.x/guide/directory-structure/composables" })
→ 404 Documentation page not found

get_documentation_page({ path: "/docs/4.x/directory-structure/app/composables" })
→ ✅ returns content

list_documentation_pages({ version: "4.x", search: "composables" })
→ ✅ returns correct path (catalog was already fine)

Also broken in tool metadata:

  • /docs/4.x/guide/going-further/error-handling → should be /docs/4.x/getting-started/error-handling

Test plan

  • get_documentation_page with legacy path /docs/4.x/guide/directory-structure/composables returns composables doc
  • get_documentation_page with canonical path /docs/4.x/directory-structure/app/composables still works
  • get_documentation_page with /docs/4.x/guide/going-further/error-handling resolves to getting-started error-handling page
  • MCP tool description lists Nuxt 4 directory-structure/app/* paths

Made with Cursor

The get_documentation_page MCP tool advertised Nuxt 3-era directory
structure URLs that 404 in queryCollection lookups. nuxt.com already
redirects those paths in the browser, but MCP fetches content by path
directly.

- Add resolveDocumentationPath() mirroring directory-structure redirects
- Apply resolution in fetchPageMarkdown for all MCP doc fetches
- Update COMMON PAGES and inputExamples to Nuxt 4 paths

Co-authored-by: Cursor <cursoragent@cursor.com>
@santiagodeheza santiagodeheza requested a review from atinux as a code owner June 8, 2026 02:05
@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@santiagodeheza is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c3260eb2-d6c3-4881-afa5-82f4a4225991

📥 Commits

Reviewing files that changed from the base of the PR and between fb56a35 and 4c1ba17.

📒 Files selected for processing (1)
  • server/utils/mcp.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/utils/mcp.ts

📝 Walkthrough

Walkthrough

This PR adds a documentation path resolver to the MCP tools service. A new resolveDocumentationPath() function translates legacy Nuxt documentation URLs (those using /guide/directory-structure patterns) to their current equivalents under directory-structure/app/ and related paths. The resolver is integrated into fetchPageMarkdown to normalize incoming paths before content lookup. The MCP tool configuration is updated to reflect these path changes in its description and input examples.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: fixing legacy documentation path resolution and updating tool examples in the MCP server.
Description check ✅ Passed The description is thorough and directly related to the changeset, clearly explaining the problem, root cause, solution, and providing reproduction steps.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/utils/mcp.ts`:
- Around line 34-37: The variable `resolved` in the `server/utils/mcp.ts`
snippet is never reassigned, so change its declaration from `let resolved =
path.replace(...)` to use `const resolved = path.replace(...)` to satisfy lint
rules and reflect intent; locate the `resolved` assignment that applies the
regex /^(... )\/guide\/directory-structure$/ and update the `let` to `const`
there.
- Around line 56-59: The current branch that checks topLevel from rest and
APP_SCOPED_DIRECTORIES builds `${prefix}/directory-structure/app/${rest}` which
produces `.../app/app` when rest === 'app'; change the logic in that branch (the
block using topLevel, APP_SCOPED_DIRECTORIES, rest and prefix) to special-case
rest === 'app' and return `${prefix}/directory-structure/app` for that case,
otherwise return `${prefix}/directory-structure/app/${rest}` so you don't
duplicate "app".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c4f483ab-2aa4-4d59-b837-e77564ff6081

📥 Commits

Reviewing files that changed from the base of the PR and between 452d2b1 and fb56a35.

📒 Files selected for processing (2)
  • server/mcp/tools/docs/get-documentation-page.ts
  • server/utils/mcp.ts

Comment thread server/utils/mcp.ts Outdated
Comment thread server/utils/mcp.ts
@santiagodeheza

Copy link
Copy Markdown
Author

Hey @atinux , just making sure this doesnt get buried.
tiny fix, just some stale paths in the MCP resulting in 404s. @HugoRCD already approved.

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