update_tool
Modify an existing Vapi tool's configuration to update SMS, call transfer, custom functions, or API integration settings.
Instructions
Updates an existing Vapi tool
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Name of the function/tool | |
| description | No | Description of what the function/tool does | |
| sms | No | SMS tool configuration - to send text messages | |
| transferCall | No | Transfer call tool configuration - to transfer calls to destinations | |
| function | No | Custom function tool configuration - for custom server-side functions | |
| apiRequest | No | API Request tool configuration - for HTTP API integration | |
| toolId | Yes | ID of the tool to update |
Implementation Reference
- src/tools/tool.ts:47-51 (handler)The core handler function for 'update_tool': transforms the input using transformUpdateToolInput, updates the tool via VapiClient.tools.update, and returns the transformed output.createToolHandler(async (data) => { const updateToolDto = transformUpdateToolInput(data); const tool = await vapiClient.tools.update(data.toolId, updateToolDto); return transformToolOutput(tool); })
- src/tools/tool.ts:43-52 (registration)Registers the 'update_tool' MCP tool on the server, specifying name, description, input schema, and handler.server.tool( 'update_tool', 'Updates an existing Vapi tool', UpdateToolInputSchema.shape, createToolHandler(async (data) => { const updateToolDto = transformUpdateToolInput(data); const tool = await vapiClient.tools.update(data.toolId, updateToolDto); return transformToolOutput(tool); }) );
- src/schemas/index.ts:406-408 (schema)Zod input schema definition for the update_tool, extending BaseToolConfigSchema with toolId.export const UpdateToolInputSchema = BaseToolConfigSchema.extend({ toolId: z.string().describe('ID of the tool to update'), });
- src/tools/utils.ts:30-40 (helper)Generic helper function that wraps tool handlers to provide error handling and standardize ToolResponse format.export function createToolHandler<T>( handler: (params: T) => Promise<any> ): (params: T) => Promise<ToolResponse> { return async (params: T) => { try { const result = await handler(params); return createSuccessResponse(result); } catch (error) { return createErrorResponse(error); } };
- src/transformers/index.ts:314-365 (helper)Transformer function that converts the UpdateToolInputSchema into the Vapi UpdateToolDto format.export function transformUpdateToolInput( input: z.infer<typeof UpdateToolInputSchema> ): any { let updateDto: any = {}; // Add function definition if name and description are provided if (input.name || input.description) { updateDto.function = { ...(input.name && { name: input.name }), ...(input.description && { description: input.description }), }; } // Handle SMS tool configuration if (input.sms?.metadata) { updateDto.metadata = input.sms.metadata; } // Handle Transfer call tool configuration if (input.transferCall?.destinations) { updateDto.destinations = input.transferCall.destinations; } // Handle Function tool configuration if (input.function?.parameters && input.function?.server) { // For function tools, add parameters to the existing function object if (updateDto.function) { updateDto.function.parameters = input.function.parameters; } else { updateDto.function = { parameters: input.function.parameters, }; } updateDto.server = { url: input.function.server.url, ...(input.function.server.headers && { headers: input.function.server.headers }), }; } // Handle API Request tool configuration if (input.apiRequest) { if (input.apiRequest.url) updateDto.url = input.apiRequest.url; if (input.apiRequest.method) updateDto.method = input.apiRequest.method; if (input.apiRequest.headers) updateDto.headers = input.apiRequest.headers; if (input.apiRequest.body) updateDto.body = input.apiRequest.body; if (input.apiRequest.backoffPlan) updateDto.backoffPlan = input.apiRequest.backoffPlan; if (input.apiRequest.timeoutSeconds) updateDto.timeoutSeconds = input.apiRequest.timeoutSeconds; } return updateDto; }