Skip to main content
Glama

playwright_delete

Send HTTP DELETE requests to remove resources from web applications using browser automation. Specify the target URL to delete data or clear content programmatically.

Instructions

Perform an HTTP DELETE request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to perform DELETE operation

Implementation Reference

  • DeleteRequestTool class implements the core logic for the 'playwright_delete' tool. It performs an HTTP DELETE request using Playwright's APIRequestContext.delete(), handles response text, and formats the success response with status and truncated body.
    export class DeleteRequestTool extends ApiToolBase {
      /**
       * Execute the DELETE request tool
       */
      async execute(args: any, context: ToolContext): Promise<ToolResponse> {
        return this.safeExecute(context, async (apiContext) => {
          const response = await apiContext.delete(args.url);
    
          let responseText: string;
          try {
            responseText = await response.text();
          } catch (_error) {
            responseText = "Unable to get response text";
          }
    
          return createSuccessResponse([
            `DELETE request to ${args.url}`,
            `Status: ${response.status()} ${response.statusText()}`,
            `Response: ${responseText.substring(0, 1000)}${responseText.length > 1000 ? "..." : ""}`,
          ]);
        });
      }
    }
  • Tool metadata definition including name, description, and input schema (requires 'url' string) for MCP protocol tool listing and validation.
    {
      name: "playwright_delete",
      description: "Perform an HTTP DELETE request",
      inputSchema: {
        type: "object",
        properties: {
          url: { type: "string", description: "URL to perform DELETE operation" },
        },
        required: ["url"],
      },
    },
  • Dispatch switch case in handleToolCall that routes 'playwright_delete' calls to the DeleteRequestTool instance's execute method.
    case "playwright_delete":
      return await deleteRequestTool.execute(args, context);
  • Instantiation of DeleteRequestTool instance during tool initialization in initializeTools function.
    if (!deleteRequestTool) deleteRequestTool = new DeleteRequestTool(server);
  • ApiToolBase abstract class provides common API context validation, error handling, and safeExecute wrapper used by DeleteRequestTool.
    import type { APIRequestContext } from "playwright";
    import { createErrorResponse, type ToolContext, type ToolHandler, type ToolResponse } from "../common/types.js";
    
    /**
     * Base class for all API-based tools
     * Provides common functionality and error handling
     */
    export abstract class ApiToolBase implements ToolHandler {
      protected server: any;
    
      constructor(server: any) {
        this.server = server;
      }
    
      /**
       * Main execution method that all tools must implement
       */
      abstract execute(args: any, context: ToolContext): Promise<ToolResponse>;
    
      /**
       * Ensures an API context is available and returns it
       * @param context The tool context containing apiContext
       * @returns The apiContext or null if not available
       */
      protected ensureApiContext(context: ToolContext): APIRequestContext | null {
        if (!context.apiContext) {
          return null;
        }
        return context.apiContext;
      }
    
      /**
       * Validates that an API context is available and returns an error response if not
       * @param context The tool context
       * @returns Either null if apiContext is available, or an error response
       */
      protected validateApiContextAvailable(context: ToolContext): ToolResponse | null {
        if (!this.ensureApiContext(context)) {
          return createErrorResponse("API context not initialized");
        }
        return null;
      }
    
      /**
       * Safely executes an API operation with proper error handling
       * @param context The tool context
       * @param operation The async operation to perform
       * @returns The tool response
       */
      protected async safeExecute(
        context: ToolContext,
        operation: (apiContext: APIRequestContext) => Promise<ToolResponse>,
      ): Promise<ToolResponse> {
        const apiError = this.validateApiContextAvailable(context);
        if (apiError) return apiError;
    
        try {
          return await operation(context.apiContext!);
        } catch (error) {
          return createErrorResponse(`API operation failed: ${(error as Error).message}`);
        }
      }
    }
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 states the action but lacks behavioral details: it doesn't mention authentication needs, error handling, rate limits, or what the tool returns (e.g., response status, body). For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 a single, direct sentence with zero waste. It's front-loaded and efficiently conveys the core action without unnecessary elaboration, making it highly concise and well-structured.

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

Completeness2/5

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

Given the tool's complexity (a mutation operation with no annotations and no output schema), the description is incomplete. It doesn't explain return values, error cases, or behavioral traits like side effects. For a DELETE tool, which typically modifies server state, more context is needed for safe and effective use.

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%, with the 'url' parameter fully documented in the schema. The description adds no additional meaning beyond what the schema provides (e.g., no examples or constraints on URL format). Baseline 3 is appropriate as the schema handles parameter documentation adequately.

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 ('Perform an HTTP DELETE request'), which is a specific HTTP method. It distinguishes from siblings like playwright_get, playwright_post, etc., by specifying the DELETE method. However, it doesn't explicitly mention what resource it operates on beyond 'HTTP request', making it slightly less specific than a perfect 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention scenarios for DELETE requests (e.g., deleting resources in REST APIs) or differentiate from other HTTP methods in the sibling list (like playwright_post or playwright_put). This leaves the agent without context for tool selection.

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