Skip to main content
Glama
ericyangpan

Scan QRCode MCP Server

by ericyangpan

decode_qrcode_data_url

Extract text from QR codes encoded as base64 data URLs. This tool processes image data URLs to decode and retrieve the embedded information.

Instructions

Decode a QR code from a data URL (data:;base64,...)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageDataUrlYesImage data URL (base64) of the QR image.

Implementation Reference

  • Specific handler for decoding QR code from data URL: parses the base64 data and calls buffer decoder.
    export async function decodeQrFromDataUrl(dataUrl: string): Promise<DecodeResult> {
      const { buffer } = parseBase64DataUrl(dataUrl);
      return decodeQrFromBuffer(buffer);
    }
  • Core implementation: loads image buffer with Jimp, prepares data for jsQR, detects and extracts QR text.
    export async function decodeQrFromBuffer(buffer: Buffer): Promise<DecodeResult> {
      const image = await Jimp.read(buffer);
      const { data, width, height } = image.bitmap;
    
      // Jimp gives a Node Buffer; jsQR expects a Uint8ClampedArray in RGBA order (same layout as Canvas ImageData).
      const clamped = new Uint8ClampedArray(data.buffer, data.byteOffset, data.byteLength);
      const qr = (
        jsQR as unknown as (
          data: Uint8ClampedArray,
          width: number,
          height: number,
        ) => { data: string } | null
      )(clamped, width, height);
      if (!qr) {
        throw new Error('No QR code detected in image');
      }
      return { text: qr.data };
    }
  • Supporting utility to parse data URL and extract the base64 buffer.
    export function parseBase64DataUrl(dataUrl: string): { mime: string; buffer: Buffer } {
      const match = /^data:([^;]+);base64,(.+)$/i.exec(dataUrl);
      if (!match) {
        throw new Error('Invalid data URL. Expected format: data:<mime>;base64,<data>');
      }
      const [, mime, data] = match;
      const buffer = Buffer.from(data, 'base64');
      return { mime, buffer };
    }
  • src/server.ts:29-43 (registration)
    Tool registration in ListToolsResult: defines name, description, and input schema.
    {
      name: 'decode_qrcode_data_url',
      description: 'Decode a QR code from a data URL (data:<mime>;base64,...)',
      inputSchema: {
        type: 'object',
        required: ['imageDataUrl'],
        properties: {
          imageDataUrl: {
            type: 'string',
            description: 'Image data URL (base64) of the QR image.',
          },
        },
        additionalProperties: false,
      },
    },
  • MCP server CallToolRequest handler: input validation and invocation of service implementation.
    if (name === 'decode_qrcode_data_url') {
      if (!args.imageDataUrl || typeof args.imageDataUrl !== 'string') {
        throw new Error('Missing required argument: imageDataUrl');
      }
      const result = await decodeQr({ imageDataUrl: args.imageDataUrl });
      return { content: [{ type: 'text', text: result.text }] };
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool decodes QR codes from data URLs but doesn't mention error handling, performance characteristics, or what happens with invalid inputs. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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, efficient sentence that directly states the tool's function and input format without unnecessary details. It is front-loaded and wastes no words, making it easy to parse quickly.

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 annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., decoded text, error messages) or address potential complexities like handling malformed data URLs. For a decoding tool with no structured output information, more context is needed to understand its full operation.

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 description coverage is 100%, with the single parameter 'imageDataUrl' well-documented in the schema. The description adds minimal value by reiterating the data URL format but doesn't provide additional context like examples or constraints beyond what the schema already specifies, meeting the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('Decode a QR code') and the input source ('from a data URL'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from its sibling tool 'decode_qrcode_image_url', which likely handles different input formats, leaving some ambiguity about when to choose one over the other.

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 guidance on when to use this tool versus alternatives, such as its sibling 'decode_qrcode_image_url'. It mentions the input format but doesn't specify scenarios where a data URL is appropriate or compare it to other decoding methods, leaving usage context unclear.

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/ericyangpan/scan-qrcode-mcp'

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