Skip to main content
Glama
benswel

QR for Agent

bulk_create_qr_codes

Generate multiple QR codes in one batch for product catalogs, event lists, or bulk operations, supporting up to 50 codes per request with customizable options.

Instructions

Create multiple QR codes in a single request (up to 50). Each item supports the same options as create_qr_code. The quota check is all-or-nothing: if the batch would exceed your plan limit, no QR codes are created. Ideal for generating QR codes for product catalogs, event lists, or batch operations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYesArray of QR codes to create. Max 50 per request.

Implementation Reference

  • Implementation of bulkCreateQrCodes service function.
    export async function bulkCreateQrCodes(
      items: CreateQrInput[],
      apiKeyId: number,
      plan: Plan = "free"
    ) {
      // Check plan quota upfront (all-or-nothing)
      const limits = PLAN_LIMITS[plan];
      if (limits.maxQrCodes !== Infinity) {
        const [{ total }] = db
          .select({ total: count() })
          .from(qrCodes)
          .where(eq(qrCodes.apiKeyId, apiKeyId))
          .all();
    
        const remaining = limits.maxQrCodes - total;
        if (items.length > remaining) {
          return {
            error: "QR_CODE_LIMIT_REACHED" as const,
            limit: limits.maxQrCodes,
            existing: total,
            requested: items.length,
            remaining,
          };
        }
      }
    
      const customDomain = getCustomDomain(apiKeyId);
      const results = [];
      for (const input of items) {
        const shortId = nanoid(config.shortId.length);
        const format = input.format || "svg";
        const shortUrl = buildShortUrl(shortId, customDomain);
        const type = input.type || "url";
    
        let targetUrl: string;
        let typeData: string | null = null;
    
        const typeDataMap: Record<string, unknown> = {
          vcard: input.vcard_data, wifi: input.wifi_data, email: input.email_data,
          sms: input.sms_data, phone: input.phone_data, event: input.event_data,
          text: input.text_data, location: input.location_data, social: input.social_data,
          app_store: input.app_store_data,
        };
    
        if (type === "url") {
          targetUrl = input.target_url!;
        } else {
          typeData = JSON.stringify(typeDataMap[type]);
          targetUrl = shortUrl;
        }
    
        const qrContent = getQrContent(type, shortUrl, typeData);
        const styleOptions = buildStyleOptions(input);
        const imageData = await renderQrCode(qrContent, format, styleOptions);
    
        const inserted = db
          .insert(qrCodes)
          .values({
            shortId,
            targetUrl,
            label: input.label || null,
            format,
            styleOptions: styleOptions ? JSON.stringify(styleOptions) : null,
            apiKeyId,
            type,
            typeData,
            expiresAt: type === "url" ? (input.expires_at || null) : null,
            scheduledUrl: type === "url" ? (input.scheduled_url || null) : null,
            scheduledAt: type === "url" ? (input.scheduled_at || null) : null,
            utmParams: type === "url" && input.utm_params ? JSON.stringify(input.utm_params) : null,
            gtmContainerId: type === "url" ? (input.gtm_container_id || null) : null,
            redirectRules: type === "url" && input.redirect_rules ? JSON.stringify(input.redirect_rules) : null,
          })
          .returning()
          .get();
    
        results.push({
          ...formatQrResponse(inserted, customDomain),
          image_data: imageData,
        });
      }
    
      return { created: results.length, items: results };
    }
  • Registration and definition of the bulk_create_qr_codes MCP tool.
    bulk_create_qr_codes: {
      description:
        "Create multiple QR codes in a single request (up to 50). Each item supports the same options as create_qr_code. The quota check is all-or-nothing: if the batch would exceed your plan limit, no QR codes are created. Ideal for generating QR codes for product catalogs, event lists, or batch operations.",
      inputSchema: z.object({
        items: z
          .array(
            z.object({
              target_url: z.string().url().describe("The destination URL."),
              label: z.string().optional().describe("Optional label."),
              format: z.enum(["svg", "png"]).default("svg").describe("Image format."),
              foreground_color: z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe("Hex color for dots."),
              background_color: z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe("Hex color for background."),
              dot_style: z.enum(["square", "rounded", "dots", "classy-rounded"]).optional().describe("Dot shape."),
              corner_style: z.enum(["square", "extra-rounded", "dot"]).optional().describe("Corner shape."),
              logo_url: z.string().optional().describe("Logo URL or data URI."),
              expires_at: z.string().optional().describe("ISO 8601 expiration date."),
              scheduled_url: z.string().url().optional().describe("Replacement URL activated at scheduled_at."),
              scheduled_at: z.string().optional().describe("ISO 8601 activation date for scheduled_url."),
            })
          )
          .min(1)
          .max(50)
          .describe("Array of QR codes to create. Max 50 per request."),
      }),
      handler: async (input: Record<string, unknown>) => {
        return apiRequest("/api/qr/bulk", { method: "POST", body: input });
      },
    },
Behavior4/5

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

No annotations provided, so description carries full burden. Discloses critical behavioral trait: 'The quota check is all-or-nothing: if the batch would exceed your plan limit, no QR codes are created.' Also states batch limit (50). Missing rate limits or auth details, but covers essential atomicity guarantee.

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?

Four sentences, each earning its place: action+scope, parameter delegation, critical behavioral constraint, and usage scenario. Front-loaded with essential information. No redundancy with schema (except 'up to 50' which reinforces maxItems constraint).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 100% schema coverage and no output schema, description adequately covers the bulk operation's purpose, constraints, and atomicity. Minor gap: does not describe return values (e.g., array of created IDs), which would be helpful given the lack of output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, establishing baseline 3. Description adds value by stating 'Each item supports the same options as create_qr_code,' which links to sibling documentation and clarifies the nested parameter structure without redundancy. Reinforces the 50-item limit.

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?

Description opens with specific verb ('Create') and resource ('multiple QR codes'), explicitly states scope ('up to 50'), and distinguishes from sibling 'create_qr_code' by referencing it as the template for options. Clearly differentiates from bulk_delete and bulk_update siblings.

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

Usage Guidelines4/5

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

Provides positive usage context ('Ideal for... product catalogs, event lists, or batch operations') and implies relationship to single-create sibling. Could be stronger with explicit 'when not to use' guidance (e.g., 'For single QR codes, use create_qr_code'), but sufficiently guides selection.

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/benswel/qr-agent-core'

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