create_tool
Create custom tools for voice AI applications, including SMS messaging, call transfers, API integrations, and server functions.
Instructions
Creates a new 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 | |
| type | Yes | Type of the tool to create |
Implementation Reference
- src/tools/tool.ts:36-40 (handler)Core handler logic: transforms input data using transformToolInput, creates new tool via VapiClient.tools.create, transforms output with transformToolOutput.createToolHandler(async (data) => { const createToolDto = transformToolInput(data); const tool = await vapiClient.tools.create(createToolDto); return transformToolOutput(tool); })
- src/tools/tool.ts:32-41 (registration)Registers the 'create_tool' tool with the MCP server inside registerToolTools function, providing name, description, input schema, and handler.server.tool( 'create_tool', 'Creates a new Vapi tool', CreateToolInputSchema.shape, createToolHandler(async (data) => { const createToolDto = transformToolInput(data); const tool = await vapiClient.tools.create(createToolDto); return transformToolOutput(tool); }) );
- src/schemas/index.ts:401-404 (schema)Input validation schema for create_tool, extending BaseToolConfigSchema and requiring tool type.export const CreateToolInputSchema = BaseToolConfigSchema.extend({ type: z.enum(['sms', 'transferCall', 'function', 'apiRequest']) .describe('Type of the tool to create'), });
- src/tools/utils.ts:30-41 (helper)Utility that wraps any handler function with error handling, success/error response formatting for MCP tools.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); } }; }