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.disable

Disables the WebMCP domain.

WebMCP.cancelInvocation

Cancels a pending tool invocation. The tool's AbortSignal is fired, and a
toolResponded event with status Error will be emitted for the invocationId.

Parameters
Name Type Description
invocationId string The invocation ID returned by invokeTool.

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.

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 starts.

Parameters
Name Type Description
toolName string Name of the tool to invoke.
frameId Page.FrameId Frame id
invocationId string Invocation identifier.
input string The input parameters used for the invocation.

WebMCP.toolResponded

Event fired when a tool invocation completes or fails.

Parameters
Name Type Description
invocationId string Invocation identifier.
status InvocationStatus Status of the invocation.
output (optional) any Output or error delivered as delivered to the agent. Missing if `status` is anything other than Success.
errorText (optional) string Error text for protocol users.
exception (optional) Runtime.RemoteObject The exception object, if the javascript tool threw an 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.

InvocationStatus

(string)

Represents the status of a tool invocation.

Allowed Values
  • Success
  • Canceled
  • Error

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.

Summary