Repository navigation
Conversation
Keep App.registerTool and the tools/list / tools/call channel as they are, and make the two tool surfaces interoperable: - Tools registered with App.registerTool are mirrored into document.modelContext when the document provides one, so WebMCP-enabled hosts discover them without speaking the Apps tools channel. - Tools the page registers on document.modelContext are served over tools/list / tools/call (declaring the tools capability when the page carries WebMCP tools at connect time), with toolchange relayed as notifications/tools/list_changed, so WebMCP-authored views work on MCP Apps hosts. - installWebMcpPolyfill() gives WebMCP-authored views a drop-in document.modelContext where neither the browser nor the host provides one. Registered tools shadow same-named WebMCP entries, which also keeps a tool's own mirror from being listed twice; only the frame's own tools are served. Both behaviors can be switched off per App (mirrorToolsToWebMcp / bridgeWebMcpTools).
@modelcontextprotocol/ext-apps
@modelcontextprotocol/server-basic-preact
@modelcontextprotocol/server-basic-react
@modelcontextprotocol/server-basic-solid
@modelcontextprotocol/server-basic-svelte
@modelcontextprotocol/server-basic-vanillajs
@modelcontextprotocol/server-basic-vue
@modelcontextprotocol/server-budget-allocator
@modelcontextprotocol/server-cohort-heatmap
@modelcontextprotocol/server-customer-segmentation
@modelcontextprotocol/server-debug
@modelcontextprotocol/server-lazy-auth
@modelcontextprotocol/server-map
@modelcontextprotocol/server-pdf
@modelcontextprotocol/server-scenario-modeler
@modelcontextprotocol/server-shadertoy
@modelcontextprotocol/server-sheet-music
@modelcontextprotocol/server-system-monitor
@modelcontextprotocol/server-threejs
@modelcontextprotocol/server-transcript
@modelcontextprotocol/server-video-resource
@modelcontextprotocol/server-wiki-explorer
commit: |
Contributor
Author
|
superseded by #829 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Middle-ground counterpart to #798, along the lines of Option 3 in #797 and of #796: instead of deprecating
App.registerToolin favor of WebMCP, keep both tool surfaces first-class and have the SDK bridge them in both directions.App.registerTool()are mirrored intodocument.modelContextwhen the document provides one, so a WebMCP-enabled host (one that consumesdocument.modelContext, e.g. natively) sees them without speaking the Appstools/listchannel. The wire path is untouched; mirroring is additive.document.modelContextare served over the existingtools/list/tools/calliframe channel — the SDK declares thetoolscapability on the View's behalf when the page carries WebMCP tools at connect time, and relaystoolchangeasnotifications/tools/list_changed.installWebMcpPolyfill()is the explore: add a thin bridge between WebMCP and MCP Apps Tools #796 "drop-in" for WebMCP-authored views that must also run where neither the browser nor the host providesdocument.modelContext.No new wire messages, no host-side API changes, no deprecations: hosts keep
bridge.listTools()/callTool(), views keepregisterTool(), and a WebMCP-only host like the ones #797 anticipates readsdocument.modelContextas it would on any page. Dedup rules: registered tools shadow same-named WebMCP entries (which also keeps a tool's own mirror from being echoed back), only the frame's own tools are served, and the spec text says a host able to discover a view's tools both ways consumes exactly one surface per view. Both behaviors are per-App opt-outs (mirrorToolsToWebMcp/bridgeWebMcpTools).Spec: the informative "Relation to WebMCP" section becomes a normative "WebMCP Interoperability" section with the WebMCP ↔ MCP mapping table (same shapes as #798: results as
{content: [], structuredContent}, non-object values wrapped as{result: v}, thrown errors asisError: true).Like #798, this is meant to make the option concrete for discussion, not to merge as-is — but unlike #798 it is non-breaking, so it would not need a major release.
Test plan
bun test srcpasses (253, including 8 new interop tests driving a realServer↔Apppair overInMemoryTransportwith the SDK polyfill as the model context);tsc --noEmitandtypedoc --treatValidationWarningsAsErrorsare clean. Not verified: native WebMCP (Chrome), real third-party hosts, the browser e2e suite.Known limits / open questions
tool.update()aborts-then-registers; an implementation whose signal-triggered unregistration is asynchronous could reject the re-registration as a duplicate (works with the SDK polyfill; same pattern as Prototype WebMCP for View-exposed tools, to illustrate #797 #798).connect()is picked up for mirroring at the next reconnect or tool mutation, but thetoolscapability cannot be declared retroactively — WebMCP tools registered late on a page that had none at connect time are not served (capability is fixed atui/initialize).toolchangefired by the App's own mirror registrations currently produces an extranotifications/tools/list_changedbeside the oneregisterTool()/enable()/… already send.toolsPermissions Policy delegated (feat: add support for 'tools' permission #691); where it is not, mirroring fails gracefully andtools/listremains the fallback.cc @liady @idosal
Generated by Claude Code