Skip to main content
Glama

vin-ocr

Extracts vehicle identification number (VIN) from images using OCR. Provide a direct image URL to get the VIN.

Instructions

Recognize and extract the VIN from a vehicle image URL using OCR

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageUrlYesDirect URL to an image of a vehicle's VIN (photo or scan)

Implementation Reference

  • The main handler function for the vin-ocr tool. Registers a tool named 'vin-ocr' on the MCP server that accepts an imageUrl, calls the CarsXE VIN OCR API, and returns the formatted result.
    export function registerVinOcrTool(
      server: McpServer,
      getApiKey: () => string | null,
    ) {
      server.tool(
        "vin-ocr",
        "Recognize and extract the VIN from a vehicle image URL using OCR",
        {
          imageUrl: z
            .string()
            .url()
            .describe("Direct URL to an image of a vehicle's VIN (photo or scan)"),
        },
        async ({ imageUrl }) => {
          if (!imageUrl) {
            return {
              content: [
                {
                  type: "text",
                  text: "❌ VIN OCR failed. Image URL is required.",
                },
              ],
            };
          }
          // POST request with body as imageUrl
          const apiKey = getApiKey();
          console.log("apiKey vinOcr", apiKey ? `***${apiKey.slice(-4)}` : "null");
          if (!apiKey) {
            return {
              content: [
                {
                  type: "text",
                  text: "❌ API key not provided. Please ensure X-API-Key header is set.",
                },
              ],
            };
          }
    
          const CARSXE_API_BASE = "https://api.carsxe.com";
          const url = `${CARSXE_API_BASE}/vinocr?key=${apiKey}&source=mcp`;
          let data: CarsXEVinOcrResponse | null = null;
          try {
            const response = await fetch(url, {
              method: "POST",
              headers: { "Content-Type": "text/plain" },
              body: imageUrl,
            });
            if (!response.ok)
              throw new Error(`HTTP error! status: ${response.status}`);
            data = await response.json();
          } catch (error) {
            return {
              content: [
                {
                  type: "text",
                  text: `❌ VIN OCR failed. ${
                    error instanceof Error
                      ? error.message
                      : String(error) || "Unknown error."
                  }`,
                },
              ],
            };
          }
          if (!data || !data.success) {
            return {
              content: [
                {
                  type: "text",
                  text: `❌ VIN OCR failed. ${data?.message || "Unknown error."}`,
                },
              ],
            };
          }
          return {
            content: [
              {
                type: "text",
                text: formatVinOcrResponse(data),
              },
            ],
          };
        },
      );
  • Type definition for CarsXEVinOcrResponse, defining the shape of the API response including success, vin, box, confidence, candidates, and message fields.
    export interface CarsXEVinOcrResponse {
      success: boolean;
      vin?: string;
      box?: {
        xmin: number;
        xmax: number;
        ymin: number;
        ymax: number;
      };
      confidence?: number;
      candidates?: Array<{
        vin: string;
        confidence: number;
        box: {
          xmin: number;
          xmax: number;
          ymin: number;
          ymax: number;
        };
      }>;
      message?: string;
    }
  • src/MyMCP.ts:40-45 (registration)
    Registration of the vin-ocr tool in the MyMCP class (Cloudflare Agent-based MCP server).
      registerVinOcrTool(this.server, getApiKey);
      registerGetYearMakeModelTool(this.server, getApiKey);
      registerDecodeObdCodeTool(this.server, getApiKey);
      registerRecognizePlateImageTool(this.server, getApiKey);
      registerGetLienTheftTool(this.server, getApiKey);
    }
  • src/index.gcp.ts:56-60 (registration)
    Registration of the vin-ocr tool in the GCP/Node HTTP server-based MCP server.
    registerVinOcrTool(server, getApiKey);
    registerGetYearMakeModelTool(server, getApiKey);
    registerDecodeObdCodeTool(server, getApiKey);
    registerRecognizePlateImageTool(server, getApiKey);
    registerGetLienTheftTool(server, getApiKey);
  • Helper formatter that transforms the CarsXEVinOcrResponse into a human-readable markdown string.
    export function formatVinOcrResponse(
      data: import("../types/carsxe.js").CarsXEVinOcrResponse,
    ): string {
      if (!data.success) {
        return `❌ VIN OCR failed. ${data.message || "Unknown error."}`;
      }
      if (!data.vin) {
        return `No VIN detected in the image.`;
      }
      const lines = [
        `### 🔍 VIN OCR Results`,
        data.vin ? `**VIN:** ${data.vin}` : "",
        data.confidence !== undefined
          ? `**Confidence:** ${(data.confidence * 100).toFixed(1)}%`
          : "",
        data.box
          ? `**Bounding Box:** [xmin: ${data.box.xmin}, xmax: ${data.box.xmax}, ymin: ${data.box.ymin}, ymax: ${data.box.ymax}]`
          : "",
        "",
        data.candidates && data.candidates.length > 0
          ? `**Candidates:**\n${data.candidates
              .map(
                (c: any) =>
                  `- ${c.vin} (${(c.confidence * 100).toFixed(1)}%) [xmin: ${
                    c.box.xmin
                  }, xmax: ${c.box.xmax}, ymin: ${c.box.ymin}, ymax: ${c.box.ymax}]`,
              )
              .join("\n")}`
          : "",
      ];
      return lines.filter(Boolean).join("\n");
    }
Behavior2/5

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

With no annotations, the description carries full responsibility for behavioral disclosure, but it only states the basic function. It does not mention potential failure conditions (e.g., poor image quality), output format, or any side effects. This leaves significant gaps for an agent.

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, well-structured sentence with no filler. It efficiently conveys the core function.

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

Completeness3/5

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

For a simple OCR tool with one parameter and no output schema, the description is minimally adequate. However, it lacks details about return values, error handling, or examples, which would improve completeness given the presence of related siblings.

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 for the single parameter (imageUrl), and the description merely restates the purpose. No additional semantic value is added beyond what the schema already provides.

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 action ('Recognize and extract'), the resource ('VIN from a vehicle image URL'), and the method ('using OCR'). It effectively distinguishes this tool from siblings like 'recognize-plate-image' (for license plates) and 'decode-vehicle-plate' (for decoding plate data).

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?

The description provides no explicit guidance on when to use this tool versus alternatives, nor does it mention prerequisites or limitations. Without any usage context, the agent must rely only on the tool name and siblings.

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