Repository navigation
Make the WebMCP polyfill internal - #834
Merged
Merged
Conversation
installWebMcpPolyfill was exported from the SDK's main entry point as a convenience for WebMCP-authored views running where neither the browser nor the host provides document.modelContext. Such views should bring their own polyfill instead: the SDK's copy exists to back its own tests of the WebMCP -> Apps bridge, and keeping it public would commit the SDK to maintaining a faithful WebMCP implementation. - Remove the re-export from src/app.ts (the export never shipped in a release; it was added after v2.0.4) - Import it directly from ./webmcp-polyfill.js in the interop test - Mark the function @internal and reword the module header - Reword the draft spec's bridging paragraph to match Co-authored-by: ochafik <ochafik@anthropic.com>
Contributor
PreviewPreview deployments for this PR have been cleaned up. |
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
Removes
installWebMcpPolyfillfrom the public API before it ships in a release (it was added after v2.0.4 and has never been published).The function is a minimal, realm-local
document.modelContextpolyfill. It was exported as a convenience for WebMCP-authored views running where neither the browser nor the host provides a model context — but the SDK's own WebMCP bridge needs no polyfill (both directions no-op gracefully without a model context), so the export only served third-party WebMCP authoring. Keeping it public would commit the SDK to maintaining a faithful WebMCP implementation as that draft spec evolves. WebMCP-authored views should bring their own polyfill instead.src/app.ts: drop the re-export (the module's sole public entry).src/app-webmcp-interop.test.ts: import it directly from./webmcp-polyfill.js— the module stays as a test helper backing the WebMCP → Apps bridge tests.src/webmcp-polyfill.ts/src/webmcp.ts: mark the function@internal, reword docs to match.specification/draft/apps.mdx: the bridging paragraph now says a view "can install a polyfill of its own" rather than naming an SDK export.No wire or behavior changes: the WebMCP bridge (
webMcpBridgeoption, mirroring, bridging) is untouched.Test plan
bun teston the interop suite: 8/8 pass with the test importing the polyfill directly.tsc --noEmitclean;typedoc --treatValidationWarningsAsErrorsexits 0 (no dangling{@link}after removing the references).npm run build, then greppeddist/: the symbol is gone from all shipped bundles and fromapp.d.ts; only the module's own (unreachable via theexportsmap) declaration file remains, matching the existing pattern for test-only modules.Generated by Claude Code