PaddleOCR-json MCP
by luffy666code
README.md
<div align="center">
# ๐ PaddleOCR-json MCP
**Local OCR for MCP clients, powered by PaddleOCR-json v1.4.1**
[](https://www.python.org/)
[](https://modelcontextprotocol.io/)
[](https://github.com/hiroi-sora/PaddleOCR-json/releases/tag/v1.4.1)
[](LICENSE)
[](https://github.com/luffy666code/PaddleOCR-json-MCP/actions/workflows/ci.yml)
A lightweight **Model Context Protocol (MCP)** wrapper that exposes local
PaddleOCR-json text recognition to any compatible MCP client.
**Image path ยท Base64 ยท local processing ยท reusable engine process**
</div>
---
## โจ Features
- ๐ผ๏ธ Recognize text from a local image path.
- ๐งฉ Recognize Base64 or `data:image/...;base64,...` input.
- ๐ Optionally return text boxes and confidence scores.
- โก Reuse one PaddleOCR-json process across multiple requests.
- ๐ Restart once automatically when an OCR request fails.
- ๐งน Cleanly terminate the child process when the MCP server exits.
- ๐ช Windows and ๐ง Linux runtime layouts supported by the wrapper.
- ๐ OCR runs through a local PaddleOCR-json runtime; no remote OCR API is required.
- ๐ Client-agnostic stdio MCP server โ no dependency on a specific agent platform.
## ๐งฐ MCP tools
| Tool | Purpose |
| --- | --- |
| `recognize_image` | OCR a local image file. |
| `recognize_image_base64` | OCR an image supplied as Base64. |
| `paddleocr_status` | Check engine files and current subprocess status without starting OCR. |
`recognize_image` and `recognize_image_base64` accept `include_details=true` to
include bounding boxes in the normalized result.
## ๐๏ธ How it works
```text
MCP client
โ JSON-RPC over stdio
โผ
FastMCP wrapper (main.py)
โ line-oriented JSON over stdin/stdout
โผ
PaddleOCR-json v1.4.1
โ
โโโ models / native runtime files
```
The wrapper keeps the OCR engine alive for reuse. A single stdout reader feeds
responses through a queue, requests are serialized with a lock, and shutdown
uses terminate โ wait โ kill as a fallback.
## ๐ Quick start
### 1. Clone and install
```bash
git clone https://github.com/luffy666code/PaddleOCR-json-MCP.git
cd PaddleOCR-json-MCP
python -m venv .venv
```
Activate the virtual environment, then install:
```bash
python -m pip install -U pip
python -m pip install -e .
```
### 2. Add the PaddleOCR-json runtime
Download **PaddleOCR-json v1.4.1** from the upstream release page:
https://github.com/hiroi-sora/PaddleOCR-json/releases/tag/v1.4.1
Place the runtime under `engine/`.
**Windows**
```text
engine/
โโโ PaddleOCR-json.exe
โโโ models/
```
**Linux**
```text
engine/
โโโ bin/
โ โโโ PaddleOCR-json
โโโ lib/
โโโ models/
```
See [`engine/README.md`](engine/README.md) for the expected layout.
### 3. Run the MCP server
```bash
python main.py
```
The server uses **stdio**, so in normal use it is started by your MCP client
rather than run interactively.
## ๐ MCP client configuration
A generic source-mode configuration looks like this:
```json
{
"mcpServers": {
"paddleocr": {
"command": "python",
"args": ["/absolute/path/to/PaddleOCR-json-MCP/main.py"]
}
}
}
```
If you build a standalone wrapper, point `command` at the generated executable
instead. The exact configuration file location depends on your MCP client.
> The repository intentionally avoids client-specific placeholder syntax and
> deployment metadata. Keep client/platform adapters outside the reusable core.
## ๐งช Tool examples
### Local image
```json
{
"image_path": "C:\\images\\receipt.png",
"include_details": false
}
```
### Base64 image
```json
{
"image_base64": "iVBORw0KGgoAAAANSUhEUgAA...",
"include_details": true
}
```
A successful normalized result has the shape:
```json
{
"code": 100,
"text": "Hello OCR",
"count": 1,
"lines": [
{
"text": "Hello OCR",
"score": 0.99,
"box": [[10, 12], [120, 12], [120, 38], [10, 38]]
}
]
}
```
## ๐ฆ Build a standalone wrapper
The engine and model files remain external so they can be updated separately
from the Python wrapper.
**Windows**
```bat
scripts\build_windows.bat
```
Output:
```text
dist/paddleocr-mcp.exe
```
**Linux**
```bash
./scripts/build_linux.sh
```
After building, keep the executable next to the `engine/` directory:
```text
runtime/
โโโ paddleocr-mcp.exe # Windows example
โโโ engine/
โโโ PaddleOCR-json.exe
โโโ models/
```
## ๐ Repository layout
```text
PaddleOCR-json-MCP/
โโโ main.py
โโโ pyproject.toml
โโโ engine/
โ โโโ README.md
โโโ scripts/
โ โโโ build_windows.bat
โ โโโ build_linux.sh
โโโ .github/
โ โโโ workflows/ci.yml
โ โโโ ISSUE_TEMPLATE/bug_report.yml
โโโ CONTRIBUTING.md
โโโ SECURITY.md
โโโ NOTICE
โโโ LICENSE
```
Generated `build/`, `dist/`, logs, virtual environments, PaddleOCR-json engine
binaries, and model files are intentionally excluded from Git.
## ๐ Privacy & security
The wrapper itself talks to a **local PaddleOCR-json process** and does not
require a cloud OCR API. Images provided by file path stay on the MCP host as
far as this wrapper is concerned. Your MCP client or host may implement its own
logging, telemetry, or file handling, so review that environment separately.
Do not expose this MCP server to untrusted callers without considering local
file access: `recognize_image` can read any image path that the server process
has permission to access.
## ๐ Credits
This repository is an independent community wrapper around:
- [hiroi-sora/PaddleOCR-json](https://github.com/hiroi-sora/PaddleOCR-json)
- [PaddlePaddle/PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)
- [FastMCP](https://github.com/jlowin/fastmcp)
PaddleOCR-json v1.4.1 is licensed under the Apache License 2.0. This repository
does not claim to be an official PaddlePaddle or PaddleOCR-json project.
## ๐ License
Apache License 2.0. See [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE).
---
<div align="center">
If this wrapper is useful, consider starring the upstream OCR projects too. โญ
</div>
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues