curl_delete
Send HTTP DELETE requests via curl to remove or delete resources from specified URLs, with optional headers, redirects, and timeout settings.
Instructions
Make an HTTP DELETE request using curl
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| follow_redirects | No | Whether to follow redirects | |
| headers | No | Optional HTTP headers in the format 'Header: Value' | |
| timeout | No | Request timeout in seconds | |
| url | Yes | The URL to make the DELETE request to |
Implementation Reference
- src/index.ts:302-351 (handler)The handler function for the 'curl_delete' tool. It constructs the curl command arguments for an HTTP DELETE request, including URL, headers, redirects, and timeout options, then executes it using the shared executeCurl helper and returns the response.async ({ url, headers, follow_redirects, timeout }) => { const args = ['curl']; // Add the URL args.push(url); // Add DELETE method args.push('-X', 'DELETE'); // Add headers if provided if (headers && headers.length > 0) { headers.forEach(header => { args.push('-H', header); }); } // Add follow redirects option if (follow_redirects) { args.push('-L'); } // Add timeout if provided if (timeout) { args.push('--max-time', timeout.toString()); } // Include response headers in output args.push('-i'); try { const result = await executeCurl(args); return { content: [ { type: "text", text: `Exit Code: ${result.exitCode}\n\nResponse:\n${result.stdout}${result.stderr ? `\n\nErrors:\n${result.stderr}` : ''}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error executing curl: ${error instanceof Error ? error.message : String(error)}`, }, ], }; }
- src/index.ts:296-301 (schema)Zod schema defining the input parameters for the 'curl_delete' tool: url (required), headers (optional array), follow_redirects (optional boolean, default false), timeout (optional number).{ url: z.string().describe("The URL to make the DELETE request to"), headers: z.array(z.string()).optional().describe("Optional HTTP headers in the format 'Header: Value'"), follow_redirects: z.boolean().optional().default(false).describe("Whether to follow redirects"), timeout: z.number().optional().describe("Request timeout in seconds"), },
- src/index.ts:293-295 (registration)Registration of the 'curl_delete' tool on the MCP server instance, specifying name, description, input schema, and handler function.server.tool( "curl_delete", "Make an HTTP DELETE request using curl",
- src/index.ts:23-62 (helper)Shared helper function used by all curl tools, including curl_delete, to safely spawn and execute curl processes, capturing stdout, stderr, and exit code.async function executeCurl(args: string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> { return new Promise((resolve) => { // Ensure we're only calling curl with safe arguments if (!args.includes('curl')) { args.unshift('curl'); } const child = spawn('curl', args.slice(1), { stdio: ['pipe', 'pipe', 'pipe'], shell: false, }); let stdout = ''; let stderr = ''; child.stdout.on('data', (data) => { stdout += data.toString(); }); child.stderr.on('data', (data) => { stderr += data.toString(); }); child.on('close', (code) => { resolve({ stdout, stderr, exitCode: code || 0, }); }); child.on('error', (error) => { resolve({ stdout: '', stderr: error.message, exitCode: 1, }); }); }); }