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>>();
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 this tool 'initiates the wait operation but does not wait for its completion,' which is a key behavioral trait. However, it doesn't cover other important aspects such as timeout behavior, error handling, concurrency implications, or what happens if multiple responses match the URL pattern, leaving gaps for a tool that manages asynchronous operations.

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 two sentences that are front-loaded with the core purpose and immediately follow with critical behavioral information. Every word earns its place, with no redundancy or unnecessary elaboration, making it highly 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 the complexity of an asynchronous wait tool with no annotations and no output schema, the description is minimally adequate. It covers the basic purpose and a key behavioral trait, but lacks details on error handling, timeouts, or return values, which are important for such operations. The schema handles parameters well, but overall completeness is limited.

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) with clear descriptions. The description adds no additional meaning beyond what the schema provides, such as examples or edge cases, but doesn't need to compensate for low coverage. With 2 parameters and high schema coverage, a baseline score of 3 is appropriate.

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 action ('Ask Playwright to start waiting for a HTTP response') and resource ('HTTP response'), distinguishing it from sibling tools like playwright_assert_response which retrieves the response. However, it doesn't specify the exact scope or how it differs from other waiting/response tools beyond the named sibling.

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 the response can be retrieved later with playwright_assert_response, providing some context for when to use this tool. However, it lacks explicit guidance on when to use this versus alternatives like direct response handling or other playwright tools, and doesn't state prerequisites or exclusions.

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

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