Skip to main content
Glama
VapiAI

Vapi MCP Server

Official
by VapiAI

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
NameRequiredDescriptionDefault
phoneNumberIdYesID of the phone number to get

Implementation Reference

  • 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); })
  • 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'), });
  • 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); }) );
  • 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, }; }
  • 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); } }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/VapiAI/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server