Skip to content

Make the WebMCP polyfill internal - #834

Merged
ochafik merged 1 commit into
mainfrom
webmcp-polyfill-internal
Oct 27, 2026
Merged

ochafik merged 1 commit into
mainfrom
webmcp-polyfill-internal

Conversation

@ochafik

@ochafik ochafik commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes installWebMcpPolyfill from 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.modelContext polyfill. 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 (webMcpBridge option, mirroring, bridging) is untouched.

Test plan

  • bun test on the interop suite: 8/8 pass with the test importing the polyfill directly.
  • tsc --noEmit clean; typedoc --treatValidationWarningsAsErrors exits 0 (no dangling {@link} after removing the references).
  • Full npm run build, then grepped dist/: the symbol is gone from all shipped bundles and from app.d.ts; only the module's own (unreachable via the exports map) declaration file remains, matching the existing pattern for test-only modules.
  • Repo-wide grep: no example, doc, or plugin references the export.

Generated by Claude Code

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>
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Preview

Preview deployments for this PR have been cleaned up.

@ochafik
ochafik merged commit f89e08a into main Oct 27, 2026
22 checks passed
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.

1 participant