Skip to main content
Glama

get-market-value

Retrieve the estimated market value of a vehicle using its VIN, optionally adjusting for state, mileage, and condition.

Instructions

Get the estimated market value for a vehicle by VIN

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vinYes17-character Vehicle Identification Number
stateNoUS state abbreviation (optional)
mileageNoCurrent mileage of the vehicle used to adjust the market value (optional)
conditionNoOverall condition of the vehicle: excellent, clean, average, or rough (optional)

Implementation Reference

  • Registration function `registerGetMarketValueTool` which registers the 'get-market-value' tool on the MCP server with a Zod schema for vin (required), state, mileage, and condition (optional) and an async handler.
    export function registerGetMarketValueTool(
      server: McpServer,
      getApiKey: () => string | null,
    ) {
      server.tool(
        "get-market-value",
        "Get the estimated market value for a vehicle by VIN",
        {
          vin: z
            .string()
            .min(17)
            .max(17)
            .describe("17-character Vehicle Identification Number"),
          state: z.string().optional().describe("US state abbreviation (optional)"),
          mileage: z
            .number()
            .optional()
            .describe(
              "Current mileage of the vehicle used to adjust the market value (optional)",
            ),
          condition: z
            .enum(["excellent", "clean", "average", "rough"])
            .optional()
            .describe(
              "Overall condition of the vehicle: excellent, clean, average, or rough (optional)",
            ),
        },
        async ({ vin, state, mileage, condition }) => {
          const params: Record<string, string> = { vin };
          if (state) params.state = state;
          if (mileage !== undefined) params.mileage = String(mileage);
          if (condition) params.condition = condition;
          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<CarsXEMarketValueResponse>(
            "v2/marketvalue",
            params,
            apiKey,
          );
          if (!data) {
            return {
              content: [
                {
                  type: "text",
                  text: "❌ Failed to retrieve market value. Please check the VIN and try again.",
                },
              ],
            };
          }
          return {
            content: [
              {
                type: "text",
                text: formatMarketValueResponse(data),
              },
            ],
          };
        },
      );
    }
  • Async handler that validates API key, calls the CarsXE API endpoint 'v2/marketvalue' with params (vin, state, mileage, condition), checks response, and returns formatted market value text.
      async ({ vin, state, mileage, condition }) => {
        const params: Record<string, string> = { vin };
        if (state) params.state = state;
        if (mileage !== undefined) params.mileage = String(mileage);
        if (condition) params.condition = condition;
        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<CarsXEMarketValueResponse>(
          "v2/marketvalue",
          params,
          apiKey,
        );
        if (!data) {
          return {
            content: [
              {
                type: "text",
                text: "❌ Failed to retrieve market value. Please check the VIN and try again.",
              },
            ],
          };
        }
        return {
          content: [
            {
              type: "text",
              text: formatMarketValueResponse(data),
            },
          ],
        };
      },
    );
  • Type definition `CarsXEMarketValueResponse` with fields for input, make, model, model_year, series, style, retail_*, trade_in_*, and msrp values.
    export interface CarsXEMarketValueResponse {
      uid?: string;
      input: {
        vin: string;
        state?: string;
        country?: string;
      };
      publish_date?: string;
      data_freq?: string;
      state?: string;
      country?: string;
      uvc?: string;
      group_num?: string;
      model_year?: string;
      make?: string;
      model?: string;
      series?: string;
      style?: string;
      mileage_cat?: string;
      class_code?: string;
      class_name?: string;
      description_score?: string;
      first_values_flag?: boolean;
      risk_score?: string;
      whole_xclean?: any;
      whole_clean?: any;
      whole_avg?: any;
      whole_rough?: any;
      retail_xclean?: any;
      retail_clean?: any;
      retail_avg?: any;
      retail_rough?: any;
      trade_in_clean?: any;
      trade_in_avg?: any;
      trade_in_rough?: any;
      msrp?: string;
      retail_equipped?: any;
    }
  • Helper function `formatMarketValueResponse` that formats the market value response into a human-readable string with retail/trade-in/msrp details.
    export function formatMarketValueResponse(
      data: CarsXEMarketValueResponse,
    ): string {
      // Helper to show value or fallback to JSON string for debugging
      function showValue(obj: any, key: string): string {
        if (!obj) return "N/A";
        if (obj[key] !== undefined && obj[key] !== null) return obj[key];
        // fallback: show first property if exists
        const firstKey =
          obj && typeof obj === "object" ? Object.keys(obj)[0] : undefined;
        if (firstKey && obj[firstKey] !== undefined) return obj[firstKey];
        // fallback: show JSON
        return JSON.stringify(obj);
      }
      return [
        `💲 Vehicle Market Value`,
        `VIN: ${data.input?.vin}`,
        `Make: ${data.make}`,
        `Model: ${data.model}`,
        `Year: ${data.model_year}`,
        `Series: ${data.series}`,
        `Style: ${data.style}`,
        `Class: ${data.class_name}`,
        `State: ${data.state}`,
        `Country: ${data.country}`,
        `Publish Date: ${data.publish_date}`,
        `Data Frequency: ${data.data_freq}`,
        ``,
        `Retail (Excellent): ${showValue(
          data.retail_xclean,
          "adjusted_whole_xclean",
        )}`,
        `Retail (Good): ${showValue(data.retail_clean, "adjusted_whole_clean")}`,
        `Retail (Average): ${showValue(data.retail_avg, "adjusted_whole_avg")}`,
        `Retail (Rough): ${showValue(data.retail_rough, "adjusted_whole_rough")}`,
        ``,
        `Trade-In (Good): ${showValue(
          data.trade_in_clean,
          "adjusted_whole_clean",
        )}`,
        `Trade-In (Average): ${showValue(data.trade_in_avg, "adjusted_whole_avg")}`,
        `Trade-In (Rough): ${showValue(
          data.trade_in_rough,
          "adjusted_whole_rough",
        )}`,
        ``,
        `MSRP: ${data.msrp}`,
        // Debug: print raw objects if values are missing
        data.retail_xclean && typeof data.retail_xclean === "object"
          ? `Raw retail_xclean: ${JSON.stringify(data.retail_xclean)}`
          : undefined,
        data.retail_clean && typeof data.retail_clean === "object"
          ? `Raw retail_clean: ${JSON.stringify(data.retail_clean)}`
          : undefined,
        data.retail_avg && typeof data.retail_avg === "object"
          ? `Raw retail_avg: ${JSON.stringify(data.retail_avg)}`
          : undefined,
        data.retail_rough && typeof data.retail_rough === "object"
          ? `Raw retail_rough: ${JSON.stringify(data.retail_rough)}`
          : undefined,
        data.trade_in_clean && typeof data.trade_in_clean === "object"
          ? `Raw trade_in_clean: ${JSON.stringify(data.trade_in_clean)}`
          : undefined,
        data.trade_in_avg && typeof data.trade_in_avg === "object"
          ? `Raw trade_in_avg: ${JSON.stringify(data.trade_in_avg)}`
          : undefined,
        data.trade_in_rough && typeof data.trade_in_rough === "object"
          ? `Raw trade_in_rough: ${JSON.stringify(data.trade_in_rough)}`
          : undefined,
      ]
        .filter(Boolean)
        .join("\n");
    }
  • Generic API request helper `carsxeApiRequest` that builds URL with api key, params, and 'source=mcp', fetches from api.carsxe.com, and returns parsed JSON or null on error.
    export async function carsxeApiRequest<T>(
      endpoint: string,
      params: Record<string, string>,
      apiKey: string
    ): Promise<T | null> {
      const CARSXE_API_BASE = "https://api.carsxe.com";
      const queryParams = new URLSearchParams({
        key: apiKey,
        source: "mcp",
        ...params,
      });
      const url = `${CARSXE_API_BASE}/${endpoint}?${queryParams.toString()}`;
      try {
        const response = await fetch(url);
        if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
        return (await response.json()) as T;
      } catch (error) {
        console.error(`Error making CarsXE request to ${endpoint}:`, error);
        return null;
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, and the description does not disclose any behavioral traits such as data freshness, accuracy guarantees, or that it requires only a VIN to function. It also does not mention if there are any side effects or dependencies (e.g., external data source).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that effectively communicates the tool's purpose without any superfluous words. It is well-structured and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description should explain what the tool returns (e.g., estimated value, confidence level, source). It only states 'estimated market value' without mentioning the format or additional details. Optional parameters like 'state' and 'mileage' are not explained in context of their effect on the estimate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so each parameter is documented. The description adds no extra meaning beyond what the schema already provides. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action ('Get the estimated market value') and the resource ('a vehicle by VIN'), making its purpose unambiguous. It effectively distinguishes from siblings like 'get-vehicle-specs' or 'get-vehicle-history' which have different outputs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For example, 'get-vehicle-history' also uses VIN, and a user might need to decide based on whether they need market value or full history. The description does not mention typical use cases or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/carsxe/carsxe-mcp-server'

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