qr_code MCP tool: make QR codes from an AI assistant
· 6 min read
Get the devtoolbox.cc MCP serverOpen the QR Code tool
A QR code is a grid of a few hundred to tens of thousands of modules, each set by a Reed-Solomon encoder, a masking step and a placement pattern defined in ISO/IEC 18004. A language model can describe that process well and can’t perform it. Ask one to “draw a QR code” and you’ll get a picture that looks like one and doesn’t scan. To put a QR code on a slide, a poster or a test page, an assistant needs a tool that encodes it.
The devtoolbox.cc MCP server has one: qr_code. It generates the code as an SVG image, which stays sharp at any size, and can write it straight to a file. It uses the same encoder as the QR code generator on this site, where every generated code is checked by decoding it again in tests. Install instructions are on the MCP page.
What the tool does
- Encodes any text or URL, including non-Latin text and emoji, as UTF-8.
- Builds Wi-Fi network codes in the
WIFI:format that phone cameras understand, escaping special characters in the network name and password. - Lets you choose the error correction level (L, M, Q or H) and the quiet zone around the code.
- Takes custom colours and warns when they’d be hard to scan: low contrast, or light modules on a dark background.
- Returns the SVG as text, or writes it to
output_pathand reports the QR version and size.
Arguments
| Argument | Type | Meaning |
|---|---|---|
text |
string | Text or URL to encode. Use this or wifi. |
wifi |
object | ssid, password, security (WPA, WEP, nopass), hidden. |
ecc |
"L", "M", "Q", "H" |
Error correction. Default "M". |
margin |
integer 0–20 | Quiet zone in modules. Default 4. |
fg, bg |
#rrggbb |
Dark and light colours. Default black on white. |
output_path |
string | Write the SVG to this file instead of returning it. |
overwrite |
boolean | Allow replacing an existing file. Default false. |
Examples
These examples were run against the real tool, writing SVG files. A link for a conference slide:
{ "text": "https://devtoolbox.cc/mcp", "output_path": "/home/dev/slides/qr-mcp.svg" }
Wrote 2329 bytes to /home/dev/slides/qr-mcp.svg
Payload: https://devtoolbox.cc/mcp
Version 2, 25 × 25 modules
The output names the encoded payload, so the agent can confirm it encoded what you asked for, and the version: a version 2 code is 25 × 25 modules. The same link with the highest error correction, for a printed sticker that might get scratched:
{ "text": "https://devtoolbox.cc/mcp", "ecc": "H", "output_path": "/home/dev/slides/qr-mcp-h.svg" }
Wrote 3942 bytes to /home/dev/slides/qr-mcp-h.svg
Payload: https://devtoolbox.cc/mcp
Version 4, 33 × 33 modules
Higher error correction needs more modules for the same data, so the code grew from version 2 to version 4. A guest Wi-Fi code, where the network name contains a semicolon that has to be escaped:
{
"wifi": { "ssid": "Office;Guest", "password": "coffee:2026", "security": "WPA" },
"output_path": "/home/dev/print/wifi.svg"
}
Wrote 4051 bytes to /home/dev/print/wifi.svg
Payload: WIFI:T:WPA;S:Office\;Guest;P:coffee\:2026;;
Version 4, 33 × 33 modules
Both ; and : got a backslash. Without the escape, a phone would read the network name as just “Office” and fail to connect.
Brand colours are fine as long as scanners can still tell dark from light. Light grey on white isn’t:
{
"text": "https://example.com",
"fg": "#9ca3af",
"bg": "#ffffff",
"output_path": "/home/dev/print/grey.svg"
}
Wrote 2455 bytes to /home/dev/print/grey.svg
Payload: https://example.com
Version 2, 25 × 25 modules
Warning: Low contrast (2.5:1): some scanners may fail. Aim for 4:1 or more.
The file is still written; the warning tells the agent, and you, that it may not scan reliably. The tool doesn’t overwrite files unless told to:
{ "text": "https://example.com/v2", "output_path": "/home/dev/print/grey.svg" }
Cannot write /home/dev/print/grey.svg: EEXIST: file already exists, open '/home/dev/print/grey.svg' (set "overwrite": true to replace it)
Printing
A few rules make the difference between a code that scans at once and one that doesn’t:
- Keep the quiet zone. The standard asks for an empty margin of 4 modules, which is the tool’s default. Text or graphics touching the code are a common reason for failed scans.
- Size it for the distance. A common rule of thumb is a scanning distance of about ten times the code’s width, so a code read from 50 cm should be around 5 cm wide.
- Prefer dark modules on a light background with strong contrast. The tool warns below 4:1 and about inverted colours.
- Use the SVG for print. It’s vector graphics, so it stays sharp at any size, unlike a small PNG that’s been scaled up.
Test the printed proof with two or three phones before ordering a thousand copies.
Things to ask your assistant
- “Make a QR code for our guest Wi-Fi, SSID
Studio 5G, password inwifi.txt, and save it aswifi.svg.” - “Add a QR code linking to the repository to the last slide of
talk.md.” - “Generate QR codes for each URL in
tickets.csv, named after the ticket ID.” - “Make a QR code in our brand colour
#4f46e5and tell me if it’s scannable.”
When the content is a URL with query parameters, the parameters have to be encoded properly before they go into the code. The URL encoder on this site, or the url tool of the same MCP server, handles that. To design a code by hand with a live preview and PNG download, use the QR code generator.
Static codes, no tracking
The codes contain your content directly. There’s no redirect service in between, so they keep working as long as the link they point to works, and nobody counts the scans. The Wi-Fi password is encoded into the image you create and nowhere else.
Install
qr_code is part of the devtoolbox.cc MCP server, which runs locally without network access. Setup for Claude Desktop, Claude Code, Cursor and VS Code is on the MCP install page.