effect-playwright
    Preparing search index...

    Interface WebMCP

    Tools that a frame registers through the experimental WebMCP browser API.

    Gotchas

    WebMCP must be enabled when the browser launches. In Chromium, pass --enable-features=WebMCP; WebKit does not support it. Page.webmcp only covers the main frame, so child frames list their tools through their own Frame.webmcp.

    import { Effect } from "effect";
    import { Playwright } from "effect-playwright";
    import { chromium } from "playwright-core";

    const program = Effect.gen(function* () {
    const playwright = yield* Playwright.Playwright;
    const browser = yield* playwright.launchScoped(chromium, {
    args: ["--enable-features=WebMCP"],
    });
    const page = yield* browser.newPage();
    yield* page.goto("https://example.com");

    const tools = yield* page.webmcp.tools();
    const result = yield* page.webmcp.callTool("add", { a: 2, b: 40 });
    return { tools, result };
    }).pipe(Effect.scoped, Effect.provide(Playwright.layer));

    0.9.0

    interface WebMCP {
        callTool: (
            name: string,
            input?: unknown,
            options?: { timeout?: number },
        ) => Effect<unknown, PlaywrightError>;
        tools: (
            options?: { timeout?: number },
        ) => Effect<readonly WebMCPTool[], PlaywrightError>;
    }
    Index
    callTool: (
        name: string,
        input?: unknown,
        options?: { timeout?: number },
    ) => Effect<unknown, PlaywrightError>

    Calls a tool registered by the frame and returns its result.

    The result is whatever the tool's execute function resolved to. A result with isError: true succeeds as is; the effect fails when the tool is not registered or its execute function throws.

    0.9.0

    tools: (
        options?: { timeout?: number },
    ) => Effect<readonly WebMCPTool[], PlaywrightError>

    Returns the tools currently registered by the frame.

    Fails if the browser was launched without WebMCP support.

    0.9.0