Skip to main content
Glama
benswel

QR for Agent

bulk_delete_qr_codes

Delete multiple QR codes and their associated scan analytics in one request. Supports up to 50 codes; non-existent IDs are reported as not_found without stopping the batch.

Instructions

Delete multiple QR codes and their scan analytics in a single request (up to 50). Items with non-existent short_id are reported as not_found without failing the whole batch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
short_idsYesArray of short_id strings to delete. Max 50 per request.

Implementation Reference

  • The actual implementation function that handles bulk deletion. Iterates through shortIds, checks ownership via apiKeyId, deletes matching QR codes, and returns a summary of deleted/not_found items.
    export function bulkDeleteQrCodes(shortIds: string[], apiKeyId: number) {
      let deleted = 0;
      let notFound = 0;
      const results: Array<{ short_id: string; status: "deleted" | "not_found" }> = [];
    
      for (const shortId of shortIds) {
        const existing = db
          .select()
          .from(qrCodes)
          .where(and(eq(qrCodes.shortId, shortId), eq(qrCodes.apiKeyId, apiKeyId)))
          .get();
    
        if (!existing) {
          notFound++;
          results.push({ short_id: shortId, status: "not_found" });
          continue;
        }
    
        db.delete(qrCodes).where(eq(qrCodes.shortId, shortId)).run();
        deleted++;
        results.push({ short_id: shortId, status: "deleted" });
      }
    
      return { deleted, not_found: notFound, items: results };
    }
  • Route schema definition for bulk delete: validates body requires short_ids array (1-50 items), defines 200 response shape with deleted count, not_found count, and items array.
    export const qrBulkDeleteSchema = {
      body: {
        type: "object" as const,
        required: ["short_ids"],
        properties: {
          short_ids: {
            type: "array",
            minItems: 1,
            maxItems: 50,
            description: "Array of short_id strings to delete (max 50).",
            items: { type: "string" },
          },
        },
      },
      response: {
        200: {
          type: "object",
          properties: {
            deleted: { type: "integer" },
            not_found: { type: "integer" },
            items: {
              type: "array",
              items: {
                type: "object",
                properties: {
                  short_id: { type: "string" },
                  status: { type: "string", enum: ["deleted", "not_found"] },
                },
              },
            },
          },
        },
      },
  • MCP tool registration for bulk_delete_qr_codes. Defines input schema (short_ids array, 1-50 items) and handler that calls the HTTP API endpoint DELETE /api/qr/bulk.
    bulk_delete_qr_codes: {
      description:
        "Delete multiple QR codes and their scan analytics in a single request (up to 50). Items with non-existent short_id are reported as not_found without failing the whole batch.",
      inputSchema: z.object({
        short_ids: z
          .array(z.string())
          .min(1)
          .max(50)
          .describe("Array of short_id strings to delete. Max 50 per request."),
      }),
      handler: async (input: Record<string, unknown>) => {
        return apiRequest("/api/qr/bulk", { method: "DELETE", body: input });
      },
  • Route registration for DELETE /api/qr/bulk. Validates body with qrBulkDeleteSchema, then delegates to qrService.bulkDeleteQrCodes().
    // BULK DELETE QR codes
    app.delete(
      "/bulk",
      {
        schema: {
          ...qrBulkDeleteSchema,
          tags: ["QR Codes"],
          summary: "Delete multiple QR codes in one request",
          description:
            "Delete up to 50 QR codes and their scan analytics in a single request. Items with non-existent short_id are reported as not_found.",
        },
      },
      async (request, reply) => {
        const body = request.body as { short_ids: string[] };
        return qrService.bulkDeleteQrCodes(body.short_ids, request.apiKeyId);
      }
    );
Behavior4/5

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

With no annotations, the description carries full burden. It adds value by disclosing that scan analytics are also deleted, the batch size limit, and that non-existent items are reported as not_found without failing the batch. This is good transparency for a delete operation.

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?

Two sentences, no fluff, front-loading key information (purpose and limit) with technical details in the second sentence. Every word earns its place.

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

Completeness5/5

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

For a simple batch delete with one parameter and no output schema, the description covers all necessary behavioral aspects (what, limit, error handling). It is complete enough for an agent to use correctly.

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%, so baseline is 3. The description adds meaning beyond the schema by explaining how non-existent short_ids are handled, which helps the agent understand error behavior.

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?

The description clearly states it deletes multiple QR codes and their scan analytics in a single request, with a batch limit of 50. This distinguishes it from sibling tools like delete_qr_code (single) and bulk_create/update.

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?

The description specifies the batch size limit and behavior for non-existent short_ids, but does not explicitly state when to use this tool vs alternatives or provide context on prerequisites.

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