Skip to main content
Glama
tcguoxing
by tcguoxing

paddle-ocr-mcp-server

PaddleOCR PP-OCRv6 的 FastMCP server:把云端 PaddleOCR 识别能力封装为标准 MCP 工具,任何 MCP 客户端(Claude Code 等)都能通过协议直接调用图片/截图/扫描件里的文字识别。

特性

  • 一个工具搞定 OCRpaddle_ocr(image),传入本地路径或 URL,返回识别文本行 + 置信度(JSON)。

  • 零第三方依赖的客户端ocr_client.py 仅用 Python 标准库(urllib / json / base64)实现「提交 → 轮询 → 拉取结果」全流程,可独立复用。

  • 可测:解析逻辑抽成纯函数 parse_jsonl,6 个单测覆盖正常 / 空输入 / 异常路径,不联网、不依赖 token。

  • token 走环境变量PADDLEOCR_TOKEN(已写入 ~/.zshrc),密钥不进代码不进仓库。

Related MCP server: ocr-mcp

快速开始

cd ~/Code/paddle-ocr-mcp-server
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"

# token 从环境变量读取(若新 shell 未继承,先 source ~/.zshrc 或 export)

运行 / 验证

# 1) 直接跑 server(stdio,Claude Code 默认传输)
.venv/bin/paddle-ocr-mcp

# 2) 单测(不联网、不依赖 token)
.venv/bin/python -m pytest -q

# 3) 用 MCP inspector 调试(可选)
npx @modelcontextprotocol/inspector .venv/bin/paddle-ocr-mcp

接入 Claude Code

claude mcp add paddle-ocr -- .venv/bin/paddle-ocr-mcp

之后在 Claude Code 里直接说「识别这张图 xxx.png 里的字」,模型会自动调用 paddle_ocr 工具。

工具

  • paddle_ocr(image: str) -> str

    • image:图片本地路径URL

    • 返回 JSON 数组 [{"text": "...", "confidence": 0.99}, ...]

项目结构

src/paddle_ocr_mcp/
├── ocr_client.py   # OCR 客户端(提交/轮询/解析),零第三方依赖,纯函数可测
└── server.py       # FastMCP server + @mcp.tool paddle_ocr
tests/              # ocr_client 纯函数单测(不联网)

开发

.venv/bin/python -m pytest -v     # 跑测试
.venv/bin/paddle-ocr-mcp --transport sse   # 需要 HTTP 传输时

Available Tools

1 tool
paddle_ocrPaddle OcrA

识别图片中的文字(中英文)。传入图片本地路径或 URL,返回识别到的文本行及置信度(JSON 数组)。

示例: paddle_ocr("/Users/xx/screenshot.png") paddle_ocr("https://example.com/scan.jpg")

返回格式:[{"text": "识别到的文本", "confidence": 0.99}, ...]

ParametersJSON Schema
NameRequiredDescriptionDefault
imageYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the behavioral disclosure burden. It explains accepted inputs (local path or URL), the output structure (JSON array of text and confidence), and includes a return-format example. It does not mention error behavior or image-format limits, but is otherwise transparent for a simple read-only OCR tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and well-structured: purpose, input constraints, examples, and return format are all present in a short space. Every sentence contributes useful information with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with one parameter and no sibling tools, the description covers purpose, input, and output adequately. Minor gaps such as supported image formats, network requirements for URLs, and error handling are not addressed, but they are not critical for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must clarify the parameter. It fully compensates by specifying that 'image' accepts a local path or URL, and reinforces this with two clear examples. The single parameter's meaning is unambiguous.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: recognizing text (Chinese/English) from images. It names the operation (识别图片中的文字) and the input resource (image), making its purpose unambiguous even without siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear context for when to use the tool: any task requiring OCR from an image. It does not state exclusions or alternative tools (there are no siblings), but provides concrete invocation examples that make usage straightforward.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev0.1.0
    • First observedpaddle_ocr

TDQS

A4.3/5.0

Scored across 1 tool

Disambiguation5/5

只有一个工具,不存在与其他工具混淆的情况,代理可以毫无歧义地选择它。

Naming Consistency5/5

工具名称paddle_ocr简洁地反映了技术栈和功能,虽然只有一个工具,但命名无混乱,可视为一致。

Tool Count3/5

仅1个工具,对于OCR这一单一用途来说显得单薄,但核心功能已覆盖,属于边界情况。

Completeness2/5

仅提供图片文字识别,缺少语言选择、方向校正、批量处理等常见OCR能力,表面不完整。

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers