Skip to content

Extension + examples: migrate to document.modelContext, forward cancellation end to end - #55

Merged
kashishhora merged 9 commits into
feat/execution-signals-and-consumer-apifrom
feat/extension-modelcontext-and-cancellation
Sep 3, 2026
Merged

Extension + examples: migrate to document.modelContext, forward cancellation end to end#55
kashishhora merged 9 commits into
feat/execution-signals-and-consumer-apifrom
feat/extension-modelcontext-and-cancellation

Conversation

@kashishhora

@kashishhora kashishhora commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

Stacked on #54. Moves the bridge extension and the examples off navigator.modelContextTesting (removed in Chrome 152.0.7940.0) and forwards MCP client cancellation all the way to the tool handler. Base is the 1.1.0 branch; GitHub will retarget to main once that merges.

  • extension/src/content-main.ts — a small adapter over document.modelContext.getTools() / executeTool() (native Chrome or the 1.1.0 polyfill), falling back to modelContextTesting for pages still on webmcp-react <=1.0.0. It re-detects the page object by identity: webmcp-react installs a fresh modelContext whenever its provider remounts, so a held reference would go stale. inputSchema is normalized to a JSON string on the wire whether Chrome hands back a string (<=153) or an object (154+).
  • Cancellation, end to end — MCP notifications/cancelled → SDK extra.signal → WebSocket CANCEL_TOOL → background → content scripts → executeTool(tool, args, { signal }). The 30s call timeout now sends CANCEL_TOOL too. Late results for a cancelled call are dropped at both the background and the server.
  • packages/webmcp-server/bin regenerated so the published server carries the cancel path.
  • examples/native-harness — the self-test drives getTools() / executeTool() and adds probes for string-vs-object inputSchema, the execution signal, a mid-flight abort, and unregister-during-execution.
  • examples/playground — DevPanel on the consumer API with a Cancel button, plus a slow_hint tool to try it on.
  • Extension README/PRIVACY and a CHANGELOG entry under Unreleased.

Test plan

  • pnpm typecheck:extension / pnpm build:extension — the committed bin rebuilds byte-identical
  • Playground and native-harness builds; library suite still 205 passing
  • DevPanel: cancel slow_hint mid-flight against the polyfill — the result row shows the abort, other tools keep working
  • Native Chrome Canary: harness self-test plus one extension list → execute → cancel round-trip. Not run yet — since native support is the point of this PR, I'd hold merge until it is.

@kashishhora
kashishhora force-pushed the feat/extension-modelcontext-and-cancellation branch from f6b059c to e527008 Compare September 3, 2026 19:06
@kashishhora
kashishhora force-pushed the feat/extension-modelcontext-and-cancellation branch from e527008 to 0af3f1a Compare September 3, 2026 20:44
…, verified Chrome build

- tool-registry: the 30 s call timeout now sends CANCEL_TOOL before resolving, so
  the page stops executing and the background's pending entry is released instead
  of lingering until a late result arrives.
- content-main: the 10 s discovery give-up falls through to the 1 s identity watch
  rather than stopping, so a provider that mounts late (code-split route, slow
  network) is still discovered. Exactly one watch is created on either branch.
- content-main: document why the TypeError retry cannot double-execute a tool.
- CHANGELOG / spec §4: cite the verified build for the native consumer API
  (150.0.7861.0+); spec §4 now describes the presence-poll + identity-watch loop
  the bridge actually runs, and §5 records native-Chrome verification as a merge
  requirement.
- Regenerated the tracked webmcp-server bin.
@kashishhora
kashishhora force-pushed the feat/extension-modelcontext-and-cancellation branch from 0af3f1a to 03cbff4 Compare September 3, 2026 20:45
@kashishhora
kashishhora merged commit cf55219 into main Sep 3, 2026
4 checks passed
@kashishhora
kashishhora deleted the feat/extension-modelcontext-and-cancellation branch September 3, 2026 21:04
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.

2 participants