Skip to content

1.1.0: execution AbortSignals + document.modelContext consumer API - #54

Merged
kashishhora merged 9 commits into
mainfrom
feat/execution-signals-and-consumer-api
Sep 3, 2026
Merged

1.1.0: execution AbortSignals + document.modelContext consumer API#54
kashishhora merged 9 commits into
mainfrom
feat/execution-signals-and-consumer-api

Conversation

@kashishhora

@kashishhora kashishhora commented Sep 3, 2026

Copy link
Copy Markdown
Member

What changed

Built on #53 (the 1.0.0 release, now merged) — this is the 1.1.0 delta on top of it.

Chrome's WebMCP implementation moved in three steps (per the Chrome WebMCP team's EPP announcements, checked against Chromium source):

  1. 152.0.7940.0 removed navigator.modelContextTesting. The consumer API is document.modelContext.getTools() / executeTool() (shipping since 150.0.7861.0).
  2. 153.0.8007.0 calls a tool's execute as execute(input, { signal })webmcp issue #48, spec PR #247. From 153.0.8008.0, unregistering a tool no longer cancels its in-flight executions (issue #218).
  3. 154.0.8014.0 changed RegisteredTool.inputSchema from a JSON string to an object (spec PR #241).

Library

  • src/types.tsToolDescriptor.execute and the config handler take (input, { signal }). New ToolExecuteCallbackOptions, ExecuteToolOptions, RegisteredTool (inputSchema: InputSchema | string, since 153 and 154 differ), ModelContextGetToolOptions; ModelContext gains optional getTools/executeTool. One-argument handlers still type-check.
  • src/hooks/useMcpTool.ts — the direct execute() path and the registered descriptor now share one runHandler. Handlers always receive a real AbortSignal; on Chrome <=152 (which passes no options) a never-aborting one is substituted. When an aborted execution's handler rejects it's treated as cancellation: isExecuting clears, state.error and onError are left alone. execute(input?, { signal }?) accepts a caller signal.
  • src/polyfill/execute.ts (new) — one execution engine behind both executeTool and the shim: per-execution AbortController, a caller abort rejects with signal.reason while the tool-side signal aborts with a generic AbortError (what 153 does), late settlement after abort is ignored, tool failures reject UnknownError, results serialize the way native does. Input is still validated against inputSchema (OperationError); native doesn't validate yet (issue #92).
  • src/polyfill/index.tsdocument.modelContext.getTools() / executeTool() on the polyfill: fresh sorted objects, deep-copied object inputSchema (the 154 shape), fromOrigins validation, UnknownError for a stale tool. In-flight executions survive unregistration.
  • src/polyfill/testing-shim.ts — now a thin wrapper over the engine that warns once that navigator.modelContextTesting is deprecated (removal planned for 2.0.0). Keeps its historical NotFoundError/OperationError input errors.
  • Docs — README, docs/api.md (Cancellation section and a Chrome compat table), AGENTS.md, both skills, CHANGELOG. Version bump to 1.1.0.

Test plan

  • pnpm typecheck / pnpm lint (zero warnings) / pnpm build
  • pnpm test — 205 passing: both execution paths, cancellation semantics, engine abort races and serialization, consumer API, shim parity
  • Harness self-test against native Chrome 153+/154 Canary — only the polyfill has been exercised so far

The extension and examples migration is stacked on this branch in a follow-up PR.

@kashishhora
kashishhora force-pushed the feat/execution-signals-and-consumer-api branch 2 times, most recently from 07d2354 to 6698a81 Compare September 3, 2026 20:44
AGENTS.md still named navigator.modelContextTesting as the external-call path
in the architecture note and the Testing section, which would steer new tests
at a surface that is removed in 2.0.0. Name document.modelContext.getTools() /
executeTool() instead and mention the shim only as deprecated.

Drop the unused `{ signal }` destructure from the README quick start — it
trips noUnusedParameters for anyone copying the first snippet. The 1.1.0
section still shows the two-argument handler.
@kashishhora
kashishhora force-pushed the feat/execution-signals-and-consumer-api branch from 6698a81 to 0ee5484 Compare September 3, 2026 20:45
@kashishhora kashishhora changed the title 0.3.0: execution AbortSignals + document.modelContext consumer API 1.1.0: execution AbortSignals + document.modelContext consumer API Sep 3, 2026
@kashishhora
kashishhora merged commit 7c5feaf into main Sep 3, 2026
4 checks passed
@kashishhora
kashishhora deleted the feat/execution-signals-and-consumer-api 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