使用说明
MCP OCR服务器
使用MCP(模型上下文协议)构建的生产级OCR服务器,通过简单的界面提供OCR功能。
特性
- 使用Tesseract OCR从图像中提取文本
- 支持多种输入类型:
- 本地图像文件
- 图像URL
- 原始图像字节数
- 自动Tesseract安装
- 支持多种语言
- 生产就绪错误处理
安装
# Using pip
pip install mcp-ocr
# Using uv
uv pip install mcp-ocr
Tesseract将自动安装在支持的平台上:
- macOS(通过Homebrew)
- Linux(通过apt、dnf或pacman)
- Windows(提供手动安装说明)
用法
作为MCP服务器
- 启动服务器:
python -m mcp_ocr
- 为桌面配置Claude:
添加到
~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"ocr": {
"command": "python",
"args": ["-m", "mcp_ocr"]
}
}
}
可用工具
perform_ocr
从图像中提取文本:
# From file
perform_ocr("/path/to/image.jpg")
# From URL
perform_ocr("https://example.com/image.jpg")
# From bytes
perform_ocr(image_bytes)
get_supported_语言
列出可用的OCR语言:
get_supported_languages()
发展
- 克隆存储库:
git clone https://github.com/rjn32s/mcp-ocr.git
cd mcp-ocr
- 设置开发环境:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .
- 运行测试:
pytest
贡献
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
安全
- 永远不要提交API令牌或敏感凭据
- 使用环境变量或安全凭据存储
- 遵循GitHub的安全最佳实践
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
