Repository navigation
[MCP] Update WebMCP registration API - #3844
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates WebMCP tool registration to use Chrome’s current document.modelContext API and to handle asynchronous registerTool() without allowing failures to break the Playground experience.
Changes:
- Switched WebMCP registration from
navigator.modelContexttodocument.modelContext. - Made
registerWebMCPTools()async and awaited tool registration. - Updated website/personal-wp initialization, e2e mock, and README to align with the new API.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/playground/website/src/lib/state/redux/init-mcp-bridge.ts | Awaits WebMCP registration and logs failures without crashing the site. |
| packages/playground/personal-wp/src/lib/state/redux/init-mcp-bridge.ts | Same async-safe WebMCP registration pattern for personal-wp. |
| packages/playground/mcp/tests/e2e/webmcp.spec.ts | Updates e2e mock to provide document.modelContext and async registerTool(). |
| packages/playground/mcp/src/webmcp.ts | Migrates registration to document.modelContext and supports async registration. |
| packages/playground/mcp/README.md | Documentation updated to reference document.modelContext. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7e71cee to
47ab963
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughWebMCP now uses ChangesWebMCP registration
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change updates WebMCP registration and preserves website behavior when registration is unavailable or fails; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant ReduxMCPBridge
participant registerWebMCPTools
participant documentModelContext
participant WebMCPTools
ReduxMCPBridge->>registerWebMCPTools: start registration
registerWebMCPTools->>documentModelContext: read document.modelContext
registerWebMCPTools->>WebMCPTools: register tools concurrently
WebMCPTools-->>registerWebMCPTools: resolve or reject registrations
registerWebMCPTools-->>ReduxMCPBridge: resolve or reject with aggregated error
ReduxMCPBridge->>ReduxMCPBridge: log rejected registration with logger.warn
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Co-authored-by: Fellyph Cintra <fellyph.cintra@gmail.com>
Summary
Updates WebMCP tool registration to use the current
document.modelContextAPI and handle asynchronous tool registration without breaking the Playground website.Motivation for the change, related issues
Chrome's WebMCP API has moved away from
navigator.modelContext; the Chrome WebMCP Imperative API documentation notes thatnavigator.modelContextis deprecated in Chrome 150 and recommendsdocument.modelContextinstead.The
registerTool()API is also asynchronous in newer Chrome builds, so registration failures need to be caught from the returned Promise. WebMCP is still a progressive enhancement, so failed or unavailable WebMCP registration should not break the website.Implementation details
document.modelContextonly.registerWebMCPTools()return a Promise and await allregisterTool()calls.document.modelContext.Testing Instructions
git diff --check.node_modulesis missing. The commit hook also attemptednx format --fix --parallel --uncommittedand reported that Nx modules could not be found.Summary by CodeRabbit
document.modelContextAPI.