使用说明
MCP浑源OCR服务器
一种模型上下文协议(MCP)服务器,使用 浑源OCR 模型(1B参数)。
特性
- 本地处理:完全在您的机器上使用PyTorch运行。
- 苹果硅技术支持:在Mac上自动使用MPS(金属性能着色器)进行加速。
- MCP兼容:适用于Claude Desktop、VS Code(通过MCP扩展)和其他MCP客户端。
先决条件
- Python 3.10+
uv(推荐)或pippoppler(需要PDF支持)- macOS:
brew install poppler - Ubuntu:
sudo apt-get install poppler-utils - Windows:下载并添加到PATH
- macOS:
安装
-
克隆存储库:
git clone https://github.com/beingmyself-tc/mcp-ocr.git cd mcp-ocr -
安装依赖项:
# Using uv (recommended) uv sync # OR using pip pip install .
用法
运行服务器
您可以直接运行服务器:
# If installed with uv
uv run mcp-ocr
# If installed with pip
python -m mcp_ocr.server
使用Claude Desktop进行配置
将以下内容添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"mcp-ocr": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-ocr",
"run",
"mcp-ocr"
]
}
}
}
使用VS代码进行配置
要将此MCP服务器与VS代码一起使用,请将以下内容添加到全局MCP设置文件中(通常 ~/Library/Application Support/Code/User/mcp.json 在macOS上):
{
"servers": {
"mcp-ocr": {
"type": "stdio",
"command": "/absolute/path/to/mcp-ocr/.venv/bin/python",
"args": [
"-m",
"mcp_ocr.server"
]
}
}
}
确保更换 /absolute/path/to/mcp-ocr 使用克隆存储库的实际路径。
工具
ocr_image
对单个图像文件执行OCR。
- 输入:
image_path(string)-图像文件的绝对路径(例如.jpg、.png)。mode(字符串,可选)-处理模式:"ocr"(默认):检测文本并输出坐标。"format":提取Markdown/HTML/LaTeX中的文本/表格/公式。"formula":提取LaTeX中的配方。"table":提取HTML格式的表。"translation":摘录并翻译成英文。
- 输出:摘录文本。
ocr_pdf
对PDF文件执行OCR。
- 输入:
pdf_path(string)-PDF文件的绝对路径。mode(字符串,可选)-与相同的模式ocr_image.
- 输出:提取的文本(连接的页面)。
许可证
麻省理工学院