Skip to main content
Glama

playwright_expect_response

Initiate waiting for HTTP responses in browser automation tests to verify network interactions and validate expected API calls or page loads.

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 ExpectResponseTool class implements the core logic for the 'playwright_expect_response' tool. It sets up a Playwright page.waitForResponse promise for the given URL and stores it in a map keyed by the provided ID for later retrieval.
    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 metadata including name, description, and input schema (JSON Schema) for 'playwright_expect_response'.
    {
      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"],
      },
    },
  • Instantiation of the ExpectResponseTool instance in the initializeTools function.
    if (!expectResponseTool) expectResponseTool = new ExpectResponseTool(server);
    if (!assertResponseTool) assertResponseTool = new AssertResponseTool(server);
  • Switch case in handleToolCall that dispatches execution to expectResponseTool.execute
    case "playwright_expect_response":
      return await expectResponseTool.execute(args, context);
  • Global map storing pending response promises by ID, used by both expect and assert tools.
    const responsePromises = new Map<string, Promise<Response>>();
Behavior2/5

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

No annotations are provided, so the description carries full burden. It discloses that the tool starts waiting without completion, which is a key behavioral trait. However, it misses critical details: it doesn't specify timeout behavior, error handling, or how it integrates with Playwright's async operations. 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 extremely concise with two sentences that directly state the tool's function and limitation. Every word earns its place, and it's front-loaded with the core purpose. There is no wasted text, making it efficient and easy to parse.

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 no annotations, no output schema, and 2 parameters with full schema coverage, the description is minimally adequate. It explains the tool's purpose and hints at usage with 'playwright_assert_response,' but lacks details on behavioral aspects like timeouts or integration patterns. For a tool that initiates async operations, more context would improve completeness.

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?

Schema description coverage is 100%, so the schema already documents both parameters ('id' and 'url') fully. The description adds no additional meaning beyond what the schema provides, such as explaining the relationship between 'id' and later retrieval. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't need to heavily.

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 verb ('start waiting') and resource ('HTTP response'), distinguishing it from sibling tools like 'playwright_assert_response' which retrieves the response. However, it doesn't explicitly differentiate from other waiting or response-related tools beyond the sibling list context.

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 stating it 'initiates the wait operation but does not wait for its completion,' suggesting it should be used before an action that triggers a response. It references 'playwright_assert_response' for retrieval, providing some alternative guidance. However, it lacks explicit when-to-use vs. when-not-to-use scenarios or comparisons with other tools like 'playwright_get' or navigation tools.

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

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

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