Skip to content

Add executeTool() - #2

Merged
MiguelsPizza merged 1 commit into
alex/core-polyfillfrom
alex/execute-tool
Sep 17, 2026
Merged

MiguelsPizza merged 1 commit into
alex/core-polyfillfrom
alex/execute-tool

Conversation

@MiguelsPizza

@MiguelsPizza MiguelsPizza commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

WIP - currently having some AI's do reviews. Below is AI generated

this adds executeTool() on top of #1, following the draft algorithm: object input, JSON-serialized results, and cancellation that hands the callback its own fresh signal and a default AbortError while the caller gets its own reason back. The method is declared by a local augmentation that mirrors webmcp-types#3 exactly, including ModelContextExecuteToolOptions, so removing it once that ships is a straight deletion.

The execution tests are their own file, so this PR is mostly one new file rather than hunks spliced through the registration tests.

100 browser tests and the package checks pass. WPT is at 51 passing assertions including all 22 IDL checks, with five expected failures recorded per assertion in wpt-metadata. The pin is the WPT export of the Chromium CL for #246 and #251 and it rewrote all four of those files, so these aren't stale tests waiting on an update: the draft's input and result rules haven't moved since #251 merged. Four of the five call executeTool() with no input, which the draft rejects with a TypeError before it looks the tool up; object-arguments wants an unquoted "Success" back from a callback whose result the draft JSON-serializes. Unexpected passes fail the run too, so these can't quietly go green. Details in TESTING.md.

One thing I'd like your read on: a tool.window from another document rejects with UnknownError, matching step 16.1, rather than NotSupportedError as I originally had it. Extension integration is #3.

@MiguelsPizza
MiguelsPizza force-pushed the alex/core-polyfill branch 2 times, most recently from bea387f to 1be0c1f Compare September 14, 2026 15:30
@MiguelsPizza
MiguelsPizza force-pushed the alex/execute-tool branch 2 times, most recently from 49e0a43 to a8d5c56 Compare September 14, 2026 15:50
@MiguelsPizza
MiguelsPizza force-pushed the alex/execute-tool branch 2 times, most recently from ad06f90 to f757b99 Compare September 14, 2026 21:48
@MiguelsPizza
MiguelsPizza force-pushed the alex/core-polyfill branch 2 times, most recently from 34da5b6 to 855027d Compare September 15, 2026 16:38
Implement executeTool() against the current draft: object input, JSON-serialized results, and abort handling that gives the callback its own signal and a default AbortError while the caller receives its own reason. Extend the WPT selection from 13 files to 18, and from 27 assertions to 56, now that the interface is complete enough for the IDL harness.

Record as per-subtest expected failures in wpt-metadata the four upstream files that disagree with the draft on omitted input and on result serialization, rather than patching tests or relaxing the implementation. Carry a temporary ModelContext augmentation mirroring webmcp-types#3 until that ships.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MiguelsPizza added a commit that referenced this pull request Sep 17, 2026
Use released webmcp-types 0.1.8 and remove the temporary executeTool
augmentation. Shorten comments and test setup while preserving Web IDL
conversion, cancellation, and native-installation behavior.

Run every pinned WebMCP testharness file with standard WPT expectations
instead of a selected list. Record failures, timeouts, and blocked subtests
separately so the supported scope is visible. Apply the review's fixture,
header, and Chrome flag corrections.

Validate blob URLs using their inherited origin; a browser regression
demonstrates the former SecurityError for trustworthy blob origins.

Validated with pnpm test (100 browser tests), pnpm test:package, and
pnpm test:wpt (58 files; all results match their explicit expectations).

References:
#1
#2
https://github.com/webmachinelearning/webmcp-types/releases/tag/v0.1.8
https://url.spec.whatwg.org/#concept-url-origin
@MiguelsPizza
MiguelsPizza merged commit 0cb2b89 into alex/core-polyfill Sep 17, 2026
2 checks passed
MiguelsPizza added a commit that referenced this pull request Sep 23, 2026
Provide document.modelContext in browsers without native WebMCP, using the
released webmcp-types declarations and preserving existing native contexts.
Support explicit installation and the webmcp-polyfill/auto entry point.

Implement registration, discovery, object-input execution, JSON snapshots,
cancellation, and toolchange notifications. Participating frames exchange
requests through MessagePorts with source, origin, exposure, and inherited
permission checks. Keep page-author callbacks and listeners outside protocol
timeouts, and report malformed discovery replies without breaking discovery.

Run browser and packed-consumer checks plus every pinned WebMCP testharness
file. Add Chrome and Firefox WPT CI with explicit Linux browser dependencies;
record actual Safari results and platform limitations separately. Declarative
tools and lifecycle events remain unimplemented.

Validation: 226 browser tests and packed-consumer checks pass. WPT covers
67 files and 161 subtests with zero unexpected results: Chrome/Firefox have
96 PASS, 23 expected FAIL, 24 TIMEOUT, and 18 NOTRUN; Safari has 92 PASS and
27 expected FAIL with the same TIMEOUT/NOTRUN counts. All 22 pinned IDL
subtests pass. The Firefox WPT test command also passes in Linux under act.

References:
https://webmachinelearning.github.io/webmcp/
https://github.com/webmachinelearning/webmcp-types
#2
web-platform-tests/wpt@2699eaa
MiguelsPizza added a commit that referenced this pull request Sep 23, 2026
Provide document.modelContext in browsers without native WebMCP, using the
released webmcp-types declarations and preserving existing native contexts.
Support explicit installation and the webmcp-polyfill/auto entry point.

Implement registration, discovery, object-input execution, JSON snapshots,
cancellation, and toolchange notifications. Participating frames exchange
requests through MessagePorts with source, origin, exposure, and inherited
permission checks. Keep page-author callbacks and listeners outside protocol
timeouts, and report malformed discovery replies without breaking discovery.

Run browser and packed-consumer checks plus every pinned WebMCP testharness
file. Add Chrome and Firefox WPT CI with explicit Linux browser dependencies;
record actual Safari results and platform limitations separately. Declarative
tools and lifecycle events remain unimplemented.

Validation: 226 browser tests and packed-consumer checks pass. WPT covers
67 files and 161 subtests with zero unexpected results: Chrome/Firefox have
96 PASS, 23 expected FAIL, 24 TIMEOUT, and 18 NOTRUN; Safari has 92 PASS and
27 expected FAIL with the same TIMEOUT/NOTRUN counts. All 22 pinned IDL
subtests pass. The Firefox WPT test command also passes in Linux under act.

References:
https://webmachinelearning.github.io/webmcp/
https://github.com/webmachinelearning/webmcp-types
#2
web-platform-tests/wpt@2699eaa

Co-authored-by: François Beaufort <beaufort.francois@gmail.com>
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