Metadata-Version: 2.4
Name: wk-ocr-mcp
Version: 0.2.2
Summary: MCP server for OCR text recognition service (RapidOCR + OpenVINO)
Project-URL: Homepage, https://github.com/your-org/wk-ocr-mcp
Project-URL: Repository, https://github.com/your-org/wk-ocr-mcp
License: MIT
Keywords: claude-code,mcp,ocr,rapidocr,text-recognition
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Requires-Dist: mcp>=1.0.0
Description-Content-Type: text/markdown

# OCR MCP Server

MCP (Model Context Protocol) 服务器，让 Claude Code / Cursor / Windsurf 等 AI 编码工具通过 MCP 协议直接调用 OCR 文字识别服务。

## 功能

| Tool | 说明 |
|------|------|
| `ocr_recognize` | 图片文字识别 - 从任意包含文字的图片中提取文本内容 |
| `ocr_table` | 表格识别 - 从图片中提取表格的行列结构化数据 |
| `ocr_health` | 服务健康检查 - 验证后端 OCR 服务是否正常运行 |

### 参数说明

`ocr_recognize` 和 `ocr_table` 支持以下参数（三选一，优先级从高到低）：

| 参数 | 说明 |
|------|------|
| `image_path` | **本地文件路径（推荐）** - 支持 png, jpg, jpeg, gif, bmp, webp, tiff, tif, pdf |
| `image_base64` | 图片的 base64 编码 |
| `image_url` | 图片 URL 地址 |

直接给文件路径即可，MCP Server 会自动读取文件并处理。

## 环境变量

| 变量 | 默认值 | 说明 |
|------|--------|------|
| `OCR_SERVICE_URL` | `http://127.0.0.1:8082/api` | OCR 后端 API 地址（含路径前缀） |

## 接入配置

### Claude Code

项目根目录创建 `.mcp.json`：

```json
{
  "mcpServers": {
    "ocr": {
      "command": "uvx",
      "args": ["wk-ocr-mcp"],
      "env": {
        "OCR_SERVICE_URL": "https://gogs.wxapp.info/ocr-api"
      }
    }
  }
}
```

或 pip install 后：

```json
{
  "mcpServers": {
    "ocr": {
      "command": "python3",
      "args": ["-m", "ocr_mcp_server"],
      "env": {
        "OCR_SERVICE_URL": "https://gogs.wxapp.info/ocr-api"
      }
    }
  }
}
```

### Cursor / Windsurf

分别放到项目根目录 `.cursor/mcp.json` 或 `.codeium/windsurf/mcp_config.json`，格式同上。

## OCR_SERVICE_URL 配置说明

`OCR_SERVICE_URL` 必须指向 API 路径前缀：

| 场景 | 值 |
|------|-----|
| 直接访问 | `http://127.0.0.1:8082/api` |
| Nginx 代理 | `https://gogs.wxapp.info/ocr-api` |

代码会在此基础拼接端点：`{URL}/ocr`、`{URL}/table`、`{URL}/health`

## 使用方式

配置好后重启工具，直接用自然语言：

```
帮我识别这张图片里的文字: /path/to/screenshot.png
```

```
这个截图里的表格数据提取出来: /path/to/table.png
```

AI 会自动调用 `ocr_recognize` 或 `ocr_table`，传入文件路径即可完成识别。

## License

MIT
