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
| Name | Required | Description | Default |
|---|---|---|---|
| ssid | Yes | WiFi network name (SSID). | |
| password | No | WiFi password. Omit for open networks (use encryption='nopass'). | |
| encryption | No | Encryption type. Default: WPA. | WPA |
| hidden | No | Whether the network is hidden. Default: false. | |
| label | No | Label for this QR code. | |
| format | No | Image format. | svg |
| foreground_color | No | Hex color for dots. | |
| background_color | No | Hex color for background. | |
| dot_style | No | Dot shape. | |
| corner_style | No | Corner shape. | |
| logo_url | No | Logo URL or data URI. | |
| frame_style | No | Frame style around QR. | |
| frame_text | No | CTA text on frame (max 30 chars). | |
| frame_color | No | Frame background color. | |
| frame_text_color | No | Frame text color. |
Implementation Reference
- packages/mcp/src/tools.ts:314-345 (handler)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, }, }); }, }, - packages/mcp/src/tools.ts:314-333 (schema)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."), }), - packages/mcp/src/server.ts:21-53 (registration)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, }; } } ); - packages/mcp/src/api-client.ts:1-40 (helper)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(); }