api_put
Update resources by sending a PUT request to any API endpoint with JSON payload and custom headers.
Instructions
Perform a PUT request to an API endpoint
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | API endpoint URL | |
| data | Yes | Request body data (JSON string) | |
| headers | No | Request headers |
Implementation Reference
- src/executor.ts:578-611 (handler)The handleApiPut function that executes the api_put tool logic. It uses Playwright's APIRequestContext to perform a PUT request with the given URL, data (JSON string), and optional headers. Returns the response status and body.
async function handleApiPut(client: APIRequestContext, args: any): Promise<{ toolResult: CallToolResult }> { try { const options = { data: args.data, headers: args.headers || { 'Content-Type': 'application/json' } }; const response = await client.put(args.url, options); const responseData = await getResponseData(response); return { toolResult: { content: [ { type: "text", text: `PUT ${args.url} - Status: ${response.status()}`, }, ...responseData ], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `PUT request failed: ${(error as Error).message}`, }], isError: true, }, }; } } - src/tools.ts:164-180 (schema)The input schema definition for the api_put tool. Defines required parameters: url (string), data (string for JSON body), and optional headers (object with string values).
{ name: "api_put", description: "Perform a PUT request to an API endpoint", inputSchema: { type: "object", properties: { url: { type: "string", description: "API endpoint URL" }, data: { type: "string", description: "Request body data (JSON string)" }, headers: { type: "object", description: "Request headers", additionalProperties: { type: "string" } } }, required: ["url", "data"] } }, - src/executor.ts:215-216 (registration)The switch case in executeToolCall that dispatches to handleApiPut when toolName is 'api_put'.
case "api_put": return await handleApiPut(apiClient!, args); - src/tools.ts:14-20 (registration)api_put is listed as one of the API_TOOLS, which are used to determine if the API client needs to be initialized.
export const API_TOOLS = [ "api_get", "api_post", "api_put", "api_patch", "api_delete" ];