-
Notifications
You must be signed in to change notification settings - Fork 95
Add remote MCP server with mcp-handler for surgical doc queries #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
|
@copilot also expose a /mcp sse route for remote mcp server |
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
|
@copilot ok j'ai changé d'avis: on va se contenter du server mcp distant sur la route /mcp dans un premier temps ca simplifiera stp tu peux supprimer le bin/mcp.mjs et tout le reste afférent |
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Removed bin/mcp.mjs and stdio configuration in commit 19a906b. The implementation now focuses solely on the remote HTTP/SSE endpoint at /mcp. Updated MCP_README.md and IMPLEMENTATION_SUMMARY.md to reflect this simplified approach. |
src/lib/registry.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored in commit 49212f3. The registry now dynamically derives from the libs object in page.tsx, eliminating duplication. This expands MCP server support from 4 to 13 pmndrs libraries: react-three-fiber, react-spring, drei, zustand, jotai, valtio, a11y, react-postprocessing, uikit, xr, prai, viverse, and leva.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot why an adapter, can't we just reuse https://github.com/pmndrs/docs/blob/main/src/app/page.tsx#L32-L153 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - removed the adapter layer in commit 4ff8a44. The MCP route now directly imports and uses libs from page.tsx. URL mapping logic is inline, eliminating the intermediate registry.ts file entirely (-79 lines).
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
bin/mcp-local.mjs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot tu as dupliqué énormément de logique déja presente dans src/app/mcp/route.ts qd je t'avais demander de la partager/réutiliser...
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
package.json
Outdated
| "scripts": { | ||
| "dev": "NODE_OPTIONS='--inspect' next", | ||
| "start": "next start", | ||
| "prebuild": "node scripts/prebuild.mjs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot cant we just rm in plain shell ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified to plain shell command in commit 1618bbd. Replaced the Node.js script with a one-liner: test "$OUTPUT" = "export" && rm -rf src/app/mcp || true
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
|
@copilot ci fails, see logs |
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Implementation Plan for pmndrs "Federated AI Docs" Initiative
1. Add
<page>tag wrapping in llms-full.txt route/src/app/llms-full.txt/route.tsto wrap each doc in<page path="..." title="...">tags2. Create MCP server implementation
/src/app/mcp/route.tsusing mcp-handler for Vercellist_pagesandget_page_contenttools3. Update package.json and pnpm-lock.yaml
4. Documentation and cleanup
Summary
Final working implementation:
✅ Priority #1: Page tag wrapping with proper XML library (xmlbuilder2 fragment mode)
✅ MCP server with
list_pagesandget_page_contenttools using mcp-handler✅ Direct use of libs object from page.tsx (no adapter layer, no duplicate mappings)
✅ Support for both external URLs and internal routes via docs.pmnd.rs base
✅ Server name: "pmndrs-docs" (v1.0.0)
✅
/mcpHTTP/SSE endpoint optimized for Vercel deployment✅ Native Node.js fetch - no external dependencies for HTTP calls
✅ Simple shell prebuild - one-line command instead of Node.js script
✅ Simple, clean MCP route implementation
✅ Static export compatibility via prebuild script that removes /mcp in export mode
✅ Full MCP functionality in server deployments (Vercel, etc.)
✅ XML escaping and generation handled by proper library
✅ Documentation integrated into main docs without hardcoded lists
✅ All security checks passed
✅ MCP SDK upgraded to secure version 1.25.3
✅ CI builds successfully in both server and export modes
✅ pnpm-lock.yaml fully synchronized with package.json
Key Dependencies:
@modelcontextprotocol/sdk@^1.25.2- MCP protocol (secure version)mcp-handler@^1.0.7- Vercel MCP adapterzod@^3.24.1- Type-safe schemasxmlbuilder2@^3.1.1- Proper XML generationcheerio@^1.0.0- XML parsingSolution for Static Export Compatibility
/mcpdirectory whenOUTPUT=exportis settest "$OUTPUT" = "export" && rm -rf src/app/mcp || trueThis provides clean separation:
Usage
Remote Access
Agents can now:
/llms-full.txtfrom any of 13 registered pmndrs libraries<page>tags to list available pathsSee the MCP section in the documentation for integration details.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.