MCP (Model Context Protocol) lets an AI assistant call external tools. The Barcode Scanner MCP Server is QR Code AI’s MIT-licensed npm package @qrcode-ai-com/qrcode-barcode-scanner-mcp. Your assistant app (the MCP host, such as Cursor, OpenClaw, Goose or Continue) launches it as a local process on your machine and communicates over standard input and output (stdio). By default it exposes a single tool, scan_image; a second tool, scan_file, is optional and disabled by default. Your assistant receives a real decoder result rather than relying on its own visual guess.
Add the server to your MCP host
Add this entry to your host’s MCP configuration. On first launch, npx fetches the published server package and reuses that cached copy afterwards. Requires Node.js 22.19 or later on the 22 release line, or Node.js 24 or later.
12345678
{
"mcpServers": {
"qrscan": {
"command": "npx",
"args": ["--yes", "--ignore-scripts", "@qrcode-ai-com/qrcode-barcode-scanner-mcp"]
}
}
}
The mcpServers structure is a widely used client convention. Place this entry in your host’s configuration file, then verify that scan_image appears in its tool list. Cursor and other hosts that read an mcpServers JSON file accept this entry as shown. On Windows, some hosts need to launch npx via cmd. Browse the Barcode Scanner Integrations directory for client-specific setups.
The MCP architecture overview explains the host, client and server roles.
The same local MCP server also decodes QR codes: see the QR Code Scanner MCP Server guide.
Install a local copy
If you prefer a pinned, audited copy that never queries npm at start-up, install the server in your project and point your host to 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 installation folder where it is, as the host stores its absolute path.
Allow the server to read files by path
By default, the server accepts raw image bytes only: no file path and no URL. A second optional tool, scan_file, reads a single image file from its absolute path. It stays disabled by default and only becomes available when the person configuring the server sets the QRSCAN_MCP_ALLOWED_DIRECTORIES environment variable to the permitted folders.
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 the “Install a local copy” entry with one extra env line. Separate multiple folders in the same way as PATH: a colon on macOS and Linux, or a semicolon on Windows.
scan_file accepts the absolute path of one image inside an allowed folder and returns the same structured report as scan_image, with the same two optional arguments, profile and budgetMs, covered below.
Ask your assistant to read a barcode
You do not invoke the tool yourself: your assistant handles the call. For example, ask: “Read the barcode in inventory-label.png and give me its exact value and format.” An assistant that works from file paths rather than raw image bytes requires the optional scan_file tool shown above.
The assistant then invokes scan_image with imageBase64 (canonical base64 of the image 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 along with its format. Your assistant receives this in structuredContent, the machine-readable part of the tool response.
If the image also contains a QR code, the report lists the QR code first: check the format of each detection.
To prepare the sample image, create a test barcode with Barcode Generator using Code 128 and STOCK-4827. Save the PNG as inventory-label.png, then let your host pass its image bytes to the tool.
The MCP server reference documents both tools, the input limits and the error codes.
What you get
The prompt above decodes your own label. For a reproducible reference, 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": []
}
}
symbology is the detected format, content.text holds the digits exactly as encoded, and payload provides their parsed GS1 reading: Application Identifier 01 ("ai": "01") carrying the same number as a 14-digit GTIN, leading zero included.
The scanner’s published example report shows the same detection.