api_patch
Send a PATCH request to update an API resource. Provide the endpoint URL, JSON request body, and optional headers to modify existing data.
Instructions
Perform a PATCH 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/tools.ts:182-197 (registration)Registration of the 'api_patch' tool with its name, description, and input schema (url, data, headers).
name: "api_patch", description: "Perform a PATCH 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/tools.ts:14-20 (helper)API_TOOLS array listing 'api_patch' as one of the available API tools.
export const API_TOOLS = [ "api_get", "api_post", "api_put", "api_patch", "api_delete" ]; - src/executor.ts:218-219 (registration)Switch case dispatching 'api_patch' to handler function handleApiPatch.
case "api_patch": return await handleApiPatch(apiClient!, args); - src/executor.ts:613-646 (handler)Handler function handleApiPatch: executes PATCH request using APIRequestContext, passes url/data/headers, returns status and response data.
async function handleApiPatch(client: APIRequestContext, args: any): Promise<{ toolResult: CallToolResult }> { try { const options = { data: args.data, headers: args.headers || { 'Content-Type': 'application/json' } }; const response = await client.patch(args.url, options); const responseData = await getResponseData(response); return { toolResult: { content: [ { type: "text", text: `PATCH ${args.url} - Status: ${response.status()}`, }, ...responseData ], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `PATCH request failed: ${(error as Error).message}`, }], isError: true, }, }; } }