GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Playwright for Java
  • Docs
  • API
  • Java
  • Node.js
  • Python
  • .NET
  • Community
  • Classes
  • APIRequestContext
  • APIResponse
  • Browser
  • BrowserContext
  • BrowserType

This view

  • Original page
  • New address

GeezerVison is showing playwright.dev — WebMCP | Playwright Java

This is unreleased documentation for Playwright Java Next version.
For up-to-date documentation, see the latest version (stable).
Version: Next

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=WebMCP launch argument, Firefox with the dom.modelcontext.enabled and dom.modelcontext.testing.enabled preferences. WebKit does not implement it.

Tool names, descriptions, input schemas and results are provided by the page, so treat them as untrusted input.


Methods​

callTool​

Added in: v1.64 webMCP.callTool

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.

Usage

WebMCP.callTool(name);
WebMCP.callTool(name, input, options);

Arguments

  • name String#

    Name of the tool, as reported by WebMCP.tools().

  • input Object (optional)#

    Input for the tool, matching its inputSchema. Defaults to an empty object.

  • options WebMCP.CallToolOptions (optional)

    • setTimeout double (optional)#

      Maximum time in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. The default value can be changed by using the BrowserContext.setDefaultTimeout() or Page.setDefaultTimeout() methods.

Returns

  • Object#

tools​

Added in: v1.64 webMCP.tools

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().

Usage

WebMCP.tools();
WebMCP.tools(options);

Arguments

  • options WebMCP.ToolsOptions (optional)
    • setTimeout double (optional)#

      Maximum time in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. The default value can be changed by using the BrowserContext.setDefaultTimeout() or Page.setDefaultTimeout() methods.

Returns

  • List<Tools>#
    • name String

      Tool name, unique within the frame.

    • description String

      Tool description.

    • inputSchema Object (optional)

      JSON Schema of the tool input, when the page provides one.

    • annotations Annotations (optional)

      • readOnly boolean (optional)

        The tool does not modify any state.

      • untrustedContent boolean (optional)

        The tool output may contain third-party content.

      • consequential boolean (optional)

        The tool takes a consequential action, such as placing an order.

      Hints the page provides about the tool.

  • Methods
    • callTool
    • tools
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.