Skip to main content
Glama

playwright_expect_response

Initiate a wait operation for an HTTP response matching a specified URL pattern without completing the wait. Use this tool to prepare response assertions in browser automation workflows.

Instructions

Ask Playwright to start waiting for a HTTP response. This tool initiates the wait operation but does not wait for its completion.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesUnique & arbitrary identifier to be used for retrieving this response later with `Playwright_assert_response`.
urlYesURL pattern to match in the response.

Implementation Reference

  • The main handler function for the 'playwright_expect_response' tool. It sets up a Playwright page.waitForResponse promise for the given URL pattern and stores it in a global map using the provided ID.
    export class ExpectResponseTool extends BrowserToolBase { /** * Execute the expect response tool */ async execute(args: ExpectResponseArgs, context: ToolContext): Promise<ToolResponse> { return this.safeExecute(context, async (page) => { if (!args.id || !args.url) { return createErrorResponse("Missing required parameters: id and url must be provided"); } const responsePromise = page.waitForResponse(args.url); responsePromises.set(args.id, responsePromise); return createSuccessResponse(`Started waiting for response with ID ${args.id}`); }); } }
  • The input schema definition and tool metadata (name, description) for registration with the MCP server.
    { name: "playwright_expect_response", description: "Ask Playwright to start waiting for a HTTP response. This tool initiates the wait operation but does not wait for its completion.", inputSchema: { type: "object", properties: { id: { type: "string", description: "Unique & arbitrary identifier to be used for retrieving this response later with `Playwright_assert_response`." }, url: { type: "string", description: "URL pattern to match in the response." } }, required: ["id", "url"], }, },
  • The dispatch case in the main tool handler that routes calls to the ExpectResponseTool instance.
    case "playwright_expect_response": return await expectResponseTool.execute(args, context);
  • Instantiation of the ExpectResponseTool class instance used for handling tool calls.
    if (!expectResponseTool) expectResponseTool = new ExpectResponseTool(server);
  • Global map storing pending response promises keyed by ID, shared between expect and assert tools.
    const responsePromises = new Map<string, Promise<Response>>();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/executeautomation/mcp-playwright'

If you have feedback or need assistance with the MCP directory API, please join our Discord server