Skip to main content
Glama
qiao-925
by qiao-925

ocr_recognize

Extract text from local image files using PaddleOCR to convert visual content into machine-readable text with confidence scores and positional data.

Instructions

Recognize text from one local image path via PaddleOCR.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool definition and handler entry point for ocr_recognize.
    @mcp.tool()
    async def ocr_recognize(image: dict[str, Any]) -> dict[str, Any]:
        """Recognize text from one local image path via PaddleOCR."""
        return await asyncio.to_thread(recognition_service.recognize, image)
  • The core business logic that orchestrates image resolution, validation, and OCR engine invocation.
    def recognize(self, image: dict[str, Any]) -> dict[str, Any]:
        """Handle one OCR request and return the public tool response."""
        request = OCRRequest(image=image)
        resolved_engine = "paddleocr"
        resolved_path: str | None = None
    
        try:
            image_path = self._resolve_image_path(request.image)
            validated_path = validate_image(str(image_path)).resolve()
            resolved_path = str(validated_path)
            result = self._engine.recognize(validated_path)
            meta = self._build_meta(
                request_id=request.request_id,
                resolved_engine=resolved_engine,
                resolved_image_path=resolved_path,
            )
            return self._build_success(data=result.to_dict(), meta=meta)
        except EngineNotAvailableError as exc:
            return self._build_error(
                code=exc.code,
                message=exc.message,
                retryable=exc.retryable,
                data=None,
                meta=self._build_meta(
                    request_id=request.request_id,
                    resolved_engine=resolved_engine,
                    resolved_image_path=resolved_path,
                ),
            )
        except FileNotFoundError as exc:
            return self._build_error(
                "file_not_found",
                str(exc),
                False,
                None,
                self._build_meta(request.request_id, resolved_engine, resolved_path),
            )
        except InvalidImageRequestError as exc:
            return self._build_error(
                exc.code,
                exc.message,
                exc.retryable,
                None,
                self._build_meta(request.request_id, resolved_engine, resolved_path),
            )
        except ValueError as exc:
            return self._build_error(
                "invalid_image",
                str(exc),
                False,
                None,
                self._build_meta(request.request_id, resolved_engine, resolved_path),
            )
        except Exception as exc:
            self._logger.exception("OCR 请求处理失败")
            return self._build_error(
                "internal_error",
                str(exc),
                False,
                None,
                self._build_meta(request.request_id, resolved_engine, resolved_path),
            )
Behavior2/5

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

No annotations are provided, so the description carries the full burden. While 'Recognize' implies a read-only operation, the description fails to disclose error behaviors (e.g., failed OCR), whether temporary files are created, or PaddleOCR-specific requirements like language support.

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?

Single sentence with zero waste. Each clause provides distinct value: the action (recognize text), the input constraint (local image path), and the technology context (PaddleOCR).

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

Completeness3/5

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

Adequate for a single-parameter tool with an output schema (return values need not be described), but the description leaves ambiguity about the 'image' object structure and lacks behavioral safety context required given the absence of annotations.

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

Parameters4/5

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

With 0% schema description coverage, the description compensates by clarifying that the 'image' parameter expects a 'local image path,' adding critical semantic meaning absent from the schema. However, it doesn't explain the object structure despite the schema defining it as an object with additionalProperties.

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 states a specific verb ('Recognize'), target resource ('text'), source ('one local image path'), and implementation ('PaddleOCR'). It clearly distinguishes from the sibling 'ocr_health_check' by focusing on text extraction rather than service status.

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

Usage Guidelines3/5

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

The phrase 'one local image path' implies the tool is intended for local file OCR, but there is no explicit guidance on when to use this versus the health check, supported image formats, or file size constraints.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/qiao-925/ocr-mcp-service'

If you have feedback or need assistance with the MCP directory API, please join our Discord server