api_delete
Remove a resource from a web API by performing a DELETE request with configurable headers.
Instructions
Perform a DELETE request to an API endpoint
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | API endpoint URL | |
| headers | No | Request headers |
Implementation Reference
- src/executor.ts:709-735 (handler)The handleApiDelete function is the actual handler that executes the api_delete tool logic. It makes an HTTP DELETE request using Playwright's APIRequestContext, optionally passing headers, and returns the status code.
async function handleApiDelete(client: APIRequestContext, args: any): Promise<{ toolResult: CallToolResult }> { try { const options = args.headers ? { headers: args.headers } : undefined; const response = await client.delete(args.url, options); return { toolResult: { content: [ { type: "text", text: `DELETE ${args.url} - Status: ${response.status()}`, } ], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `DELETE request failed: ${(error as Error).message}`, }], isError: true, }, }; } } - src/tools.ts:198-213 (schema)The schema definition for the api_delete tool, specifying its name, description, and input schema (url required, headers optional).
{ name: "api_delete", description: "Perform a DELETE request to an API endpoint", inputSchema: { type: "object", properties: { url: { type: "string", description: "API endpoint URL" }, headers: { type: "object", description: "Request headers", additionalProperties: { type: "string" } } }, required: ["url"] } } - src/tools.ts:14-20 (registration)The API_TOOLS array that registers 'api_delete' as one of the available API tools.
export const API_TOOLS = [ "api_get", "api_post", "api_put", "api_patch", "api_delete" ]; - src/executor.ts:221-222 (registration)The switch case in executeToolCall that dispatches the 'api_delete' tool name to handleApiDelete.
case "api_delete": return await handleApiDelete(apiClient!, args); - src/handlers.ts:65-71 (helper)The CallToolRequestSchema handler that receives tool call requests and delegates to executeToolCall, which handles api_delete routing.
server.setRequestHandler(CallToolRequestSchema, async (request) => { return executeToolCall( request.params.name, request.params.arguments ?? {}, server ); });