Skip to main content
Glama

recognize-plate-image

Recognize and extract license plate numbers from a vehicle image URL. Obtain plate text from a direct image link.

Instructions

Recognize and extract license plate(s) from a vehicle image URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageUrlYesDirect URL to an image of a vehicle's license plate

Implementation Reference

  • Handler function (registerRecognizePlateImageTool) that registers the 'recognize-plate-image' MCP tool. It accepts an imageUrl, sends a POST request to the CarsXE plate recognition API, and returns formatted results.
    export function registerRecognizePlateImageTool(
      server: McpServer,
      getApiKey: () => string | null,
    ) {
      server.tool(
        "recognize-plate-image",
        "Recognize and extract license plate(s) from a vehicle image URL",
        {
          imageUrl: z
            .string()
            .url()
            .describe("Direct URL to an image of a vehicle's license plate"),
        },
        async ({ imageUrl }) => {
          if (!imageUrl) {
            return {
              content: [
                {
                  type: "text",
                  text: "❌ Plate recognition failed. Image URL is required.",
                },
              ],
            };
          }
          // POST request with body as imageUrl
          const apiKey = getApiKey();
          console.log(
            "apiKey recognizePlateImage",
            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}/platerecognition?key=${apiKey}&source=mcp`;
          let data: CarsXEPlateRecognitionResponse | 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: `❌ Plate recognition failed. ${
                    error instanceof Error
                      ? error.message
                      : String(error) || "Unknown error."
                  }`,
                },
              ],
            };
          }
          if (!data || !data.success) {
            return {
              content: [
                {
                  type: "text",
                  text: `❌ Plate recognition failed. ${
                    data?.message || "Unknown error."
                  }`,
                },
              ],
            };
          }
          return {
            content: [
              {
                type: "text",
                text: formatPlateRecognitionResponse(data),
              },
            ],
          };
        },
      );
    }
  • Type definition for CarsXEPlateRecognitionResponse, defining the shape of the API response including results with candidates, region, vehicle, box, and scores.
    export interface CarsXEPlateRecognitionResponse {
      success: boolean;
      message?: string;
      camera_id?: string | null;
      filename?: string;
      processing_time?: number;
      results?: Array<{
        box: {
          xmax: number;
          xmin: number;
          ymax: number;
          ymin: number;
        };
        candidates: Array<{
          plate: string;
          score: number;
        }>;
        dscore?: number;
        plate: string;
        region?: {
          code: string;
          score: number;
        };
        score: number;
        vehicle?: {
          score: number;
          type: string;
        };
      }>;
    }
  • Registration call: server.tool('recognize-plate-image', ...) registers this tool with the MCP server.
    export function registerRecognizePlateImageTool(
      server: McpServer,
      getApiKey: () => string | null,
    ) {
      server.tool(
        "recognize-plate-image",
        "Recognize and extract license plate(s) from a vehicle image URL",
        {
          imageUrl: z
            .string()
            .url()
            .describe("Direct URL to an image of a vehicle's license plate"),
        },
        async ({ imageUrl }) => {
          if (!imageUrl) {
            return {
              content: [
                {
                  type: "text",
                  text: "❌ Plate recognition failed. Image URL is required.",
                },
              ],
            };
          }
          // POST request with body as imageUrl
          const apiKey = getApiKey();
          console.log(
            "apiKey recognizePlateImage",
            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}/platerecognition?key=${apiKey}&source=mcp`;
          let data: CarsXEPlateRecognitionResponse | 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: `❌ Plate recognition failed. ${
                    error instanceof Error
                      ? error.message
                      : String(error) || "Unknown error."
                  }`,
                },
              ],
            };
          }
          if (!data || !data.success) {
            return {
              content: [
                {
                  type: "text",
                  text: `❌ Plate recognition failed. ${
                    data?.message || "Unknown error."
                  }`,
                },
              ],
            };
          }
          return {
            content: [
              {
                type: "text",
                text: formatPlateRecognitionResponse(data),
              },
            ],
          };
        },
      );
    }
  • src/MyMCP.ts:43-45 (registration)
    Registration invocation in MyMCP (Cloudflare Workers MCP Agent).
      registerRecognizePlateImageTool(this.server, getApiKey);
      registerGetLienTheftTool(this.server, getApiKey);
    }
  • src/index.gcp.ts:59-61 (registration)
    Registration invocation in index.gcp.ts (Node.js HTTP server with streamable HTTP transport).
      registerRecognizePlateImageTool(server, getApiKey);
      registerGetLienTheftTool(server, getApiKey);
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the basic action and source, but omits critical details like output format, error handling, input constraints, or limitations (e.g., image quality, plate orientation).

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 that is front-loaded with the key information. No extraneous words or repetition.

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 the lack of output schema and annotations, the description should provide more context about return values, possible multiple plates, and failure modes. It is insufficient for an agent to fully understand the tool's behavior.

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 schema already provides a description for the parameter ('Direct URL to an image of a vehicle's license plate'), achieving 100% coverage. The tool description adds no further semantic detail about the parameter beyond what the schema offers.

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 purpose: recognize and extract license plate(s) from a vehicle image URL. It uses a specific verb-resource combination and distinguishes from sibling tools like 'decode-vehicle-plate' or 'vin-ocr'.

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 over alternatives. There is no mention of prerequisites, context, or exclusions, leaving the agent to infer usage.

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