get_phone_number
Retrieve details for a specific phone number using its unique ID to access configuration and usage information.
Instructions
Gets details of a specific phone number
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| phoneNumberId | Yes | ID of the phone number to get |
Implementation Reference
- src/tools/phone-number.ts:26-30 (handler)The core handler logic that extracts phoneNumberId from input, fetches the phone number details using VapiClient, and returns the transformed output.createToolHandler(async (data) => { const phoneNumberId = data.phoneNumberId; const phoneNumber = await vapiClient.phoneNumbers.get(phoneNumberId); return transformPhoneNumberOutput(phoneNumber); })
- src/schemas/index.ts:309-311 (schema)Zod input schema defining the required phoneNumberId parameter for the tool.export const GetPhoneNumberInputSchema = z.object({ phoneNumberId: z.string().describe('ID of the phone number to get'), });
- src/tools/phone-number.ts:22-31 (registration)Registers the get_phone_number tool on the MCP server with name, description, input schema, and wrapped handler function.server.tool( 'get_phone_number', 'Gets details of a specific phone number', GetPhoneNumberInputSchema.shape, createToolHandler(async (data) => { const phoneNumberId = data.phoneNumberId; const phoneNumber = await vapiClient.phoneNumbers.get(phoneNumberId); return transformPhoneNumberOutput(phoneNumber); }) );
- src/transformers/index.ts:233-244 (helper)Helper function that transforms the raw Vapi phone number response into 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/tools/utils.ts:30-41 (helper)Utility that wraps the raw handler with try-catch error handling and standardizes the response format to ToolResponse.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); } }; }