ocr
A minimalist OCR library for Rust with CLI and MCP server interfaces. Recognition is implemented in Rust (bitmap font templates, segmentation, and matching)—no Tesseract or other external OCR engine.
The MCP server is built on rmcp.
Features
- No native OCR dependencies - Pure Rust pipeline (binarization, line/character segmentation, template matching)
- Library -
OcrEngineAPI with structured results (text, words, confidence, bounding boxes) - CLI - Text and JSON output; optional preprocessing
- MCP server - Model Context Protocol server for assistant integration (stdio transport)
- Preprocessing - Optional grayscale + threshold preprocessing
- English-focused - Bitmap glyph set suited to Latin letters, digits, and common punctuation
Installation
Binaries (from this crate):
| Binary | Purpose |
|---|---|
ocr |
CLI tool |
ocr-mcp |
MCP server (stdio transport) |
Usage
Library
Crate name: ocr (import as ocr, not ocr_rs).
use OcrEngine;
use Path;
let engine = new
.language
.preprocessing;
let result = engine.recognize_file?;
println!;
println!;
CLI
# Plain text to stdout
# JSON with word-level detail
# Enable preprocessing
MCP server
Add to your MCP client configuration (e.g. Claude Desktop):
Exposed tools:
| Tool | Description |
|---|---|
ocr_image |
OCR on an image file (path) |
ocr_base64 |
OCR on base64-encoded image data |
Architecture
See ARCHITECTURE.md for design details and SPEC.md for the API specification.
License
Apache-2.0