MCP (Model Context Protocol) lets an AI assistant call external tools reliably. Barcode Scanner MCP Server is QR Code AI’s MIT-licensed npm package @qrcode-ai-com/qrcode-barcode-scanner-mcp. Your assistant host (such as Cursor, OpenClaw, Goose or Continue) spawns it locally over standard input and output (stdio). By default it exposes scan_image for base64 bytes, with an optional scan_file tool for local paths, delivering exact decoder output rather than visual guesswork.
Register the server in your MCP host
Add this block to your host’s MCP settings. npx fetches the published package on first launch and reuses it afterwards. Requires Node.js 22.19+ on the 22 release line, or Node.js 24+.
12345678
{
"mcpServers": {
"qrscan": {
"command": "npx",
"args": ["--yes", "--ignore-scripts", "@qrcode-ai-com/qrcode-barcode-scanner-mcp"]
}
}
}
Most desktop and editor hosts accept the mcpServers JSON shape. Place it in your host’s config file and confirm scan_image appears. On Windows, some hosts need to launch npx via cmd. Check the Barcode Scanner Integrations directory for client-specific configs.
See the MCP architecture documentation for how host, client and server roles fit together.
The same MCP server also decodes QR codes: check the QR Code Scanner MCP Server guide.
Install a pinned local copy
To run an audited local copy that never touches npm at startup, install the package inside your workspace and point your host config at its absolute paths.
1
npm install --prefix ./.qrscan-mcp --ignore-scripts @qrcode-ai-com/qrcode-barcode-scanner-mcp
{
"mcpServers": {
"qrscan": {
"command": "/absolute/path/to/node",
"args": ["/absolute/path/to/.qrscan-mcp/node_modules/@qrcode-ai-com/qrcode-barcode-scanner-mcp/src/cli.mjs"]
}
}
}
Leave the install folder in place because your host config references its absolute path.
Allow reading local files by path
By default the server accepts raw image bytes only, never file paths or URLs. A second optional tool, scan_file, decodes one image by absolute path. It stays disabled until the operator configures QRSCAN_MCP_ALLOWED_DIRECTORIES with the exact directories permitted for reading.
123456789
{
"mcpServers": {
"qrscan": {
"command": "/absolute/path/to/node",
"args": ["/absolute/path/to/.qrscan-mcp/node_modules/@qrcode-ai-com/qrcode-barcode-scanner-mcp/src/cli.mjs"],
"env": { "QRSCAN_MCP_ALLOWED_DIRECTORIES": "/absolute/path/to/images" }
}
}
}
This extends the “Install a pinned local copy” entry with an env block. Separate multiple folders just like PATH: colons on macOS and Linux, semicolons on Windows.
scan_file takes the absolute path to one image inside an allowed folder and outputs the identical report format as scan_image, with the same optional profile and budgetMs arguments.
Prompt your assistant to decode a barcode
Your assistant calls scan_image on your behalf rather than asking you to type JSON. For instance, ask: “Read the barcode in inventory-label.png and give me its exact value and format.” Assistants passing file paths instead of image bytes require scan_file enabled above.
The assistant invokes scan_image with imageBase64 (canonical base64 bytes with no whitespace or data-URL prefix), an optional profile (fast by default, or frame or full) and an optional budgetMs time limit in milliseconds where 0 removes the cap.
1
{ "imageBase64": "<canonical base64 image>", "profile": "full", "budgetMs": 0 }
For inventory-label.png, a Code 128 label, the report returns STOCK-4827 alongside its symbology inside structuredContent on the tool response.
If an image also includes a QR code, the report places QR codes ahead of barcodes, so inspect every detection’s symbology.
Need a test label? Create a test barcode with Barcode Generator using Code 128 and STOCK-4827, save it as inventory-label.png and pass its bytes through your host.
Read the MCP integration reference for both tools, file limits and error codes.
Expected output
To compare against your own label, here is the first detection returned for the public EAN-13 sample label:
1234567891011121314151617181920
{
"symbology": "ean13",
"content": {
"text": "9506000134352",
"raw": "OTUwNjAwMDEzNDM1Mg==",
"charset": "utf8"
},
"payload": {
"kind": "gs1",
"elements": [
{
"ai": "01",
"value": "09506000134352"
}
],
"gtin": "09506000134352",
"conformant": true,
"issues": []
}
}
symbology names the detected format, content.text preserves the digits exactly as encoded and payload gives their GS1 interpretation: Application Identifier 01 ("ai": "01") formatted as a 14-digit GTIN with its leading zero intact.
This excerpt matches the scanner’s published EAN-13 example report.