@developer.k/mcp-ocr-engine
v0.1.0
Published
Shared OCR engine utilities for local MCP servers
Readme
OCR Engine
@developer.k/mcp-ocr-engine is a shared OCR utility package for local MCP servers.
It provides:
- A small OCR engine interface.
- A Tesseract.js implementation that runs locally.
- Optional image preprocessing through
sharp. - Normalized OCR text, word boxes, confidence scores, and image metadata.
- Bundled npm language data for English and Korean.
The package is intentionally not tied to Playwright, PDF rendering, desktop capture, or MCP tool schemas. Those layers should pass image buffers or image paths into this package and interpret returned coordinates in their own coordinate space.
Install
npm install @developer.k/mcp-ocr-engineFor local monorepo development, install from the package directory or use a file dependency.
Example
import { TesseractJsOcrEngine } from "@developer.k/mcp-ocr-engine";
const ocr = new TesseractJsOcrEngine();
const result = await ocr.recognize({
image: "C:\\temp\\screen.png",
language: "eng",
preprocess: {
scale: 2,
grayscale: true
}
});
console.log(result.text);
console.log(result.words);
await ocr.close();Language
Use Tesseract language codes such as:
engkorkor+eng
English and Korean language data are installed through npm packages and loaded from local files by default. Remote language downloads are disabled by default so the engine can run in offline/local MCP environments.
For other languages, either add the matching @tesseract.js-data/<code> package support in the engine or instantiate the engine with allowRemoteLanguageDownload: true.
const ocr = new TesseractJsOcrEngine({
defaultLanguage: "kor+eng",
workerIdleMs: 300_000,
allowRemoteLanguageDownload: false
});Coordinate Rules
Returned boxes are normalized back to the original input image coordinate space, even when preprocessing scale is used.
For cropped browser or PDF page images, callers should add their own crop/page origin after OCR if they need viewport or page coordinates.
Smoke Test
npm run smokeThe smoke test renders a small synthetic image, runs OCR locally, and prints recognized text and word bounding boxes.
