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
| Name | Required | Description | Default |
|---|---|---|---|
| short_id | Yes | The short ID of the WiFi QR code to update. | |
| ssid | No | WiFi network name. | |
| password | No | WiFi password. | |
| encryption | No | Encryption type. | |
| hidden | No | Whether the network is hidden. | |
| label | No | Update the label. |
Implementation Reference
- packages/mcp/src/tools.ts:371-388 (handler)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 }); }, }, - packages/mcp/src/tools.ts:371-381 (schema)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."), }), - packages/mcp/src/tools.ts:371-388 (registration)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 }); }, }, - packages/mcp/src/api-client.ts:13-40 (helper)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(); } - packages/mcp/src/server.ts:21-53 (registration)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, }; } } );