WebMCP

Experimental

Dependencies: Runtime, Page, DOM

Commands

WebMCP.enable

Enables the WebMCP domain, allowing events to be sent. Enabling the domain will trigger a toolsAdded event for
all currently registered tools.

WebMCP.invokeTool

Invokes a tool by name with JSON-encoded input arguments.
Returns an invocationId; the result arrives asynchronously via toolResponded event.

Parameters
Name Type Description
toolName string Name of the tool to invoke.
frameId Page.FrameId Frame identifier where the tool is registered.
input (optional) object JSON-encoded input arguments for the tool (parsed and passed to the execute callback).
Return Object
Name Type Description
invocationId string Unique ID for this invocation, used to correlate with toolResponded.

WebMCP.callTool

Invokes a tool by name with the given JSON arguments (synchronous convenience).

Parameters
Name Type Description
name string Name of the tool to invoke.
arguments (optional) string JSON-encoded input arguments for the tool.
Return Object
Name Type Description
success boolean Whether the tool executed successfully.
result (optional) string JSON-encoded result from the tool, if any.
errorMessage (optional) string Error message if the tool failed.

Events

WebMCP.toolsAdded

Event fired when new tools are added.

Parameters
Name Type Description
tools array<Tool> Array of tools that were added.

WebMCP.toolsRemoved

Event fired when tools are removed.

Parameters
Name Type Description
tools array<Tool> Array of tools that were removed.

WebMCP.toolInvoked

Event fired when a tool invocation has been started (the execute callback is running).

Parameters
Name Type Description
invocationId string The invocation ID returned by invokeTool.
toolName string Name of the tool being invoked.

WebMCP.toolResponded

Event fired when a tool invocation has completed (successfully or with error).

Parameters
Name Type Description
invocationId string The invocation ID returned by invokeTool.
status InvocationStatus Status of the invocation.
output (optional) string The tool's return value (JSON-encoded), present when status is "completed".
errorText (optional) string Error text, present when status is "error".

Types

Annotation

(object)

Tool annotations

Properties
Name Type Description
readOnly (optional) boolean A hint indicating that the tool does not modify any state.
autosubmit (optional) boolean If the declarative tool was declared with the autosubmit attribute.

Tool

(object)

Definition of a tool that can be invoked.

Properties
Name Type Description
name string Tool name.
description string Tool description.
inputSchema (optional) object Schema for the tool's input parameters.
annotations (optional) Annotation Optional annotations for the tool.
frameId Page.FrameId Frame identifier associated with the tool registration.
backendNodeId (optional) DOM.BackendNodeId Optional node ID for declarative tools.
stackTrace (optional) Runtime.StackTrace The stack trace at the time of the registration.

InvocationStatus

(string)

Status of a tool invocation.

Allowed Values
  • completed
  • error

Summary