Readonly[Optional ReadonlyprefixReadonlytoolCloses the toolset.
NOTE: This method is invoked, for example, at the end of an agent server's lifecycle or when the toolset is no longer needed. Implementations should ensure that any open connections, files, or other managed resources are properly released to prevent leaks.
A Promise that resolves when the toolset is closed.
Returns the tools that should be exposed to LLM.
Optionalcontext: ReadonlyContextContext used to filter tools available to the agent. If not defined, all tools in the toolset are returned.
A Promise that resolves to the list of tools.
Whether this document exposes WebMCP.
ProtectedisReturns whether the tool should be exposed to LLM.
The tool to check.
Context used to filter tools available to the agent.
Whether the tool should be exposed to LLM.
Subscribes to the WebMCP toolchange event, which fires when the page
registers or removes tools. Returns an unsubscribe function.
Processes the outgoing LLM request for this toolset. This method will be called before each tool processes the llm request.
Use cases:
The context of the tool.
The outgoing LLM request, mutable this method.
A toolset backed by the tools a web page registers with WebMCP.
WebMCP lets a page declare typed, callable tools on
document.modelContext. This toolset surfaces them to an in-browser agent, so the agent drives the page through the handlers it published instead of scraping the DOM. Each tool's ownexecuteruns in the page, so its UI updates as a side effect.Unlike MCPToolset, nothing is transported anywhere: discovery and execution are same-document browser calls.
Outside a browser, or in a browser without WebMCP,
getTools()returns an empty array rather than throwing, so this is safe to construct anywhere.Example
See
https://developer.chrome.com/docs/ai/webmcp