fix(webmcp): handle the breaking change to tool registration identity
Why
A website can replace a tool and give the new tool the same name. If Stagehand calls a tool it found earlier using only that name, it can accidentally run the replacement. Chrome now gives each registration its own ID. WebMCP PR #348
What
Stagehand uses that ID in TypeScript and Python to call the exact tool it found. If the website has removed it, the call fails. Older Chrome versions still look up tools by name.
How
Verified on Chrome 158 and Chrome Dev 160 with both SDKs. On the WebMCP groceries demo, save the get_stores handle, navigate away, then return. On Chrome Dev 160, the saved handle should fail and a freshly discovered handle should return the stores.
Summary by cubic
Keeps saved WebMCP tool handles pointing at their original registration so a page that reuses a tool name can't redirect a previously discovered handle to a replacement tool. Chrome now assigns every registration a toolId; Stagehand passes it through in TypeScript and Python when Chrome supports it, and falls back to name-based lookup on older versions.
- Adds optional
toolIdto tool descriptors, identities, and the protocol. - Invokes tools by
toolIdwhen available; old handles now fail cleanly if the registration was removed. - Emits a removal event when a registration is superseded by a same-named replacement.
- Legacy clients can opt out of
toolIdin discovery and event payloads. - Bumps
devtools-protocolto pick up the new WebMCP definitions.