get_vehicles
Retrieve a list of all Tesla vehicles linked to your Tessie account for monitoring and management purposes.
Instructions
List all vehicles in the Tessie account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1168-1219 (handler)MCP tool registration and handler for 'get_vehicles'. Fetches vehicles using TessieClient and returns formatted list in MCP-compliant response format.server.tool( "get_vehicles", "List all vehicles in the Tessie account", {}, async () => { try { const vehicles = await tessieClient.getVehicles(); const result = { total_vehicles: vehicles.length, vehicles: vehicles.map(vehicle => ({ vin: vehicle.vin, display_name: vehicle.display_name })) }; // Wrap in MCP format return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { const enhancedError = ErrorHandler.classifyError(error); if (ErrorHandler.shouldDegrade(enhancedError)) { const fallbackData = { status: 'degraded', error_type: enhancedError.type, message: enhancedError.userFriendly, suggestion: enhancedError.suggestion, vehicles: [], fallback_note: 'Vehicle list temporarily unavailable. Try again in a few moments.' }; // Wrap error fallback in MCP format return { content: [ { type: "text", text: JSON.stringify(fallbackData, null, 2) } ] }; } throw new Error(ErrorHandler.formatErrorForUser(enhancedError)); } } );
- src/tessie-client.ts:221-243 (helper)TessieClient.getVehicles() method: Core implementation that queries the Tessie API /vehicles endpoint and extracts VIN/display_name.async getVehicles(): Promise<Array<{ vin: string; display_name: string }>> { return ErrorHandler.withRetry(async () => { const response: AxiosResponse<{ results: any[] } | any[]> = await this.client.get('/vehicles'); // Handle both old and new API response formats let vehicles: any[]; if (response.data && typeof response.data === 'object' && 'results' in response.data) { vehicles = response.data.results; } else { vehicles = response.data as any[]; } // Extract VIN and display name from the new format return vehicles.map(vehicle => ({ vin: vehicle.vin, display_name: vehicle.last_state?.vehicle_state?.vehicle_name || vehicle.display_name || `Vehicle ${vehicle.vin.slice(-6)}` })); }, { maxRetries: 2, // Account list is fairly stable baseDelay: 1500 }); }
- src/query-optimizer.ts:264-270 (helper)Natural language query parser recognizes vehicle list queries and maps to 'get_vehicles' operation.if (lowerQuery.includes('vehicle') && (lowerQuery.includes('list') || lowerQuery.includes('all'))) { return { operation: 'get_vehicles', parameters: {}, confidence: 0.8 }; }