Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

playwright_expect_response

Initiate waiting for HTTP responses in browser automation tests by specifying URL patterns and unique identifiers for later validation.

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

  • Implements the core execution logic for the 'playwright_expect_response' tool using Playwright's page.waitForResponse to start waiting for a HTTP response matching the URL pattern, storing the promise for later assertion.
    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}`);
        });
      }
    }
  • Defines the tool schema including name, description, input parameters (id and url), and validation requirements.
    {
      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"],
      },
    },
  • Registers the tool handler in the main tool dispatching switch statement, delegating execution to the ExpectResponseTool instance.
    case "playwright_expect_response":
      return await expectResponseTool.execute(args, context);
  • Instantiates the ExpectResponseTool class instance used for handling tool calls.
    if (!expectResponseTool) expectResponseTool = new ExpectResponseTool(server);
  • Generates equivalent Playwright test code for the tool action during codegen session recording.
    private generateExpectResponseStep(parameters: Record<string, unknown>): string {
      const { url, id } = parameters;
      return `
      // Wait for response
      const ${id}Response = page.waitForResponse('${url}');`;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool starts waiting without completion, which is a key behavioral trait, but lacks details on error handling, timeouts, or what happens if no response matches. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and front-loaded, consisting of two sentences that directly state the purpose and a key behavioral note. Every sentence earns its place without redundancy, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (initiating a wait for HTTP responses) and lack of annotations or output schema, the description is minimally adequate. It covers the basic purpose and a behavioral hint but does not address potential errors, dependencies on other tools, or return values, leaving room for more completeness in this context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, providing clear details for both parameters ('id' and 'url'). The description does not add any meaning beyond the schema, such as explaining parameter interactions or usage examples. With high schema coverage, a baseline score of 3 is appropriate as the schema handles the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Ask Playwright to start waiting for a HTTP response.' It specifies the action ('start waiting') and resource ('HTTP response'), but does not explicitly differentiate it from sibling tools like 'playwright_assert_response', which retrieves the response later. This makes it clear but not fully sibling-aware.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning that this tool 'initiates the wait operation but does not wait for its completion,' suggesting it should be used before 'playwright_assert_response' for retrieval. However, it does not provide explicit when-to-use guidance or alternatives, leaving the context somewhat inferred rather than clearly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.