Skip to main content
Glama
benswel

QR for Agent

get_qr_analytics

Retrieve comprehensive QR code analytics: total scans, daily trends, device, browser, country, and referer breakdowns with percentages, plus recent scan events with parsed user-agent and geo data.

Instructions

Get enriched scan analytics for a QR code. Returns total scans, daily trends, device/browser/country/referer breakdowns with percentages, and recent scan events with parsed user-agent and geo data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
short_idYesThe short ID of the QR code to get analytics for.
periodNoTime period for aggregations. Default: 30d.30d

Implementation Reference

  • Core tool definition for get_qr_analytics. Defines description, inputSchema (short_id + period), and handler which calls apiRequest to GET /api/analytics/{short_id} with period query param.
    get_qr_analytics: {
      description:
        "Get enriched scan analytics for a QR code. Returns total scans, daily trends, device/browser/country/referer breakdowns with percentages, and recent scan events with parsed user-agent and geo data.",
      inputSchema: z.object({
        short_id: z.string().describe("The short ID of the QR code to get analytics for."),
        period: z
          .enum(["7d", "30d", "90d", "all"])
          .default("30d")
          .describe("Time period for aggregations. Default: 30d."),
      }),
      handler: async (input: { short_id: string; period: string }) => {
        return apiRequest(`/api/analytics/${input.short_id}`, { query: { period: input.period } });
      },
    },
  • apiRequest helper function used by the handler. Sends HTTP requests with X-API-Key header to BASE_URL, supporting query params and JSON body.
    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();
    }
  • Tool registration loop. Iterates over exported tools object and registers each (including get_qr_analytics) with the McpServer instance via server.tool().
    // Register each tool from our definitions
    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,
            };
          }
        }
      );
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It correctly indicates a read operation ('get') and lists returned data, but does not disclose prerequisites (e.g., existing short_id), error cases, rate limits, or pagination behavior for recent events.

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: first states purpose, second enumerates returned data. Front-loaded and concise with no redundant information.

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 read-only analytics tool with two simple parameters and no output schema, the description adequately covers return content. It lacks specifics on data format and edge cases, but is sufficient for typical use.

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% and already describes short_id and period with defaults/enum. The description adds context by listing the types of analytics returned, but does not deepen understanding of individual parameters 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 the verb ('get') and resource ('enriched scan analytics for a QR code'), and lists specific data types (total scans, daily trends, breakdowns, recent events). This distinguishes it from siblings that focus on creation, deletion, or other analytics like conversions.

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

Usage Guidelines3/5

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

The description implies use after creating a QR code, but does not explicitly state when to use this vs. other tools like get_conversions or get_usage. No when-not or alternative guidance is provided.

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