Skip to main content
Glama
benswel

QR for Agent

list_qr_codes

Browse and search existing QR codes with paginated results including short IDs, target URLs, labels, and timestamps.

Instructions

List all managed QR codes with pagination. Returns short IDs, target URLs, labels, and timestamps. Use this to browse or search for existing QR codes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMax results to return.
offsetNoNumber of results to skip.

Implementation Reference

  • The core handler function `listQrCodes` that queries the database for QR codes owned by the API key, with pagination (limit/offset). Returns data, total count, offset, and limit.
    export function listQrCodes(limit: number = 20, offset: number = 0, apiKeyId: number) {
      const rows = db
        .select()
        .from(qrCodes)
        .where(eq(qrCodes.apiKeyId, apiKeyId))
        .limit(limit)
        .offset(offset)
        .all();
    
      const [{ total }] = db
        .select({ total: count() })
        .from(qrCodes)
        .where(eq(qrCodes.apiKeyId, apiKeyId))
        .all();
    
      const customDomain = getCustomDomain(apiKeyId);
      return {
        data: rows.map((row) => formatQrResponse(row, customDomain)),
        total,
        offset,
        limit,
      };
    }
  • The MCP tool definition for 'list_qr_codes' with input schema (limit/offset) and handler that calls the HTTP API endpoint GET /api/qr via apiRequest.
    list_qr_codes: {
      description:
        "List all managed QR codes with pagination. Returns short IDs, target URLs, labels, and timestamps. Use this to browse or search for existing QR codes.",
      inputSchema: z.object({
        limit: z.number().min(1).max(100).default(20).describe("Max results to return."),
        offset: z.number().min(0).default(0).describe("Number of results to skip."),
      }),
      handler: async (input: { limit: number; offset: number }) => {
        return apiRequest("/api/qr", { query: { limit: input.limit, offset: input.offset } });
      },
    },
  • Registration of all tools (including list_qr_codes) into the MCP server by iterating over the tools object and calling server.tool().
    for (const [name, tool] of Object.entries(tools)) {
      server.tool(
        name,
        tool.description,
        tool.inputSchema.shape,
        async (input: Record<string, unknown>) => {
          try {
            const result = await tool.handler(input as any);
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(result, null, 2),
                },
              ],
            };
          } catch (error) {
            const message = error instanceof Error ? error.message : String(error);
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({
                    error: message,
                    hint: "Check the input parameters and try again. Use list_qr_codes to verify available QR codes.",
                  }),
                },
              ],
              isError: true,
            };
          }
        }
      );
    }
  • JSON Schema (qrListSchema) defining the query parameters limit (integer, 1-100, default 20) and offset (integer, min 0, default 0) for the list endpoint.
    export const qrListSchema = {
      querystring: {
        type: "object" as const,
        properties: {
          limit: {
            type: "integer",
            default: 20,
            minimum: 1,
            maximum: 100,
            description: "Maximum number of QR codes to return. Defaults to 20, max 100.",
          },
          offset: {
            type: "integer",
            default: 0,
            minimum: 0,
            description: "Number of records to skip for pagination.",
          },
        },
      },
    };
  • The apiRequest helper function used by the MCP tool handler to make HTTP requests to the backend API, converting query params and returning JSON.
    export async function apiRequest(path: string, options: RequestOptions = {}) {
      const { method = "GET", body, query } = options;
    
      let url = `${BASE_URL}${path}`;
      if (query) {
        const params = new URLSearchParams();
        for (const [key, value] of Object.entries(query)) {
          params.set(key, String(value));
        }
        url += `?${params.toString()}`;
      }
    
      const headers: Record<string, string> = {
        "X-API-Key": API_KEY,
      };
    
      if (body) {
        headers["Content-Type"] = "application/json";
      }
    
      const res = await fetch(url, {
        method,
        headers,
        body: body ? JSON.stringify(body) : undefined,
      });
    
      return res.json();
    }
Behavior3/5

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

The description mentions pagination and return fields, implying read-only behavior. No annotations are provided, so the description carries the burden. It lacks details like ordering or side effects, but for a list operation this is acceptable.

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 concise sentences with front-loaded information: first states the action, second provides use case and return fields. No unnecessary words.

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

Completeness3/5

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

No output schema, but the description mentions returned fields. It fails to clarify that the list is unfiltered (only pagination), and the word 'search' could be misleading given the absence of search parameters.

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% with clear parameter descriptions. The description adds 'with pagination' which hints at the parameters but does not add new meaning beyond what the schema 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?

The description clearly states it lists all managed QR codes with pagination and specifies the returned fields (short IDs, target URLs, labels, timestamps). This distinguishes it from sibling tools like get_qr_code which retrieves a single record.

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 explicitly says 'use this to browse or search for existing QR codes', providing clear usage context. However, it could be improved by mentioning alternatives for single-record retrieval.

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