generate-qrcode-terminal
Generate QR codes from text or URLs and display them directly in your terminal. This tool converts input data into terminal-formatted QR codes for quick scanning and sharing.
Instructions
Generate a QR code from text or URL and display it in terminal format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| options | No | Terminal display options | |
| text | Yes | The text or URL to encode in the QR code |
Implementation Reference
- src/index.ts:151-177 (handler)Handler function that generates QR code in terminal format using QRCode.toString(type: 'terminal') and returns it as text content.async ({ text, options = {} }) => { try { const terminalQR = await QRCode.toString(text, { type: 'terminal', small: options.small || false }); return { content: [ { type: "text", text: `QR code for: "${text}"\n\n${terminalQR}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error generating terminal QR code: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- src/index.ts:144-149 (schema)Zod input schema for the tool, requiring text and optional options with small boolean flag.inputSchema: { text: z.string().min(1).describe("The text or URL to encode in the QR code"), options: z.object({ small: z.boolean().optional().default(false).describe("Use small format for terminal display") }).optional().describe("Terminal display options") }
- src/index.ts:139-178 (registration)Registration of the 'generate-qrcode-terminal' tool using server.registerTool, including title, description, schema, and handler reference.server.registerTool( "generate-qrcode-terminal", { title: "Generate QR Code for Terminal", description: "Generate a QR code from text or URL and display it in terminal format", inputSchema: { text: z.string().min(1).describe("The text or URL to encode in the QR code"), options: z.object({ small: z.boolean().optional().default(false).describe("Use small format for terminal display") }).optional().describe("Terminal display options") } }, async ({ text, options = {} }) => { try { const terminalQR = await QRCode.toString(text, { type: 'terminal', small: options.small || false }); return { content: [ { type: "text", text: `QR code for: "${text}"\n\n${terminalQR}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error generating terminal QR code: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } );