Skip to main content
Glama

generateQRCode

Create QR codes from text or data for sharing information, with options for terminal display, SVG images, or base64 encoding and configurable error correction.

Instructions

Generate a QR code from input data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesData to encode in QR code
typeNoOutput type (terminal, svg, or base64)terminal
errorCorrectionLevelNoError correction levelM

Implementation Reference

  • The main handler function for the generateQRCode tool. It generates QR codes in terminal, SVG, or base64 PNG format using the qrcode and qrcode-terminal libraries, supporting configurable error correction levels.
    handler: async ({
      data,
      type = 'terminal',
      errorCorrectionLevel = 'M'
    }: {
      data: string;
      type?: 'terminal' | 'svg' | 'base64';
      errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H'
    }) => {
      try {
        let result: string;
        const options = {
          errorCorrectionLevel,
          margin: 1,
          width: type === 'svg' ? 200 : undefined
        };
    
        switch (type) {
          case 'terminal':
            // Use qrcode-terminal for better terminal output
            result = await generateTerminalQR(data, { small: true });
            break;
          case 'svg':
            result = await QRCode.toString(data, { ...options, type: 'svg' });
            break;
          case 'base64':
            const buffer = await QRCode.toBuffer(data, { ...options, type: 'png' });
            result = `data:image/png;base64,${buffer.toString('base64')}`;
            break;
          default:
            throw new Error(`Unsupported output type: ${type}`);
        }
    
        return {
          content: [{
            type: 'text',
            text: result
          }]
        };
      } catch (error) {
        throw new Error(`QR code generation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • Input schema for the generateQRCode tool, defining required 'data' string and optional 'type' and 'errorCorrectionLevel' parameters.
    inputSchema: {
      type: 'object',
      properties: {
        data: {
          type: 'string',
          description: 'Data to encode in QR code'
        },
        type: {
          type: 'string',
          description: 'Output type (terminal, svg, or base64)',
          enum: ['terminal', 'svg', 'base64'],
          default: 'terminal'
        },
        errorCorrectionLevel: {
          type: 'string',
          description: 'Error correction level',
          enum: ['L', 'M', 'Q', 'H'],
          default: 'M'
        }
      },
      required: ['data']
    },
  • src/index.ts:28-35 (registration)
    Registers the generateQRCode tool by spreading generatorTools into the allTools object, which is used by the MCP server's listTools and callTool request handlers.
    const allTools: ToolKit = {
      ...systemTools,
      ...networkTools,
      ...geoTools,
      ...generatorTools,
      ...dateTimeTools,
      ...securityTools
    };
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the basic action but doesn't describe what happens after generation (e.g., where/how the QR code is returned, if it's saved, performance characteristics, or error handling). For a tool with no annotation coverage, this leaves significant behavioral gaps.

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 states the core purpose without unnecessary words. It's appropriately sized for a straightforward tool and front-loads the essential information.

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 no annotations, no output schema, and three parameters, the description is incomplete. It doesn't explain what the tool returns (e.g., image data, file path, or display), error conditions, or practical constraints. For a generation tool with output implications, more context is needed.

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?

Schema description coverage is 100%, so the schema fully documents all three parameters. The description adds no additional parameter information beyond what's in the schema. According to guidelines, when schema coverage is high (>80%), the baseline score is 3 even with no param info in description.

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 tool's purpose as 'Generate a QR code from input data', which specifies the verb (generate) and resource (QR code). It distinguishes from siblings like generateUUID or hashData by focusing on QR code generation. However, it doesn't explicitly differentiate from all possible alternatives in a broader context.

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. There's no mention of use cases, prerequisites, or comparisons with other tools. The agent must infer usage solely from the tool name and parameters.

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/cyanheads/toolkit-mcp-server'

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