Skip to main content
Glama
benswel

QR for Agent

update_wifi_qr

Update WiFi network credentials (SSID, password, encryption) on an existing WiFi QR code without regenerating the image. Requires short ID. Optionally update label or hidden status.

Instructions

Update the WiFi credentials of a WiFi QR code. Only works on QR codes created with type='wifi'. Note: updating WiFi data changes the QR image content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
short_idYesThe short ID of the WiFi QR code to update.
ssidNoWiFi network name.
passwordNoWiFi password.
encryptionNoEncryption type.
hiddenNoWhether the network is hidden.
labelNoUpdate the label.

Implementation Reference

  • The handler function that executes the update_wifi_qr tool logic. It extracts short_id, label, and remaining wifi fields from input, constructs a body with wifi_data, and calls apiRequest with a PATCH to /api/qr/{short_id}.
    update_wifi_qr: {
      description:
        "Update the WiFi credentials of a WiFi QR code. Only works on QR codes created with type='wifi'. Note: updating WiFi data changes the QR image content.",
      inputSchema: z.object({
        short_id: z.string().describe("The short ID of the WiFi QR code to update."),
        ssid: z.string().optional().describe("WiFi network name."),
        password: z.string().optional().describe("WiFi password."),
        encryption: z.enum(["WPA", "WEP", "nopass"]).optional().describe("Encryption type."),
        hidden: z.boolean().optional().describe("Whether the network is hidden."),
        label: z.string().optional().describe("Update the label."),
      }),
      handler: async (input: Record<string, unknown>) => {
        const { short_id, label, ...wifiFields } = input;
        const body: Record<string, unknown> = { wifi_data: wifiFields };
        if (label !== undefined) body.label = label;
        return apiRequest(`/api/qr/${short_id}`, { method: "PATCH", body });
      },
    },
  • Input schema for update_wifi_qr using zod: requires short_id, optional ssid, password, encryption (enum: WPA/WEP/nopass), hidden (boolean), and label.
    update_wifi_qr: {
      description:
        "Update the WiFi credentials of a WiFi QR code. Only works on QR codes created with type='wifi'. Note: updating WiFi data changes the QR image content.",
      inputSchema: z.object({
        short_id: z.string().describe("The short ID of the WiFi QR code to update."),
        ssid: z.string().optional().describe("WiFi network name."),
        password: z.string().optional().describe("WiFi password."),
        encryption: z.enum(["WPA", "WEP", "nopass"]).optional().describe("Encryption type."),
        hidden: z.boolean().optional().describe("Whether the network is hidden."),
        label: z.string().optional().describe("Update the label."),
      }),
  • The tool is registered as part of the 'tools' export object in tools.ts. It is then dynamically registered in server.ts which iterates over all tool entries and calls server.tool().
    update_wifi_qr: {
      description:
        "Update the WiFi credentials of a WiFi QR code. Only works on QR codes created with type='wifi'. Note: updating WiFi data changes the QR image content.",
      inputSchema: z.object({
        short_id: z.string().describe("The short ID of the WiFi QR code to update."),
        ssid: z.string().optional().describe("WiFi network name."),
        password: z.string().optional().describe("WiFi password."),
        encryption: z.enum(["WPA", "WEP", "nopass"]).optional().describe("Encryption type."),
        hidden: z.boolean().optional().describe("Whether the network is hidden."),
        label: z.string().optional().describe("Update the label."),
      }),
      handler: async (input: Record<string, unknown>) => {
        const { short_id, label, ...wifiFields } = input;
        const body: Record<string, unknown> = { wifi_data: wifiFields };
        if (label !== undefined) body.label = label;
        return apiRequest(`/api/qr/${short_id}`, { method: "PATCH", body });
      },
    },
  • The apiRequest helper function used by the handler to make HTTP requests to the backend API with proper headers (X-API-Key) 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();
    }
  • Dynamic registration of all tools (including update_wifi_qr) via the MCP SDK's server.tool() method, binding the name, description, schema, and 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,
            };
          }
        }
      );
Behavior3/5

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

No annotations are provided, so the description carries the burden. It discloses that updating WiFi data changes the QR image content, which adds value beyond a simple 'update' statement. However, it does not mention permissions, reversibility, or other side effects.

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, front-loaded with purpose and a key constraint. Every word earns its place; no redundancy.

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 and no annotations. The description is brief: it covers purpose and a behavioral note but lacks return value description, error handling, or guidance on parameter interactions. Adequate for a simple update, but minimal.

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 description coverage is 100%, and the description adds no additional parameter-level meaning beyond what the schema already provides. Baseline score of 3 is appropriate.

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 clearly states the verb 'Update', the resource 'WiFi QR code', and a constraint 'Only works on QR codes created with type='wifi''. This distinguishes it from sibling tools like create_wifi_qr or update_qr_destination.

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?

Explicitly states the precondition that the QR code must have type='wifi', which guides when to use. Does not list alternatives or when not to use, but the constraint is clear.

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