create_phone_qr
Generate a QR code that dials a phone number when scanned. Customize colors, dot styles, logo, and frame with optional call-to-action text. Output SVG or PNG.
Instructions
Create a QR code that initiates a phone call when scanned. The phone number is encoded directly in the QR code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| phone_number | Yes | Phone number to call. | |
| 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:464-470 (handler)Handler function for create_phone_qr that extracts phone_number and calls the API route /api/qr with type 'phone' and phone_data.
handler: async (input: Record<string, unknown>) => { const { phone_number, ...rest } = input; return apiRequest("/api/qr", { method: "POST", body: { type: "phone", phone_data: { phone_number }, ...rest }, }); }, - packages/mcp/src/tools.ts:450-463 (schema)Input schema for create_phone_qr using Zod. Required: phone_number. Optional: label, format, foreground_color, background_color, dot_style, corner_style, logo_url, frame_style, frame_text, frame_color, frame_text_color.
inputSchema: z.object({ phone_number: z.string().describe("Phone number to call."), 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 registers all tools (including create_phone_qr) with the MCP server via server.tool().
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:13-40 (helper)The apiRequest helper function used by create_phone_qr's handler to make HTTP POST requests to the backend API.
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(); }