Skip to main content
Glama
VapiAI

Vapi MCP Server

Official
by VapiAI

get_assistant

Retrieve a Vapi assistant using its unique ID to access configuration and details for voice AI integration.

Instructions

Gets a Vapi assistant by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assistantIdYesID of the assistant to get

Implementation Reference

  • Core handler function for the 'get_assistant' tool. Extracts assistantId from input, fetches the assistant using vapiClient.assistants.get(), handles not found and other errors, transforms output with transformAssistantOutput, and returns it.
    createToolHandler(async (data) => {
      //   console.log('get_assistant', data);
      const assistantId = data.assistantId;
      try {
        const assistant = await vapiClient.assistants.get(assistantId);
        if (!assistant) {
          throw new Error(`Assistant with ID ${assistantId} not found`);
        }
        return transformAssistantOutput(assistant);
      } catch (error: any) {
        console.error(`Error getting assistant: ${error.message}`);
        throw error;
      }
    })
  • Zod input schema for the get_assistant tool, validating the required 'assistantId' parameter.
    export const GetAssistantInputSchema = z.object({
      assistantId: z.string().describe('ID of the assistant to get'),
    });
  • Registers the 'get_assistant' MCP tool on the server with name, description, input schema, and wrapped handler function.
    server.tool(
      'get_assistant',
      'Gets a Vapi assistant by ID',
      GetAssistantInputSchema.shape,
      createToolHandler(async (data) => {
        //   console.log('get_assistant', data);
        const assistantId = data.assistantId;
        try {
          const assistant = await vapiClient.assistants.get(assistantId);
          if (!assistant) {
            throw new Error(`Assistant with ID ${assistantId} not found`);
          }
          return transformAssistantOutput(assistant);
        } catch (error: any) {
          console.error(`Error getting assistant: ${error.message}`);
          throw error;
        }
      })
    );
  • Helper function that wraps the raw tool handler to provide error handling and standardize the response format as 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