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}');`;
    }
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 is non-blocking ('does not wait for its completion'), which is a key behavioral trait. However, it lacks details on error handling, timeout behavior, concurrency limits, or how it integrates with Playwright's context (e.g., page or browser scope). For a tool initiating asynchronous operations, this is a significant gap.

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: two sentences that directly state the purpose and key behavioral trait. Every sentence earns its place by clarifying the tool's action and its non-blocking nature, with zero wasted words or redundant information.

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 async HTTP response waits), lack of annotations, and no output schema, the description is minimally complete. It covers the basic purpose and non-blocking behavior but omits critical context like error handling, timeout details, or integration with sibling tools (e.g., how 'id' links to 'playwright_assert_response'). For a tool with no structured safety or output info, it should do more to guide usage.

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's in the schema, such as explaining parameter interactions or usage examples. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

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 monitoring tools in the sibling list, such as those handling navigation or events.

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's used to set up a response expectation without blocking. It hints at an alternative ('playwright_assert_response' for retrieval) but doesn't explicitly state when to use this tool vs. others (e.g., for async monitoring vs. immediate actions). No exclusions or prerequisites are provided.

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/devskido/customed-playwright'

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