get_phone_number
Retrieve details of a specific phone number by providing its ID. Access phone number data through the Vapi MCP Server.
Instructions
Gets details of a specific phone number
Input 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 handler function for the 'get_phone_number' tool. Calls vapiClient.phoneNumbers.get(phoneNumberId) and transforms the 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)The Zod schema defining the input: phoneNumberId (string).
export const GetPhoneNumberInputSchema = z.object({ phoneNumberId: z.string().describe('ID of the phone number to get'), }); - src/tools/phone-number.ts:22-31 (registration)Registration of the 'get_phone_number' tool via server.tool() inside registerPhoneNumberTools.
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/tools/index.ts:9-13 (registration)registerPhoneNumberTools is called from registerAllTools to wire up the tool on the MCP server.
export const registerAllTools = (server: McpServer, vapiClient: VapiClient) => { registerAssistantTools(server, vapiClient); registerCallTools(server, vapiClient); registerPhoneNumberTools(server, vapiClient); registerToolTools(server, vapiClient); - src/transformers/index.ts:233-244 (helper)transformPhoneNumberOutput helper used to convert the API response into the output schema 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, }; }