MCP (Model Context Protocol) enables AI assistants to call structured external tools. Barcode Scanner MCP Server ships as QR Code AI’s MIT-licensed npm package @qrcode-ai-com/qrcode-barcode-scanner-mcp. Your MCP host (such as Cursor, OpenClaw, Goose or Continue) spawns it locally and communicates over stdio (standard input and output). By default it exposes scan_image for image bytes, with scan_file available as an opt-in tool. Your assistant gets direct decoder output rather than guessing visually.
Register the server in your MCP host
Place this snippet inside your host’s MCP config file. npx fetches the npm package on the first launch and caches it locally afterwards. Requires Node.js 22.19+ on the 22 branch, or Node.js 24+.
12345678
{
"mcpServers": {
"qrscan": {
"command": "npx",
"args": ["--yes", "--ignore-scripts", "@qrcode-ai-com/qrcode-barcode-scanner-mcp"]
}
}
}
Most desktop and IDE hosts adopt the mcpServers JSON schema. Put this block into your client’s active config path and confirm scan_image appears in its tool list. Cursor and similar clients accept it as shown; on Windows, certain hosts require invoking npx via cmd. Check the Barcode Scanner Integrations directory for client-specific setups.
Refer to the MCP architecture overview to see how host, client and server roles fit together.
The same MCP server decodes QR codes as well: see the QR Code Scanner MCP Server guide.
Keep a pinned local install
If you want an audited local copy that never reaches out to npm at startup, install the package inside a project folder and configure absolute paths in your host.
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"]
}
}
}
Do not move the install directory afterwards, because your host points directly to its absolute path.
Enable file-path scanning (optional)
Out of the box, the server accepts image bytes only and rejects file paths or URLs. To let it read local images by path, opt into the second tool, scan_file, by setting the QRSCAN_MCP_ALLOWED_DIRECTORIES environment variable to the specific directories it may access.
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 builds on “Keep a pinned local install” by adding an env block. Separate multiple folders just like PATH: colons on macOS and Linux, semicolons on Windows.
scan_file expects the absolute path to one image inside an allowed folder and outputs the identical report format as scan_image, accepting the same optional profile and budgetMs fields explained below.
Prompt your assistant to decode a barcode
You do not invoke the tool manually: your assistant handles the call. For example, ask: “Decode the barcode in inventory-label.png and return its exact value and format.” Assistants that pass file paths instead of image bytes need scan_file enabled as shown above.
The assistant sends imageBase64 (canonical base64 of the image bytes without whitespace or a data-URL prefix), an optional profile (fast by default, or frame / full) and an optional budgetMs time budget in milliseconds (0 removes the limit).
1
{ "imageBase64": "<canonical base64 image>", "profile": "full", "budgetMs": 0 }
On inventory-label.png (a Code 128 label), the report contains STOCK-4827 along with its symbology inside structuredContent on the MCP tool response.
When an image also holds a QR code, QR entries appear first in the detections array, so inspect the symbology of each item.
To generate a test file yourself, create a test barcode with Barcode Generator using Code 128 and STOCK-4827, save the PNG as inventory-label.png and let your host pass its bytes to the tool.
Consult the MCP reference for both tools, size caps and error codes.
Expected output
The example above targets your own label. As a verifiable baseline, here is the first detection returned for the public EAN-13 sample image:
1234567891011121314151617181920
{
"symbology": "ean13",
"content": {
"text": "9506000134352",
"raw": "OTUwNjAwMDEzNDM1Mg==",
"charset": "utf8"
},
"payload": {
"kind": "gs1",
"elements": [
{
"ai": "01",
"value": "09506000134352"
}
],
"gtin": "09506000134352",
"conformant": true,
"issues": []
}
}
Here symbology names the detected barcode format, content.text holds the exact encoded digits and payload gives the parsed GS1 reading: Application Identifier 01 ("ai": "01") with the same code expressed as a 14-digit GTIN including its leading zero.
The scanner’s published sample report shows the exact same detection structure.