Skip to main content
Glama
keithah

Tessie MCP Extension

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

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

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/keithah/tessie-mcp'

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