list_phone_numbers
Retrieve all available phone numbers from the Vapi MCP Server to enable voice API integration and communication setup.
Instructions
Lists all Vapi phone numbers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/phone-number.ts:16-19 (handler)The core handler function that fetches the list of phone numbers from the Vapi API (limited to 10) and transforms each using transformPhoneNumberOutput.createToolHandler(async () => { const phoneNumbers = await vapiClient.phoneNumbers.list({ limit: 10 }); return phoneNumbers.map(transformPhoneNumberOutput); })
- src/tools/phone-number.ts:12-20 (registration)Registers the 'list_phone_numbers' tool with the MCP server, providing description, empty input schema, and the wrapped handler.server.tool( 'list_phone_numbers', 'Lists all Vapi phone numbers', {}, createToolHandler(async () => { const phoneNumbers = await vapiClient.phoneNumbers.list({ limit: 10 }); return phoneNumbers.map(transformPhoneNumberOutput); }) );
- src/transformers/index.ts:233-244 (helper)Helper function that transforms raw Vapi phone number objects to the standardized PhoneNumberOutputSchema format.export function transformPhoneNumberOutput( phoneNumber: any ): z.infer<typeof PhoneNumberOutputSchema> { return { id: phoneNumber.id, name: phoneNumber.name, createdAt: phoneNumber.createdAt, updatedAt: phoneNumber.updatedAt, phoneNumber: phoneNumber.number, status: phoneNumber.status, }; }
- src/schemas/index.ts:313-323 (schema)Zod schema defining the structure of phone number output objects used by the tool.export const PhoneNumberOutputSchema = BaseResponseSchema.extend({ name: z.string().optional(), phoneNumber: z.string(), status: z.string(), capabilities: z .object({ sms: z.boolean().optional(), voice: z.boolean().optional(), }) .optional(), });
- src/tools/utils.ts:30-41 (helper)Generic utility that wraps the raw handler function with try-catch error handling and standardizes the response format 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); } }; }