ADK for TypeScript: API Reference
    Preparing search index...

    Class WebMCPToolset

    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 own execute runs 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.

    import {LlmAgent} from '@google/adk';
    import {WebMCPToolset} from '@google/adk/tools/webmcp';

    const agent = new LlmAgent({
    name: 'page_agent',
    model: 'gemini-3.8-live',
    tools: [new WebMCPToolset()],
    });

    Hierarchy (View Summary)

    Constructors

    Properties

    "[BASE_TOOLSET_SIGNATURE_SYMBOL]": true
    prefix?: string
    toolFilter: string[] | ToolPredicate

    Methods

    • Closes 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.

      Returns Promise<void>

      A Promise that resolves when the toolset is closed.

    • Subscribes to the WebMCP toolchange event, which fires when the page registers or removes tools. Returns an unsubscribe function.

      Parameters

      • listener: () => void

      Returns () => void

    • Processes the outgoing LLM request for this toolset. This method will be called before each tool processes the llm request.

      Use cases:

      • Instead of let each tool process the llm request, we can let the toolset process the llm request. e.g. ComputerUseToolset can add computer use tool to the llm request.

      Parameters

      • _toolContext: Context

        The context of the tool.

      • _llmRequest: LlmRequest

        The outgoing LLM request, mutable this method.

      Returns Promise<void>