Calls a tool registered by the frame and returns its result. The result is whatever the tool's execute function
resolved to, typically an object with a content array. A result with isError: true is returned as is. The
method throws when the tool is not registered or its execute function throws.
const result = await page.webmcp.callTool('add', { a: 2, b: 40 });
console.log(result.content[0].text); // "42"
Name of the tool, as reported by webMCP.tools([options]).
Optional input: anyInput for the tool, matching its inputSchema. Defaults to an empty object.
Optional options: { Optional timeout?: numberMaximum time in milliseconds. Defaults to 0 - no timeout. The default value can be changed via actionTimeout
option in the config, or by using the
browserContext.setDefaultTimeout(timeout)
or page.setDefaultTimeout(timeout) methods.
Returns the tools currently registered by the frame. Throws if the browser was launched without WebMCP support, see the note above for the launch options that enable it.
page.webmcp covers the main frame only, child frames list their tools through their own frame.webmcp.
Optional options: { Optional timeout?: numberMaximum time in milliseconds. Defaults to 0 - no timeout. The default value can be changed via actionTimeout
option in the config, or by using the
browserContext.setDefaultTimeout(timeout)
or page.setDefaultTimeout(timeout) methods.
WebMCP exposes the tools that a frame registers through the experimental WebMCP browser API,
navigator.modelContext. It lists the tools and calls them.Instances are accessed through frame.webmcp. page.webmcp is the instance of the main frame.
NOTE WebMCP is an experimental browser feature. Chromium enables it with the
--enable-features=WebMCPlaunch argument, Firefox with thedom.modelcontext.enabledanddom.modelcontext.testing.enabledpreferences. WebKit does not implement it.Tool names, descriptions, input schemas and results are provided by the page, so treat them as untrusted input.