Skip to main content
Glama
benswel

QR for Agent

create_wifi_qr

Generate a QR code that encodes WiFi network credentials for instant auto-join. Simply scan with a phone camera; no internet required. Customize colors, styles, and add a branded frame with a call-to-action.

Instructions

Create a QR code that encodes WiFi credentials. When scanned by a phone camera, it offers to auto-join the WiFi network. No internet connection needed to join — the credentials are encoded directly in the QR image.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ssidYesWiFi network name (SSID).
passwordNoWiFi password. Omit for open networks (use encryption='nopass').
encryptionNoEncryption type. Default: WPA.WPA
hiddenNoWhether the network is hidden. Default: false.
labelNoLabel for this QR code.
formatNoImage format.svg
foreground_colorNoHex color for dots.
background_colorNoHex color for background.
dot_styleNoDot shape.
corner_styleNoCorner shape.
logo_urlNoLogo URL or data URI.
frame_styleNoFrame style around QR.
frame_textNoCTA text on frame (max 30 chars).
frame_colorNoFrame background color.
frame_text_colorNoFrame text color.

Implementation Reference

  • The handler function for create_wifi_qr tool. It destructures ssid, password, encryption, hidden from input, spreads the rest, and delegates to the backend API via apiRequest('/api/qr', POST) with type:'wifi' and wifi_data.
    create_wifi_qr: {
      description:
        "Create a QR code that encodes WiFi credentials. When scanned by a phone camera, it offers to auto-join the WiFi network. No internet connection needed to join — the credentials are encoded directly in the QR image.",
      inputSchema: z.object({
        ssid: z.string().describe("WiFi network name (SSID)."),
        password: z.string().optional().describe("WiFi password. Omit for open networks (use encryption='nopass')."),
        encryption: z.enum(["WPA", "WEP", "nopass"]).default("WPA").describe("Encryption type. Default: WPA."),
        hidden: z.boolean().optional().describe("Whether the network is hidden. Default: false."),
        label: z.string().optional().describe("Label for this QR code."),
        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."),
        frame_style: z.enum(["none", "banner_bottom", "banner_top", "rounded"]).optional().describe("Frame style around QR."),
        frame_text: z.string().max(30).optional().describe("CTA text on frame (max 30 chars)."),
        frame_color: z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe("Frame background color."),
        frame_text_color: z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe("Frame text color."),
      }),
      handler: async (input: Record<string, unknown>) => {
        const { ssid, password, encryption, hidden, ...rest } = input;
        return apiRequest("/api/qr", {
          method: "POST",
          body: {
            type: "wifi",
            wifi_data: { ssid, password, encryption, hidden },
            ...rest,
          },
        });
      },
    },
  • Input schema (Zod) for create_wifi_qr tool defining ssid (required string), password (optional string), encryption (enum WPA/WEP/nopass, default WPA), hidden (optional boolean), label, format, foreground/background colors, dot/corner styles, logo_url, frame options.
    create_wifi_qr: {
      description:
        "Create a QR code that encodes WiFi credentials. When scanned by a phone camera, it offers to auto-join the WiFi network. No internet connection needed to join — the credentials are encoded directly in the QR image.",
      inputSchema: z.object({
        ssid: z.string().describe("WiFi network name (SSID)."),
        password: z.string().optional().describe("WiFi password. Omit for open networks (use encryption='nopass')."),
        encryption: z.enum(["WPA", "WEP", "nopass"]).default("WPA").describe("Encryption type. Default: WPA."),
        hidden: z.boolean().optional().describe("Whether the network is hidden. Default: false."),
        label: z.string().optional().describe("Label for this QR code."),
        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."),
        frame_style: z.enum(["none", "banner_bottom", "banner_top", "rounded"]).optional().describe("Frame style around QR."),
        frame_text: z.string().max(30).optional().describe("CTA text on frame (max 30 chars)."),
        frame_color: z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe("Frame background color."),
        frame_text_color: z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe("Frame text color."),
      }),
  • Registration loop that iterates over all tools (including create_wifi_qr) and registers each with the MCP server via server.tool(name, description, schema, handler).
    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,
            };
          }
        }
      );
  • The apiRequest helper function used by the handler to make HTTP requests to the backend API with the configured BASE_URL and API_KEY.
    import dotenv from "dotenv";
    dotenv.config();
    
    const BASE_URL = process.env.BASE_URL || "http://localhost:3100";
    const API_KEY = process.env.API_KEY || "";
    
    interface RequestOptions {
      method?: string;
      body?: unknown;
      query?: Record<string, string | number>;
    }
    
    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();
    }
Behavior2/5

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

With no annotations, the description must fully disclose behavior. It explains the QR code's scanning effect but omits critical details like authentication requirements, rate limits, storage, or output format. The description adds minimal behavioral context beyond the QR code's purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two short, front-loaded sentences. It wastes no words but sacrifices completeness for brevity.

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

Completeness2/5

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

For a tool with 15 parameters and no output schema, the description is incomplete. It does not explain the return value, how the QR code is delivered, or how to use the output. Customization options are not mentioned despite many 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 descriptions for all 15 parameters. The description adds no additional parameter information beyond the schema, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool creates a QR code for WiFi credentials, specifying the action and resource. It explains the scanning behavior and that no internet is needed. However, it does not explicitly differentiate from sibling tools like create_qr_code, missing top marks.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus other QR creation tools (e.g., create_qr_code, create_email_qr). No usage conditions or exclusions are 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