qrcode-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qrcode_mcp-0.1.0/LICENSE +21 -0
- qrcode_mcp-0.1.0/PKG-INFO +417 -0
- qrcode_mcp-0.1.0/README.md +339 -0
- qrcode_mcp-0.1.0/pyproject.toml +98 -0
- qrcode_mcp-0.1.0/setup.cfg +4 -0
- qrcode_mcp-0.1.0/src/qrcode_mcp.egg-info/PKG-INFO +417 -0
- qrcode_mcp-0.1.0/src/qrcode_mcp.egg-info/SOURCES.txt +34 -0
- qrcode_mcp-0.1.0/src/qrcode_mcp.egg-info/dependency_links.txt +1 -0
- qrcode_mcp-0.1.0/src/qrcode_mcp.egg-info/entry_points.txt +2 -0
- qrcode_mcp-0.1.0/src/qrcode_mcp.egg-info/requires.txt +53 -0
- qrcode_mcp-0.1.0/src/qrcode_mcp.egg-info/top_level.txt +1 -0
- qrcode_mcp-0.1.0/src/qrmcp/__init__.py +7 -0
- qrcode_mcp-0.1.0/src/qrmcp/__main__.py +6 -0
- qrcode_mcp-0.1.0/src/qrmcp/app.py +51 -0
- qrcode_mcp-0.1.0/src/qrmcp/cli.py +53 -0
- qrcode_mcp-0.1.0/src/qrmcp/errors.py +55 -0
- qrcode_mcp-0.1.0/src/qrmcp/protocol.py +127 -0
- qrcode_mcp-0.1.0/src/qrmcp/py.typed +0 -0
- qrcode_mcp-0.1.0/src/qrmcp/registry.py +156 -0
- qrcode_mcp-0.1.0/src/qrmcp/security.py +170 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/__init__.py +7 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/batch.py +80 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/decode.py +248 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/detect.py +105 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/generate.py +120 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/health.py +55 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/imaging.py +223 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/ocr.py +314 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/opener.py +85 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/parse.py +129 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/qrspec.py +408 -0
- qrcode_mcp-0.1.0/src/qrmcp/tools/repair.py +791 -0
- qrcode_mcp-0.1.0/src/qrmcp/transports/__init__.py +19 -0
- qrcode_mcp-0.1.0/src/qrmcp/transports/http.py +158 -0
- qrcode_mcp-0.1.0/src/qrmcp/transports/sse.py +172 -0
- qrcode_mcp-0.1.0/src/qrmcp/transports/stdio.py +38 -0
qrcode_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 qrmcp contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qrcode-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for QR decoding (including damaged-code repair), generation, URL routing and pluggable OCR
|
|
5
|
+
Author: qrmcp contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/xiaobinger/qrcode-mcp
|
|
8
|
+
Project-URL: Repository, https://github.com/xiaobinger/qrcode-mcp
|
|
9
|
+
Project-URL: Issues, https://github.com/xiaobinger/qrcode-mcp/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/xiaobinger/qrcode-mcp#readme
|
|
11
|
+
Keywords: mcp,model-context-protocol,mcp-server,qrcode,qr-code,qr-decoder,qr-code-generator,qr-code-scanner,ocr,computer-vision,reed-solomon,error-correction,image-processing,zxing,segno,winrt,rapidocr,json-rpc,claude-desktop
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Natural Language :: English
|
|
23
|
+
Classifier: Natural Language :: Chinese (Simplified)
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
27
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
28
|
+
Requires-Python: >=3.10
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Requires-Dist: numpy>=1.23
|
|
32
|
+
Requires-Dist: Pillow>=9.5
|
|
33
|
+
Requires-Dist: zxing-cpp>=2.0
|
|
34
|
+
Requires-Dist: segno>=1.5
|
|
35
|
+
Requires-Dist: reedsolo>=1.7
|
|
36
|
+
Provides-Extra: vision
|
|
37
|
+
Requires-Dist: opencv-python>=4.8; extra == "vision"
|
|
38
|
+
Requires-Dist: pyzbar>=0.1.9; extra == "vision"
|
|
39
|
+
Provides-Extra: ocr-windows
|
|
40
|
+
Requires-Dist: winrt-runtime>=3.0; extra == "ocr-windows"
|
|
41
|
+
Requires-Dist: winrt-Windows.Media.Ocr>=3.0; extra == "ocr-windows"
|
|
42
|
+
Requires-Dist: winrt-Windows.Graphics.Imaging>=3.0; extra == "ocr-windows"
|
|
43
|
+
Requires-Dist: winrt-Windows.Storage>=3.0; extra == "ocr-windows"
|
|
44
|
+
Requires-Dist: winrt-Windows.Storage.Streams>=3.0; extra == "ocr-windows"
|
|
45
|
+
Requires-Dist: winrt-Windows.Globalization>=3.0; extra == "ocr-windows"
|
|
46
|
+
Requires-Dist: winrt-Windows.Foundation.Collections>=3.0; extra == "ocr-windows"
|
|
47
|
+
Provides-Extra: ocr-rapid
|
|
48
|
+
Requires-Dist: rapidocr_onnxruntime>=1.3; extra == "ocr-rapid"
|
|
49
|
+
Provides-Extra: ocr-tesseract
|
|
50
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "ocr-tesseract"
|
|
51
|
+
Provides-Extra: ocr
|
|
52
|
+
Requires-Dist: winrt-runtime>=3.0; extra == "ocr"
|
|
53
|
+
Requires-Dist: winrt-Windows.Media.Ocr>=3.0; extra == "ocr"
|
|
54
|
+
Requires-Dist: winrt-Windows.Graphics.Imaging>=3.0; extra == "ocr"
|
|
55
|
+
Requires-Dist: winrt-Windows.Storage>=3.0; extra == "ocr"
|
|
56
|
+
Requires-Dist: winrt-Windows.Storage.Streams>=3.0; extra == "ocr"
|
|
57
|
+
Requires-Dist: winrt-Windows.Globalization>=3.0; extra == "ocr"
|
|
58
|
+
Requires-Dist: winrt-Windows.Foundation.Collections>=3.0; extra == "ocr"
|
|
59
|
+
Requires-Dist: rapidocr_onnxruntime>=1.3; extra == "ocr"
|
|
60
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "ocr"
|
|
61
|
+
Provides-Extra: full
|
|
62
|
+
Requires-Dist: opencv-python>=4.8; extra == "full"
|
|
63
|
+
Requires-Dist: pyzbar>=0.1.9; extra == "full"
|
|
64
|
+
Requires-Dist: winrt-runtime>=3.0; extra == "full"
|
|
65
|
+
Requires-Dist: winrt-Windows.Media.Ocr>=3.0; extra == "full"
|
|
66
|
+
Requires-Dist: winrt-Windows.Graphics.Imaging>=3.0; extra == "full"
|
|
67
|
+
Requires-Dist: winrt-Windows.Storage>=3.0; extra == "full"
|
|
68
|
+
Requires-Dist: winrt-Windows.Storage.Streams>=3.0; extra == "full"
|
|
69
|
+
Requires-Dist: winrt-Windows.Globalization>=3.0; extra == "full"
|
|
70
|
+
Requires-Dist: winrt-Windows.Foundation.Collections>=3.0; extra == "full"
|
|
71
|
+
Requires-Dist: rapidocr_onnxruntime>=1.3; extra == "full"
|
|
72
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "full"
|
|
73
|
+
Provides-Extra: dev
|
|
74
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
75
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
76
|
+
Requires-Dist: twine>=4.0; extra == "dev"
|
|
77
|
+
Dynamic: license-file
|
|
78
|
+
|
|
79
|
+
<p align="center">
|
|
80
|
+
<picture>
|
|
81
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.png">
|
|
82
|
+
<img src="assets/logo-light.png" alt="qrcode-mcp" width="560">
|
|
83
|
+
</picture>
|
|
84
|
+
</p>
|
|
85
|
+
|
|
86
|
+
<p align="center">
|
|
87
|
+
<strong>Decode. Repair. Generate. Route safely. Read any text.</strong><br/>
|
|
88
|
+
A local MCP server that gives any MCP client real QR + OCR capabilities —<br/>
|
|
89
|
+
including the damaged codes that ordinary scanners give up on.
|
|
90
|
+
</p>
|
|
91
|
+
|
|
92
|
+
<p align="center">
|
|
93
|
+
<a href="README.zh-CN.md">简体中文</a> ·
|
|
94
|
+
<a href="#quick-start">Quick start</a> ·
|
|
95
|
+
<a href="#usage-in-mcp-clients">Client setup</a> ·
|
|
96
|
+
<a href="#tools">Tools</a> ·
|
|
97
|
+
<a href="#damaged-code-repair">Repair</a> ·
|
|
98
|
+
<a href="https://modelcontextprotocol.io/">MCP spec</a>
|
|
99
|
+
</p>
|
|
100
|
+
|
|
101
|
+
<p align="center">
|
|
102
|
+
<a href="pyproject.toml"><img alt="version 0.1.0" src="https://img.shields.io/badge/version-0.1.0-4F46E5?style=flat-square"></a>
|
|
103
|
+
<a href="pyproject.toml"><img alt="Python 3.10-3.13" src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-3776AB?style=flat-square&logo=python&logoColor=white"></a>
|
|
104
|
+
<a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/badge/license-MIT-0F766E?style=flat-square&logo=opensourceinitiative&logoColor=white"></a>
|
|
105
|
+
<a href="#protocol-support"><img alt="MCP 2025-06-18" src="https://img.shields.io/badge/MCP-2025--06--18-6D28D9?style=flat-square"></a>
|
|
106
|
+
<a href="#quick-start"><img alt="beta" src="https://img.shields.io/badge/status-beta-D97706?style=flat-square"></a>
|
|
107
|
+
</p>
|
|
108
|
+
|
|
109
|
+
<p align="center">
|
|
110
|
+
<a href="tests/selftest.py"><img alt="self-test 38/38" src="https://img.shields.io/badge/self--test-38%2F38%20passing-16A34A?style=flat-square&logo=githubactions&logoColor=white"></a>
|
|
111
|
+
<a href="#tools"><img alt="9 tools" src="https://img.shields.io/badge/tools-9-2563EB?style=flat-square"></a>
|
|
112
|
+
<a href="#transports"><img alt="stdio | HTTP | SSE" src="https://img.shields.io/badge/transports-stdio%20%7C%20HTTP%20%7C%20SSE-334155?style=flat-square"></a>
|
|
113
|
+
<a href="#safety-by-default"><img alt="offline by default" src="https://img.shields.io/badge/network-offline%20by%20default-0891B2?style=flat-square"></a>
|
|
114
|
+
<a href="CONTRIBUTING.md"><img alt="PRs welcome" src="https://img.shields.io/badge/PRs-welcome-16A34A?style=flat-square&logo=github&logoColor=white"></a>
|
|
115
|
+
</p>
|
|
116
|
+
|
|
117
|
+
<p align="center">
|
|
118
|
+
<img alt="zxing-cpp" src="https://img.shields.io/badge/-zxing--cpp-1E293B?style=flat-square">
|
|
119
|
+
<img alt="segno" src="https://img.shields.io/badge/-segno-0F766E?style=flat-square">
|
|
120
|
+
<img alt="Reed-Solomon" src="https://img.shields.io/badge/-Reed--Solomon-0891B2?style=flat-square">
|
|
121
|
+
<img alt="OpenCV" src="https://img.shields.io/badge/-OpenCV-5C3EE8?style=flat-square">
|
|
122
|
+
<img alt="WinRT OCR" src="https://img.shields.io/badge/-WinRT%20OCR-0078D4?style=flat-square">
|
|
123
|
+
<img alt="RapidOCR" src="https://img.shields.io/badge/-RapidOCR-BE123C?style=flat-square">
|
|
124
|
+
<img alt="JSON-RPC 2.0" src="https://img.shields.io/badge/-JSON--RPC%202.0-475569?style=flat-square">
|
|
125
|
+
</p>
|
|
126
|
+
|
|
127
|
+
> [!NOTE]
|
|
128
|
+
> Run it from source (`pip install -e .`) or, once available on PyPI,
|
|
129
|
+
> `pip install qrcode-mcp` / `uvx qrcode-mcp`. Either way the client setup is
|
|
130
|
+
> the same — see [Usage in MCP clients](#usage-in-mcp-clients).
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Why this exists
|
|
135
|
+
|
|
136
|
+
Every QR decoder assumes a reasonably clean symbol. Real-world captures — a
|
|
137
|
+
phone pointed at a glossy screen, a payment terminal under ceiling lights —
|
|
138
|
+
come back with a diagonal glare band that erases a dozen modules. zxing, OpenCV
|
|
139
|
+
and ZBar all return a checksum error. That is where this server starts working.
|
|
140
|
+
|
|
141
|
+
<table>
|
|
142
|
+
<tr>
|
|
143
|
+
<th align="center">What the scanner saw</th>
|
|
144
|
+
<th align="center">What <code>qr_repair</code> recovered</th>
|
|
145
|
+
</tr>
|
|
146
|
+
<tr>
|
|
147
|
+
<td align="center"><img src="assets/demo-before.jpg" alt="glare-damaged QR code" width="260"></td>
|
|
148
|
+
<td align="center"><img src="assets/demo-after.png" alt="rebuilt scannable QR code" width="260"></td>
|
|
149
|
+
</tr>
|
|
150
|
+
<tr>
|
|
151
|
+
<td align="center"><sub>zxing / OpenCV / ZBar → <b>checksum error</b></sub></td>
|
|
152
|
+
<td align="center"><sub>module grid fitted, payload rebuilt, <b>scannable PNG</b></sub></td>
|
|
153
|
+
</tr>
|
|
154
|
+
</table>
|
|
155
|
+
|
|
156
|
+
<sub>The demo pair is synthetic and contains no real device identifiers.
|
|
157
|
+
Regenerate it with <code>python assets/build_assets.py</code>.</sub>
|
|
158
|
+
|
|
159
|
+
On the real glare-damaged sample this project was built from: grid fitting
|
|
160
|
+
landed on **Version 3 / pitch 2.948 px / 99.2% function-pattern agreement**,
|
|
161
|
+
format information resolved to **EC-L / mask 6**, and hint verification reached
|
|
162
|
+
**93.6% module agreement** with the reconstructed symbol.
|
|
163
|
+
|
|
164
|
+
## Features
|
|
165
|
+
|
|
166
|
+
| | |
|
|
167
|
+
| --- | --- |
|
|
168
|
+
| 🔍 **Layered decoding** | zxing-cpp → OpenCV → ZBar → preprocessing variants → automatic repair fallback. Multi-code images, corner points, confidence and payload parsing. |
|
|
169
|
+
| 🩺 **Damaged-code repair** | Module-grid fitting, format-information decoding, multi-segment parsing, Reed–Solomon erasure / Chase correction, then module-by-module self-verification. |
|
|
170
|
+
| 🎨 **Generation** | `segno`-based, EC / version / mask / scale / border / colors, PNG · SVG · ASCII · base64, optional file output. |
|
|
171
|
+
| 🧠 **Pluggable OCR** | Windows built-in WinRT OCR, RapidOCR (offline ONNX) and Tesseract, with `auto` fallback and word-level boxes. |
|
|
172
|
+
| 🔐 **Safe by default** | URL opening requires explicit confirmation, blocks dangerous schemes and private hosts, remote image fetching disabled, output confined to one directory. |
|
|
173
|
+
| 🔌 **Three transports** | `stdio`, Streamable HTTP and legacy SSE over a pure-standard-library JSON-RPC 2.0 core — no MCP SDK, no port unless you ask for one. |
|
|
174
|
+
|
|
175
|
+
## Quick start
|
|
176
|
+
|
|
177
|
+
**From source** (works today):
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
git clone https://github.com/xiaobinger/qrcode-mcp
|
|
181
|
+
cd qrcode-mcp
|
|
182
|
+
python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
183
|
+
pip install -e . # core dependencies
|
|
184
|
+
pip install -e '.[full]' # optional: OpenCV, ZBar, all OCR backends
|
|
185
|
+
qrmcp --version
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**From the package** (once `qrcode-mcp` is installed from PyPI):
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
pip install qrcode-mcp # or: pip install 'qrcode-mcp[full]'
|
|
192
|
+
uvx qrcode-mcp qrmcp --version # no install, on-demand
|
|
193
|
+
qrmcp --transport stdio
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
| Extra | What it adds |
|
|
197
|
+
| --- | --- |
|
|
198
|
+
| *(core)* | `numpy`, `Pillow`, `zxing-cpp`, `segno`, `reedsolo` — decode / repair / generate / parse / open / health |
|
|
199
|
+
| `vision` | `opencv-python`, `pyzbar` — extra decode & detection engines |
|
|
200
|
+
| `ocr-windows` | Windows 10+ built-in OCR, `zh-Hans-CN` recognizer, word boxes, no model download |
|
|
201
|
+
| `ocr-rapid` | `rapidocr_onnxruntime` — offline Chinese + English ONNX models |
|
|
202
|
+
| `ocr-tesseract` | `pytesseract` — needs the `tesseract` binary and traineddata |
|
|
203
|
+
| `ocr` / `full` | all OCR backends / everything above |
|
|
204
|
+
| `dev` | `pytest`, `build`, `twine` |
|
|
205
|
+
|
|
206
|
+
## Usage in MCP clients
|
|
207
|
+
|
|
208
|
+
`mcp.entry.json` in this repository is a ready-to-paste stdio fragment. Drop it
|
|
209
|
+
into the `mcpServers` object of your client and restart it.
|
|
210
|
+
|
|
211
|
+
| Client | Where to put the config | Notes |
|
|
212
|
+
| --- | --- | --- |
|
|
213
|
+
| **WorkBuddy** | `~/.workbuddy/mcp.json` → `mcpServers` | Trust the new server once in the connector panel |
|
|
214
|
+
| **Claude Desktop** | `claude_desktop_config.json` (`%APPDATA%\Claude\` on Windows, `~/Library/Application Support/Claude/` on macOS) | Fully restart the app |
|
|
215
|
+
| **Cursor** | `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global) | Project scope is per-repository |
|
|
216
|
+
| **VS Code / Copilot** | `.vscode/mcp.json` | Uses the `servers` key; wrap the snippet accordingly |
|
|
217
|
+
| **Cline / Roo Code** | Extension settings → MCP Servers | Paste the JSON body |
|
|
218
|
+
| **Cherry Studio / Continue** | Settings → MCP / Tools → import JSON | Pick `stdio` as the transport |
|
|
219
|
+
| **Any MCP client** | stdio JSON below | Works with protocol `2024-11-05` … `2025-06-18` |
|
|
220
|
+
|
|
221
|
+
**From a local checkout** — point `command` at the venv interpreter (or set
|
|
222
|
+
`PYTHONPATH` to `src`):
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"mcpServers": {
|
|
227
|
+
"qrcode_mcp": {
|
|
228
|
+
"command": "python",
|
|
229
|
+
"args": ["-m", "qrmcp", "--transport", "stdio"],
|
|
230
|
+
"env": { "PYTHONIOENCODING": "utf-8", "PYTHONPATH": "C:/path/to/qrcode-mcp/src" }
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**From an installed package** — use the console script:
|
|
237
|
+
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"mcpServers": {
|
|
241
|
+
"qrcode_mcp": {
|
|
242
|
+
"command": "qrmcp",
|
|
243
|
+
"args": ["--transport", "stdio"],
|
|
244
|
+
"env": { "PYTHONIOENCODING": "utf-8" }
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**On-demand, no install** (uv):
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"mcpServers": {
|
|
255
|
+
"qrcode_mcp": {
|
|
256
|
+
"command": "uvx",
|
|
257
|
+
"args": ["--from", "qrcode-mcp", "qrmcp", "--transport", "stdio"]
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Shared / HTTP clients** — start one server, point several clients at it:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
qrmcp --transport http --port 8765 --token "$QRMCP_HTTP_TOKEN"
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"mcpServers": {
|
|
272
|
+
"qrcode_mcp": { "type": "http", "url": "http://127.0.0.1:8765/mcp" }
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Then talk to your client in natural language:
|
|
278
|
+
|
|
279
|
+
> *"Decode the QR code in this screenshot — if it fails, try repairing it."*
|
|
280
|
+
> *"Generate a QR for this URL and save it under out/."*
|
|
281
|
+
> *"Read all text in this image and give me the line boxes."*
|
|
282
|
+
> *"Parse that QR link first and ask me before opening it."*
|
|
283
|
+
|
|
284
|
+
## Tools
|
|
285
|
+
|
|
286
|
+
| Tool | What it does |
|
|
287
|
+
| --- | --- |
|
|
288
|
+
| `qr_decode` | Layered decode across engines and preprocessing variants; multi-code, corner points, confidence, payload parsing; falls back to `qr_repair` |
|
|
289
|
+
| `qr_repair` | Recover glare / blur / low-resolution symbols (QR versions 1–4); returns diagnostics, verification score and a rebuilt scannable PNG |
|
|
290
|
+
| `qr_generate` | Generate QR codes with EC / version / mask / scale / border / colors; PNG · SVG · ASCII · base64 |
|
|
291
|
+
| `qr_detect` | Locate symbols without decoding — bounding boxes for cropping before repair |
|
|
292
|
+
| `qr_parse` | Interpret URL / WiFi / vCard / phone / email / payment payloads, split query parameters, flag phishing-style patterns |
|
|
293
|
+
| `qr_open` | Validate and optionally open a QR URL in the system browser |
|
|
294
|
+
| `ocr_image` | Full text, line / word boxes and confidence via the pluggable OCR backends |
|
|
295
|
+
| `qr_batch` | Batch scan a directory or file list, optionally combining QR + OCR |
|
|
296
|
+
| `server_health` | Version, protocol versions, registered tools, backend availability, active safety policy |
|
|
297
|
+
|
|
298
|
+
All image inputs accept a local path, `file://`, a `data:` URI, a bare base64
|
|
299
|
+
string, or an `http(s)` URL when explicitly enabled.
|
|
300
|
+
|
|
301
|
+
## Damaged-code repair
|
|
302
|
+
|
|
303
|
+
```mermaid
|
|
304
|
+
flowchart LR
|
|
305
|
+
A[Damaged image] --> B[Grid fitting<br/>finder patterns + quad]
|
|
306
|
+
B --> C[Format info<br/>EC level + mask]
|
|
307
|
+
C --> D[Segment parsing<br/>byte / numeric / alnum]
|
|
308
|
+
D --> E[RS erasure<br/>+ Chase search]
|
|
309
|
+
E --> F[Rebuild QR<br/>module-by-module verify]
|
|
310
|
+
F --> G[Clean scannable PNG]
|
|
311
|
+
E -. soft reading .-> H[soft_decode<br/>character candidates]
|
|
312
|
+
H -. hint= .-> F
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
When glare destroys more codewords than the EC budget can restore, the server
|
|
316
|
+
does **not** invent a result. It returns a `soft_decode` with per-character
|
|
317
|
+
candidates; pass your best guess as `hint=` to verify it and obtain a scannable
|
|
318
|
+
rebuild:
|
|
319
|
+
|
|
320
|
+
```json
|
|
321
|
+
{
|
|
322
|
+
"name": "qr_repair",
|
|
323
|
+
"arguments": {
|
|
324
|
+
"image": "screenshot.png",
|
|
325
|
+
"hint": "https://example.com/qrmcp?sn=12345678901234567890&eC=99",
|
|
326
|
+
"save_clean": true
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
<details>
|
|
332
|
+
<summary><b>Scope and known limits</b></summary>
|
|
333
|
+
|
|
334
|
+
- Single-block QR versions 1–4 (21×21 … 33×33). Larger or rotated / mirrored
|
|
335
|
+
symbols are reported as unsupported or best-effort rather than guessed.
|
|
336
|
+
- A verification agreement of ≥ 92% on reliable modules is required before a
|
|
337
|
+
reconstruction is accepted as valid.
|
|
338
|
+
- Long URLs are encoded as `byte + numeric + byte` segments: `segno` alone would
|
|
339
|
+
put them in one byte segment and overflow Version 3-L, so the verification
|
|
340
|
+
path uses a small in-house multi-segment encoder.
|
|
341
|
+
- Windows OCR needs a language pack; WinRT `StorageFile` path APIs are avoided
|
|
342
|
+
in favour of in-memory streams for Python 3.13 compatibility.
|
|
343
|
+
|
|
344
|
+
</details>
|
|
345
|
+
|
|
346
|
+
## Transports
|
|
347
|
+
|
|
348
|
+
| Transport | Command | Endpoint | Use case |
|
|
349
|
+
| --- | --- | --- | --- |
|
|
350
|
+
| `stdio` *(default)* | `qrmcp --transport stdio` | — | MCP clients launching a subprocess; no port, logs to stderr only |
|
|
351
|
+
| `http` | `qrmcp --transport http --port 8765` | `POST/GET/DELETE /mcp` + `Mcp-Session-Id` | Streamable HTTP, spec `2025-03-26`+ |
|
|
352
|
+
| `sse` | `qrmcp --transport sse --port 8765` | `GET /sse` + `POST /messages` | Legacy clients on `2024-11-05` |
|
|
353
|
+
|
|
354
|
+
HTTP/SSE bind to `127.0.0.1` by default; set `--token` or `QRMCP_HTTP_TOKEN`
|
|
355
|
+
to require a bearer token. All three share one tool registry.
|
|
356
|
+
|
|
357
|
+
## Protocol support
|
|
358
|
+
|
|
359
|
+
`2025-06-18` · `2025-03-26` · `2024-11-05`. The server echoes the client's
|
|
360
|
+
version when supported, otherwise falls back to the newest it implements.
|
|
361
|
+
Implements `initialize`, `tools/list`, `tools/call`, `ping`, batch requests and
|
|
362
|
+
graceful shutdown.
|
|
363
|
+
|
|
364
|
+
## Safety by default
|
|
365
|
+
|
|
366
|
+
- `qr_open` **never** opens a URL without `confirm=true`; without it, it only
|
|
367
|
+
validates and returns the normalized URL plus risk flags.
|
|
368
|
+
- Blocks `file:`, `javascript:`, `data:`, userinfo, non-standard schemes and
|
|
369
|
+
hosts resolving to private / loopback addresses (SSRF protection).
|
|
370
|
+
- `QRMCP_URL_ALLOWLIST` restricts allowed hosts (`*.example.com` supported).
|
|
371
|
+
- Remote image fetching is off unless `QRMCP_ALLOW_REMOTE=1`.
|
|
372
|
+
- Generated files stay inside `QRMCP_OUTPUT_DIR` (default `./out`); absolute
|
|
373
|
+
paths and `..` traversal are rejected.
|
|
374
|
+
- `QRMCP_MAX_IMAGE_BYTES`, `QRMCP_MAX_IMAGE_PIXELS` and
|
|
375
|
+
`QRMCP_DECODE_BUDGET_MS` bound resource usage.
|
|
376
|
+
|
|
377
|
+
<details>
|
|
378
|
+
<summary><b>Full environment variable reference</b></summary>
|
|
379
|
+
|
|
380
|
+
| Variable | Purpose |
|
|
381
|
+
| --- | --- |
|
|
382
|
+
| `QRMCP_OUTPUT_DIR` | Directory for generated images |
|
|
383
|
+
| `QRMCP_URL_ALLOWLIST` | Comma-separated allowed hosts for `qr_open` |
|
|
384
|
+
| `QRMCP_ALLOW_PRIVATE` | Allow private / loopback hosts |
|
|
385
|
+
| `QRMCP_ALLOW_REMOTE` | Allow fetching images over `http(s)` |
|
|
386
|
+
| `QRMCP_HTTP_TOKEN` | Bearer token for HTTP / SSE |
|
|
387
|
+
| `QRMCP_OCR_PRIORITY` | Backend order, e.g. `rapid,windows` |
|
|
388
|
+
| `QRMCP_TESSERACT_CMD` | Path to the Tesseract binary |
|
|
389
|
+
| `QRMCP_MAX_IMAGE_BYTES` / `QRMCP_MAX_IMAGE_PIXELS` | Input size caps |
|
|
390
|
+
| `QRMCP_DECODE_BUDGET_MS` | Decode time budget |
|
|
391
|
+
| `QRMCP_LOG_LEVEL` | Logging verbosity |
|
|
392
|
+
|
|
393
|
+
</details>
|
|
394
|
+
|
|
395
|
+
## Test status
|
|
396
|
+
|
|
397
|
+
| Suite | Result | Run it |
|
|
398
|
+
| --- | --- | --- |
|
|
399
|
+
| End-to-end self-test | **38 / 38 passing** | `PYTHONPATH=src python tests/selftest.py` |
|
|
400
|
+
| Portable CI smoke | **16 checks passing** | `python tests/ci_smoke.py` |
|
|
401
|
+
| Wheel build | 24 modules, `qrmcp` console script | `python -m pip wheel . --no-deps -w dist` |
|
|
402
|
+
|
|
403
|
+
The self-test covers all three protocol versions, batch requests, all nine
|
|
404
|
+
tools, the three transports end-to-end, token auth, SSE delivery, OCR backends
|
|
405
|
+
and the damaged-image repair path. CI runs on Linux + Windows across Python
|
|
406
|
+
3.10–3.13 with core dependencies only — see
|
|
407
|
+
[`.github/workflows/ci.yml`](.github/workflows/ci.yml).
|
|
408
|
+
|
|
409
|
+
## Contributing
|
|
410
|
+
|
|
411
|
+
Issues and PRs are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). The
|
|
412
|
+
shortest useful contribution is a damaged QR sample that currently fails:
|
|
413
|
+
include the image and the expected payload.
|
|
414
|
+
|
|
415
|
+
## License
|
|
416
|
+
|
|
417
|
+
[MIT](LICENSE) © qrmcp contributors
|