Skip to main content
Glama
pvinis
by pvinis

playwright_expect_response

Initiate waiting for a specific HTTP response in Playwright by specifying a unique ID and URL pattern. Later, retrieve and validate the response using the Playwright_assert_response tool.

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

  • ExpectResponseTool class with execute method that initiates page.waitForResponse(url) and stores the promise in a map keyed by 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}`
          );
        });
      }
    }
  • Tool schema definition specifying input parameters 'id' (string) and 'url' (string).
    {
      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"],
      },
    },
  • Registration in the main tool handler switch statement, delegating execution to ExpectResponseTool instance.
    case "playwright_expect_response":
      return await expectResponseTool.execute(args, context);
  • Instantiation of the ExpectResponseTool class instance used by the handler.
    if (!expectResponseTool) expectResponseTool = new ExpectResponseTool(server);
  • Helper method in codegen generator to produce Playwright test code for this tool.
    private generateExpectResponseStep(parameters: Record<string, unknown>): string {
      const { url, id } = parameters;
      return `
      // Wait for response
      const ${id}Response = page.waitForResponse('${url}');`;
    }
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.

Install Server

Other Tools

Related Tools

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/pvinis/mcp-playwright-stealth'

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