EasyOCR MCP Server
EasyOCR MCP 服务器
一个使用 EasyOCR 库提供 OCR 功能的模型上下文协议 (MCP) 服务器。
关于 EasyOCR:
EasyOCR 是由 JaidedAI 开发的开源光学字符识别 (OCR) 库。它支持超过 80 种语言,提供 GPU 加速,并以易用性和高准确度而闻名。EasyOCR 可以从图像、扫描文档和照片中提取文本,使其适用于广泛的 OCR 任务。有关更多详细信息,请访问 EasyOCR GitHub 仓库。
功能
3 个 OCR 工具:处理来自 base64、文件或 URL 的图像
多语言支持:支持 80 多种语言,并可动态选择
灵活的输出:可在仅文本或包含坐标和置信度的详细结果之间进行选择
性能优化:读取器缓存以获得更好的性能
内存控制:自动卸载和按请求卸载选项
原生 EasyOCR 输出:返回 EasyOCR 的原始格式
Related MCP server: RapidOCR MCP Server
安装
GPU 设置
在创建项目环境之前,请选择一条 GPU 路径。
NVIDIA GPU
针对您的操作系统、Python 版本和 CUDA 版本使用官方 PyTorch 安装选择器:
来自 PyTorch 选择器的典型 Windows pip 示例:
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124安装后,进行验证:
python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"AMD GPU
AMD GPU 支持取决于平台:
Linux 和 WSL:使用官方 ROCm / Radeon PyTorch 安装文档
Windows 原生:存在 ROCm 支持,但 AMD 指出完整的 ROCm 堆栈尚未在 Windows 上得到支持
官方参考:
PyTorch 本地安装指南:https://docs.pytorch.org/get-started/locally/
AMD Windows 兼容性矩阵:https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/compatibility/compatibilityrad/windows/windows_compatibility.html
AMD PyTorch 安装指南:https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/install/installrad/wsl/install-pytorch.html
对于此仓库在 Windows 上的运行,经过测试的路径是重用现有的支持 ROCm 的 PyTorch 安装:
C:\Users\antonio\AppData\Local\Programs\Python\Python312\python.exe该解释器已通过以下方式验证:
python -c "import torch; print(torch.__version__); print(torch.cuda.is_available()); print(getattr(torch.version, 'hip', None))"在 AMD ROCm 上预期的结果形态:
torch.cuda.is_available()返回Truetorch.version.hip不为None
项目环境
# Windows example used in this repo:
# C:\Users\antonio\AppData\Local\Programs\Python\Python312\python.exe
#
# Keep using uv, but create the venv from the existing Python 3.12 interpreter.
# `--system-site-packages` allows the venv to reuse packages already installed
# in that interpreter, such as an existing AMD-enabled PyTorch build.
# Create the project venv from the existing interpreter
uv venv --python C:\Users\antonio\AppData\Local\Programs\Python\Python312\python.exe --system-site-packages
# Sync this project's dependencies into the venv
uv sync
# Remove uv-installed CPU PyTorch packages so the venv falls back to the
# AMD ROCm build that already exists in Python312
uv pip uninstall torch torchvision
# Run tests through uv without re-syncing the environment
uv run --no-sync test.py
uv run --no-sync test-gpu.py这使得项目保持在 uv 上,同时指向现有的 Python312 安装。如果没有 --system-site-packages,普通的 venv 将无法看到基础解释器中已经安装的包。在初始设置后使用 uv run --no-sync,这样 uv 就不会从锁文件中重新安装仅 CPU 的 PyTorch wheel。
使用方法
可用工具
ocr_image_base64- 处理 base64 编码的图像ocr_image_file- 处理磁盘上的图像文件ocr_image_url- 处理来自 URL 的图像unload_ocr_models- 卸载缓存的 OCR 模型以释放内存
参数
detail:输出详细级别(默认:1)0:仅文本 -['text1', 'text2', ...]1:完整详细信息 -[([[x1,y1], [x2,y2], [x3,y3], [x4,y4]], 'text', confidence), ...]
paragraph:启用段落检测(默认:false)width_ths:用于合并的文本宽度阈值(默认:0.7)height_ths:用于合并的文本高度阈值(默认:0.7)unload_jobdone:在此 OCR 调用后立即卸载模型(默认:来自UNLOAD_JOBDONE)
注意:语言选择通过 MCP 配置中的 EASYOCR_LANGUAGES 环境变量进行配置(请参阅下方的配置部分)。
示例输出
详细级别 1(完整详细信息):
[
([[189, 75], [469, 75], [469, 165], [189, 165]], '愚园路', 0.3754989504814148),
([[86, 80], [134, 80], [134, 128], [86, 128]], '西', 0.40452659130096436)
]详细级别 0(仅文本):
['愚园路', '西', '东', '315', '309', 'Yuyuan Rd.', 'W', 'E']运行服务器
# Run the MCP server through uv
uv run --no-sync easyocr-mcp.pyMCP 配置示例
如果您将此作为父 MCP 应用程序的服务器运行,则可以在主 MCP config.json 中进行配置。
Windows 示例:
{
"mcpServers": {
"easyocr-mcp": {
"command": "uv",
"args": [
"--directory",
"X:\\path\\to\\your\\project\\easyocr-mcp",
"run",
"easyocr-mcp.py"
],
"env": {
"EASYOCR_LANGUAGES": "en,ch_tra,ja"
}
}
}
}Linux/macOS 示例:
{
"mcpServers": {
"easyocr-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/your/project/easyocr-mcp",
"run",
"easyocr-mcp.py"
],
"env": {
"EASYOCR_LANGUAGES": "en,ch_tra,ja"
}
}
}
}环境变量
EASYOCR_LANGUAGES:逗号分隔的语言代码列表(默认:en)示例:
en,en,ch_sim,ja,ko,en
EASYOCR_UNLOAD_TIMEOUT:自动卸载前的非活动秒数(默认:300,0表示禁用)UNLOAD_JOBDONE:如果为true,则默认在每次 OCR 调用后卸载模型(默认:false)
支持的语言
EasyOCR 支持 80 多种语言,包括:
en- 英语ch_sim- 简体中文ch_tra- 繁体中文ja- 日语ko- 韩语fr- 法语de- 德语es- 西班牙语以及更多...
GPU/CPU 配置
GPU 的使用由启动 easyocr-mcp.py 的环境内可见的 PyTorch 安装决定。如果您使用来自 Python312 的 --system-site-packages 创建 uv venv,服务器可以重用该解释器中现有的支持 AMD 的 PyTorch。
快速验证命令:
uv run --no-sync python test-gpu.py
uv run --no-sync python test.py
uv run --no-sync python test_mcp_tools.py在此仓库经过验证的 AMD 设置上,test-gpu.py 报告:
一个支持 ROCm 的
torch构建cuda_available=True一个非空的
hip_version
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for Qwen Image 3 AI image generation
OCR.space MCP — wraps the OCR.space API (ocr.space) for image/PDF → text OCR.
MCP server for NanoBanana AI image generation and editing
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Related MCP Servers
- FlicenseAqualityDmaintenanceA Tesseract.js-based server that enables image-to-text recognition within MCP-compatible environments like Cursor. It supports multiple languages and common image formats, allowing users to extract text from local files using natural language commands.2-
- AlicenseAqualityDmaintenanceHigh-performance OCR MCP server supporting multiple input modes (path, base64, URL, upload), batch processing, and output formats like plain, JSON, and Markdown.42MIT
- AlicenseCqualityCmaintenanceA local OCR MCP server that extracts text from images using PP-OCRv6 for fast text extraction and VL-1.6 for document structure analysis, with automatic model routing and GPU detection.32MIT
- AlicenseNot gradedqualityBmaintenanceAn MCP server wrapping PaddleOCR to provide OCR text recognition for Chinese, English, Japanese, and Korean languages, supporting images from local paths, URLs, and base64 data.MIT