Skip to main content
Glama
ericyangpan

Scan QRCode MCP Server

by ericyangpan

decode_qrcode_image_url

Extract text from QR codes by providing an image URL. This tool processes HTTP(S) links to QR images and returns decoded content.

Instructions

Decode a QR code from an HTTP(S) image URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageUrlYesHTTP(S) URL to the QR image.

Implementation Reference

  • Fetches the QR code image from the HTTP(S) URL, validates protocol, fetches and converts to buffer, then decodes using decodeQrFromBuffer.
    export async function decodeQrFromUrl(url: string): Promise<DecodeResult> {
      if (!/^https?:\/\//i.test(url)) {
        throw new Error('Only http(s) URLs are supported for imageUrl');
      }
      const res = await fetch(url);
      if (!res.ok) {
        throw new Error(`Failed to fetch image: ${res.status} ${res.statusText}`);
      }
      const arrayBuffer = await res.arrayBuffer();
      const buffer = Buffer.from(arrayBuffer);
      return decodeQrFromBuffer(buffer);
    }
  • Main dispatcher function that routes to imageUrl decoder (decodeQrFromUrl) or dataUrl decoder based on input.
    export async function decodeQr(input: DecodeInput): Promise<DecodeResult> {
      if ('imageDataUrl' in input && input.imageDataUrl) {
        return decodeQrFromDataUrl(input.imageDataUrl);
      }
      if ('imageUrl' in input && input.imageUrl) {
        return decodeQrFromUrl(input.imageUrl);
      }
      throw new Error('Provide either imageDataUrl or imageUrl');
    }
  • MCP server handler for CallToolRequest of 'decode_qrcode_image_url': validates imageUrl arg and calls decodeQr service.
    if (name === 'decode_qrcode_image_url') {
      if (!args.imageUrl || typeof args.imageUrl !== 'string') {
        throw new Error('Missing required argument: imageUrl');
      }
      const result = await decodeQr({ imageUrl: args.imageUrl });
      return { content: [{ type: 'text', text: result.text }] };
    }
  • src/server.ts:44-55 (registration)
    Registers the 'decode_qrcode_image_url' tool in ListToolsResponse with name, description, and inputSchema.
    {
      name: 'decode_qrcode_image_url',
      description: 'Decode a QR code from an HTTP(S) image URL',
      inputSchema: {
        type: 'object',
        required: ['imageUrl'],
        properties: {
          imageUrl: { type: 'string', description: 'HTTP(S) URL to the QR image.' },
        },
        additionalProperties: false,
      },
    },
  • Low-level helper that loads image buffer with Jimp, prepares data for jsQR, detects and decodes the QR code.
    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 };
    }
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 action 'decode' but does not describe what happens on failure (e.g., invalid URL, non-QR image), rate limits, authentication needs, or output format. For a tool with zero annotation coverage, this is a significant gap in transparency.

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 purpose without any wasted words. It is appropriately sized and front-loaded, making it easy for an agent 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 tool's complexity (decoding QR codes from URLs) and lack of annotations and output schema, the description is incomplete. It does not explain what the tool returns (e.g., decoded text, error messages) or behavioral aspects like error handling. For a tool with no structured output or annotations, more context is needed to be fully helpful.

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 parameter 'imageUrl' fully documented in the schema as 'HTTP(S) URL to the QR image.' The description adds no additional meaning beyond this, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the schema does the heavy lifting.

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 verb 'decode' and the resource 'QR code from an HTTP(S) image URL', making the purpose specific and understandable. However, it does not explicitly differentiate from its sibling tool 'decode_qrcode_data_url', which likely handles data URLs instead of HTTP(S) URLs, so it misses full sibling differentiation.

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 its sibling 'decode_qrcode_data_url' or other alternatives. It implies usage for HTTP(S) URLs but lacks explicit when/when-not instructions or prerequisites, leaving the agent to infer context without clear direction.

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