get_assistant
Retrieve a Vapi assistant by its unique ID. This tool returns the assistant's configuration and details for management or integration with Vapi APIs.
Instructions
Gets a Vapi assistant by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assistantId | Yes | ID of the assistant to get |
Implementation Reference
- src/tools/assistant.ts:43-60 (handler)The get_assistant tool handler function. It receives an assistantId from the input data, calls vapiClient.assistants.get(assistantId) to fetch the assistant, throws an error if not found, and returns the transformed assistant output.
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; } }) - src/schemas/index.ts:197-199 (schema)The input schema for get_assistant. Defines a 'assistantId' string field that describes the ID of the assistant to get.
export const GetAssistantInputSchema = z.object({ assistantId: z.string().describe('ID of the assistant to get'), }); - src/tools/index.ts:9-14 (registration)The registration entry point. registerAllTools calls registerAssistantTools which registers the 'get_assistant' tool on the MCP server via server.tool().
export const registerAllTools = (server: McpServer, vapiClient: VapiClient) => { registerAssistantTools(server, vapiClient); registerCallTools(server, vapiClient); registerPhoneNumberTools(server, vapiClient); registerToolTools(server, vapiClient); }; - src/tools/utils.ts:44-72 (helper)createToolHandler is the helper wrapper used by get_assistant. It wraps the handler with authentication checks (hasValidToken) and error handling, returning success or error responses.
export function createToolHandler<T>( handler: (params: T) => Promise<any> ): (params: T) => Promise<ToolResponse> { return async (params: T) => { // Check auth first if (!hasValidToken()) { // Start auth if not already in progress if (!isAuthInProgress()) { try { await startAuthFlow(); } catch (error) { // Ignore - we'll show the auth URL below } } const url = getAuthUrl(); if (url) { return createAuthRequiredResponse(url); } return createErrorResponse('Authentication required. Please use vapi_login tool first.'); } try { const result = await handler(params); return createSuccessResponse(result); } catch (error) { return createErrorResponse(error); } }; }