Skip to main content
Glama

decode-obd-code

Decode OBD codes to get diagnosis information and identify vehicle problems.

Instructions

Decode an OBD code and get diagnosis information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesOBD code to decode (e.g., P0115)

Implementation Reference

  • Main handler function for the 'decode-obd-code' tool. Registers the tool on the McpServer with a Zod schema accepting a 'code' string. The handler validates the API key, calls carsxeApiRequest to the 'obdcodesdecoder' endpoint, and formats the response using formatObdCodeResponse.
    export function registerDecodeObdCodeTool(
      server: McpServer,
      getApiKey: () => string | null,
    ) {
      server.tool(
        "decode-obd-code",
        "Decode an OBD code and get diagnosis information",
        {
          code: z.string().describe("OBD code to decode (e.g., P0115)"),
        },
        async ({ code }) => {
          if (!code) {
            return {
              content: [
                {
                  type: "text",
                  text: "❌ OBD code lookup failed. Code is required.",
                },
              ],
            };
          }
          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<CarsXEObdCodeResponse>(
            "obdcodesdecoder",
            { code },
            apiKey,
          )) as CarsXEObdCodeResponse;
          if (!data || !data.success) {
            return {
              content: [
                {
                  type: "text",
                  text: `❌ OBD code lookup failed.`,
                },
              ],
            };
          }
          return {
            content: [
              {
                type: "text",
                text: formatObdCodeResponse(data),
              },
            ],
          };
        },
      );
    }
  • Input schema for the 'decode-obd-code' tool: a single required 'code' string (the OBD code like P0115).
    server.tool(
      "decode-obd-code",
      "Decode an OBD code and get diagnosis information",
      {
        code: z.string().describe("OBD code to decode (e.g., P0115)"),
      },
  • Type definition for CarsXEObdCodeResponse interface with success, diagnosis, date, and code fields.
    export interface CarsXEObdCodeResponse {
      success: boolean;
      diagnosis?: string;
      date?: string;
      code?: string;
    }
  • Formats the OBD code API response into a human-readable string with code, diagnosis, and date.
    export function formatObdCodeResponse(
      data: import("../types/carsxe.js").CarsXEObdCodeResponse,
    ): string {
      if (!data.success) {
        return `❌ OBD code lookup failed.`;
      }
      return [
        `### 🛠️ OBD Code Diagnosis`,
        data.code ? `**Code:** ${data.code}` : undefined,
        data.diagnosis ? `**Diagnosis:** ${data.diagnosis}` : undefined,
        data.date ? `**Date:** ${data.date.split("T")[0]}` : undefined,
      ]
        .filter(Boolean)
        .join("\n");
    }
  • Generic API request helper that calls the CarsXE API. Used by the handler to call the 'obdcodesdecoder' endpoint.
    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 provided, so the description must fully disclose behavior. It only states the action and output type but omits details like input format validation, error handling, or response structure.

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

Conciseness4/5

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

The description is a single, efficient sentence. While very concise, it could be slightly more structured (e.g., noting the output format) without becoming verbose.

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?

Given the tool's simplicity (one parameter, no output schema), the description is adequate but leaves room for improvement, such as clarifying what 'diagnosis information' entails.

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 covers the parameter with an example. The description adds no further parameter-level detail, but with 100% schema coverage, the baseline is met.

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 decodes an OBD code and provides diagnosis information, which distinguishes it from sibling tools that deal with vehicle plates, VINs, or other data.

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

Usage Guidelines3/5

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

The description implies usage when an OBD code is available, but lacks explicit guidance on when to use this tool versus alternatives or any 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