[feat]: add support for WebMCP tool invokation in iframes
Merged
SE
3mo ago+584+584+012345678901234567890123456789-69-69-01234567890123456789
why
before this PR, WebMCP tools registered inside of iframes were unable to be discovered or invoked
what changed
- changed WebMCP discovery to enable and collect tools from the page's main CDP session and every adopted OOPIF session
- routed invocation, response handling, & cancellation through the CDP session that owns the tool's frame
- stale tools are now rejected instead of falling back to the main frame, & only affected invocations are cleaned up when an OOPIF detaches
- added extension coverage for cross-session discovery, invocation, cancellation, response correlation, frame detachment, disposal, & lifecycle races
test plan
- Extension discovery tests cover combined main/OOPIF snapshots, child-session removals, stable session snapshots, next-call discovery after adoption, & listener cleanup after child enable failure.
- Extension invocation tests cover child-session invocation, response, cancellation, wrong-session events, targeted detach cleanup, detach during command setup, page disposal, duplicate invocation IDs, unknown frames, & failed-command listener cleanup.
- Browser integration coverage verifies distinct main/child CDP targets and sessions, successful iframe tool discovery and invocation, structured output, & stale-tool rejection after iframe removal.
Summary by cubic
WebMCP tools registered in out-of-process iframes (OOPIFs) are now discoverable and invokable; previously iframe tools were invisible and unusable. Invocation, response handling, and cancellation use the CDP session that owns the frame, while stale or detached frames fail instead of falling back to the main frame.
- Discovery enables WebMCP on the main session and adopted OOPIF sessions, then combines their snapshots.
- Detaching an OOPIF rejects only its pending invocations and removes its listeners.
- Added extension and SDK integration coverage for cross-session lifecycle, cleanup, and iframe removal.