get-year-make-model
Retrieve comprehensive vehicle specifications, history, recalls, and market value by entering year, make, model, and optional trim.
Instructions
Get comprehensive vehicle info by year, make, model, and optional trim
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | Yes | Manufacturing year of the vehicle (e.g., 2023) | |
| make | Yes | Vehicle make (e.g., Toyota) | |
| model | Yes | Vehicle model (e.g., Camry) | |
| trim | No | Vehicle trim (optional, e.g., XLE) |
Implementation Reference
- src/tools/getYearMakeModel.ts:7-67 (handler)The main handler function for the 'get-year-make-model' tool. Defines the tool with Zod schema params (year, make, model, optional trim), calls the CarsXE API endpoint v1/ymm, and returns formatted response text.
export function registerGetYearMakeModelTool( server: McpServer, getApiKey: () => string | null, ) { server.tool( "get-year-make-model", "Get comprehensive vehicle info by year, make, model, and optional trim", { year: z .string() .describe("Manufacturing year of the vehicle (e.g., 2023)"), make: z.string().describe("Vehicle make (e.g., Toyota)"), model: z.string().describe("Vehicle model (e.g., Camry)"), trim: z .string() .optional() .describe("Vehicle trim (optional, e.g., XLE)"), }, async ({ year, make, model, trim }) => { const params: Record<string, string> = { year, make, model }; if (trim) params.trim = trim; const apiKey = getApiKey(); if (!apiKey) { return { content: [ { type: "text", text: "❌ API key not provided. Please ensure X-API-Key header is set.", }, ], }; } const data = (await carsxeApiRequest<CarsXEYearMakeModelResponse>( "v1/ymm", params, apiKey, )) as CarsXEYearMakeModelResponse; if (!data || !data.success) { return { content: [ { type: "text", text: `❌ Year/Make/Model lookup failed. ${ data?.message || "Unknown error." }`, }, ], }; } return { content: [ { type: "text", text: formatYearMakeModelResponse(data), }, ], }; }, ); } - src/types/carsxe.ts:259-296 (schema)TypeScript interface CarsXEYearMakeModelResponse defining the response shape including bestMatch (with name, year, make, model, pricing, colors, features, etc.), trimOptions, success, input, and message fields.
export interface CarsXEYearMakeModelResponse { bestMatch?: { make: string; model: string; year: number | string; name: string; base_msrp: number; base_invoice: number; total_seating: number; color: { exterior: Array<{ name: string; rgb: string }>; interior: Array<{ name: string; rgb: string }>; }; features: { standard: Array<{ category: string; features: Array<{ name: string; value: string | null }>; }>; optional: Array<{ category: string; features: Array<{ name: string; price?: number | null }>; }>; }; is_truck: boolean; is_electric: boolean; is_plugin_electric: boolean; }; trimOptions?: Array<any>; success: boolean; input: { year: string; make: string; model: string; trim?: string; }; timestamp?: string; message?: string; } - src/MyMCP.ts:41-45 (registration)Registration of the tool in the MyMCP class (Cloudflare Workers agent), calling registerGetYearMakeModelTool(this.server, getApiKey).
registerGetYearMakeModelTool(this.server, getApiKey); registerDecodeObdCodeTool(this.server, getApiKey); registerRecognizePlateImageTool(this.server, getApiKey); registerGetLienTheftTool(this.server, getApiKey); } - src/index.gcp.ts:57-60 (registration)Registration of the tool in the GCP-based HTTP server, calling registerGetYearMakeModelTool(server, getApiKey) inside registerAllTools.
registerGetYearMakeModelTool(server, getApiKey); registerDecodeObdCodeTool(server, getApiKey); registerRecognizePlateImageTool(server, getApiKey); registerGetLienTheftTool(server, getApiKey); - Formatter helper that converts the CarsXEYearMakeModelResponse into a readable string output with vehicle details, MSRP, colors, and features.
export function formatYearMakeModelResponse( data: import("../types/carsxe.js").CarsXEYearMakeModelResponse, ): string { if (!data.success) { return `❌ Year/Make/Model lookup failed. ${ data.message || "Unknown error." }`; } if (!data.bestMatch) { return `No matching vehicle found for the specified year, make, and model.`; } const v = data.bestMatch; const lines = [ `### 🚘 Year/Make/Model Lookup`, `**Name:** ${v.name}`, `**Year:** ${v.year}`, `**Make:** ${v.make}`, `**Model:** ${v.model}`, `**Base MSRP:** $${v.base_msrp.toLocaleString()}`, `**Base Invoice:** $${v.base_invoice.toLocaleString()}`, `**Seating:** ${v.total_seating}`, v.is_truck ? `**Truck:** Yes` : undefined, v.is_electric ? `**Electric:** Yes` : undefined, v.is_plugin_electric ? `**Plug-in Hybrid:** Yes` : undefined, "", v.color?.exterior?.length ? `**Exterior Colors:**\n${v.color.exterior .map((c: any) => `- ${c.name} (RGB: ${c.rgb})`) .join("\n")}` : undefined, v.color?.interior?.length ? `**Interior Colors:**\n${v.color.interior .map((c: any) => `- ${c.name} (RGB: ${c.rgb})`) .join("\n")}` : undefined, "", v.features?.standard?.length ? `**Standard Features:**\n${v.features.standard .map( (cat: any) => `- **${cat.category}:**\n${cat.features .map( (f: any) => ` - ${f.name}${f.value ? `: ${f.value}` : ""}`, ) .join("\n")}`, ) .join("\n")}` : undefined, v.features?.optional?.length ? `**Optional Features & Packages:**\n${v.features.optional .map( (cat: any) => `- **${cat.category}:**\n${cat.features .map( (f: any) => ` - ${f.name}${ f.price !== undefined && f.price !== null ? ` ($${f.price})` : "" }`, ) .join("\n")}`, ) .join("\n")}` : undefined, ]; return lines.filter(Boolean).join("\n\n"); }