Skip to main content
Glama
benswel

QR for Agent

bulk_update_qr_codes

Update multiple QR codes simultaneously by modifying target URLs, labels, expiration dates, or scheduled changes in a single batch operation.

Instructions

Update multiple QR codes in a single request (up to 50). Change target URLs and/or labels. Items with non-existent short_id are reported as not_found without failing the whole batch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYesArray of QR code updates. Max 50 per request.

Implementation Reference

  • Implementation of the bulk_update_qr_codes logic.
    export function bulkUpdateQrCodes(
      items: Array<{ short_id: string; target_url?: string; label?: string; [key: string]: unknown }>,
      apiKeyId: number
    ) {
      let updated = 0;
      let notFound = 0;
      const results: Array<{ short_id: string; status: "updated" | "not_found"; target_url?: string; label?: string }> = [];
    
      for (const item of items) {
        const existing = db
          .select()
          .from(qrCodes)
          .where(and(eq(qrCodes.shortId, item.short_id), eq(qrCodes.apiKeyId, apiKeyId)))
          .get();
    
        if (!existing) {
          notFound++;
          results.push({ short_id: item.short_id, status: "not_found" });
          continue;
        }
    
        const type = (existing.type as QrType) || "url";
        const updateSet: Record<string, unknown> = {
          updatedAt: new Date().toISOString(),
        };
    
        if (item.label !== undefined) updateSet.label = item.label;
    
        if (type === "url") {
          if (item.target_url !== undefined) updateSet.targetUrl = item.target_url;
          if (item.expires_at !== undefined) updateSet.expiresAt = item.expires_at;
          if (item.scheduled_url !== undefined) updateSet.scheduledUrl = item.scheduled_url;
          if (item.scheduled_at !== undefined) updateSet.scheduledAt = item.scheduled_at;
          if (item.utm_params !== undefined) updateSet.utmParams = item.utm_params ? JSON.stringify(item.utm_params) : null;
          if (item.gtm_container_id !== undefined) updateSet.gtmContainerId = item.gtm_container_id;
          if (item.redirect_rules !== undefined) updateSet.redirectRules = item.redirect_rules ? JSON.stringify(item.redirect_rules) : null;
        }
        // Type-specific data: merge partial updates
        const typeDataKey = `${type}_data`;
        const itemData = item[typeDataKey];
        if (type !== "url" && itemData && typeof itemData === "object") {
          const current = existing.typeData ? JSON.parse(existing.typeData) : {};
          updateSet.typeData = JSON.stringify({ ...current, ...itemData as object });
        }
    
        db.update(qrCodes)
          .set(updateSet)
          .where(eq(qrCodes.shortId, item.short_id))
          .run();
    
        updated++;
        results.push({
          short_id: item.short_id,
          status: "updated",
          ...(item.target_url !== undefined && { target_url: item.target_url }),
          ...(item.label !== undefined && { label: item.label }),
        });
      }
    
      return { updated, not_found: notFound, items: results };
    }
  • Registration of the bulk_update_qr_codes MCP tool.
    bulk_update_qr_codes: {
      description:
        "Update multiple QR codes in a single request (up to 50). Change target URLs and/or labels. Items with non-existent short_id are reported as not_found without failing the whole batch.",
      inputSchema: z.object({
        items: z
          .array(
            z.object({
              short_id: z.string().describe("The short_id of the QR code to update."),
              target_url: z.string().url().optional().describe("New destination URL."),
              label: z.string().optional().describe("New label."),
              expires_at: z.string().nullable().optional().describe("ISO 8601 expiration date. Null to clear."),
              scheduled_url: z.string().url().nullable().optional().describe("Replacement URL. Null to cancel."),
              scheduled_at: z.string().nullable().optional().describe("ISO 8601 activation date. Null to cancel."),
            })
          )
          .min(1)
          .max(50)
          .describe("Array of QR code updates. Max 50 per request."),
      }),
      handler: async (input: Record<string, unknown>) => {
        return apiRequest("/api/qr/bulk", { method: "PATCH", body: input });
      },
    },
Behavior3/5

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

With no annotations provided, description carries full burden. It successfully discloses partial failure behavior (batch continues despite individual item failures), but omits other critical behavioral traits like rate limits, authentication requirements, atomicity guarantees, or idempotency.

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?

Three tightly constructed sentences with zero waste. Front-loaded with core action (bulk update), followed by capabilities (URLs/labels), then critical error handling behavior. Every sentence earns its place.

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?

For a bulk mutation tool without output schema or annotations, description covers the essential risk (partial failure reporting) and batch constraints. Would benefit from describing the return structure or success indicators, but the partial failure disclosure provides necessary context for safe invocation.

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 coverage is 100%, establishing baseline 3. Description mentions 'target URLs and/or labels' but omits other updatable fields visible in schema (expires_at, scheduled_url, scheduled_at). Adds minimal semantic meaning beyond what the well-documented schema already provides.

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 provides specific verb ('Update'), resource ('QR codes'), and clear scope ('multiple', 'up to 50'). The bulk nature and batch size limit clearly distinguish it from single-update siblings like 'update_qr_destination' or specialized update tools.

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 implicit guidance through the 'up to 50' constraint and explicit guidance on error handling ('non-existent short_id are reported as not_found without failing the whole batch'). Lacks explicit naming of single-update alternatives or specific when-to-use scenarios.

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