ocrtool-mcp is an open-source macOS-native OCR module built with Swift and Vision framework, designed to comply with the Model Context Protocol (MCP). It can be invoked by LLM tools like Cursor, Continue, OpenDevin, or custom agents using JSON-RPC over stdin.
ocrtool-mcp is a macOS-native OCR tool that implements the stdin-based MCP module protocol, allowing LLM tools like Cursor or Continue to call it via JSON-RPC.
- β Accurate OCR powered by macOS Vision Framework
- β Recognizes both Chinese and English text
- β MCP-compatible JSON-RPC interface
- β Returns line-wise OCR results with bounding boxes (in pixels)
- β Lightweight, fast, and fully offline
- β Open source free software
git clone https://github.com/ihugang/ocrtool-mcp.git
cd ocrtool-mcp
swift build -c release.build/release/ocrtool-mcpSend a JSON-RPC request via stdin:
{
"jsonrpc": "2.0",
"id": "1",
"method": "ocr_text",
"params": {
"image_path": "test.jpg",
"lang": "zh+en",
"enhanced": true
}
}Expected output:
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"lines": [
{ "text": "δ½ ε₯½", "bbox": { "x": 120, "y": 200, "width": 300, "height": 20 } },
{ "text": "Hello", "bbox": { "x": 122, "y": 240, "width": 290, "height": 20 } }
]
}
}.
βββ Package.swift
βββ Sources/OCRToolMCP/main.swift
βββ .mcp/
β βββ config.json
β βββ schema/ocr_text.json
βββ README.md
βββ LICENSE
βββ .gitignore
You can use this module with:
To use this module in Cursor, add the following to your cursor.json file:
{
"mcpServers": {
"ocrtool-mcp": {
"command": "Full path ... /ocrtool-mcp"
}
}
}- Hu Gang (ihugang)
MIT License