Skip to main content
Glama

GLM OCR MCP Server

MCP server for extracting text from images and PDFs using ZhipuAI GLM-OCR.

Usage

{
  "mcpServers": {
    "glm-ocr": {
      "command": "uvx",
      "args": ["glm-ocr-mcp"],
      "env": {
        "ZHIPU_API_KEY": "your_api_key_here",
        "ZHIPU_OCR_API_URL": "https://open.bigmodel.cn/api/paas/v4/layout_parsing"
      }
    }
  }
}

Using with Claude Code

claude mcp add --scope user glm-ocr \
  --env ZHIPU_API_KEY=your_api_key_here \
  --env ZHIPU_OCR_API_URL=https://open.bigmodel.cn/api/paas/v4/layout_parsing \
  -- uvx glm-ocr-mcp

Using with Codex

Add MCP server with command:

codex mcp add glm-ocr \
  --env ZHIPU_API_KEY=your_api_key_here \
  --env ZHIPU_OCR_API_URL=https://open.bigmodel.cn/api/paas/v4/layout_parsing \
  -- uvx glm-ocr-mcp

Tools

The server provides one tool:

  • extract_text: Extract from local file or URL (png, jpg/jpeg, pdf)

    • default returns Markdown text

    • set return_json=true to return structured JSON without md_results (contains page parsing details like bbox_2d, content, label, etc.)

Parameters:

  • file_path: Local file path or URL for png, jpg/jpeg, or pdf

  • base64_data: Optional data URL/base64 payload (use when file_path is unavailable)

  • start_page_id: Optional PDF start page (1-based, only effective for PDF)

  • end_page_id: Optional PDF end page (1-based, only effective for PDF)

  • return_json: Optional boolean, default false. true returns JSON; false returns Markdown.

Examples

# Extract text from local image
extract_text(file_path="./screenshot.png")

# Extract text from local PDF
extract_text(file_path="./document.pdf")

# Extract text from URL image
extract_text(file_path="https://example.com/test.jpg")

# Use base64/data URL
extract_text(base64_data="data:image/png;base64,iVBORw0KGgo...")

# Extract structured layout JSON
extract_text(file_path="https://example.com/test.png", return_json=True)

Related MCP server: OCR MCP Service

Development

# Create virtual environment
uv venv
source .venv/bin/activate

# Sync dependencies and install current project
uv sync

# Run server for testing
python -m glm_ocr_mcp.server

Windows PowerShell activation:

.venv\Scripts\Activate.ps1

Project Structure

glm-ocr-mcp/
├── pyproject.toml         # Project configuration
├── README.md              # Documentation
├── .env.example           # Environment variable template
├── src/
│   └── glm_ocr_mcp/
│       ├── __init__.py
│       ├── __main__.py    # Entry point
│       ├── ocr.py         # OCR client
│       └── server.py      # MCP server

Available Tools

1 tool
extract_textB

Extract text from local files or URLs. Supported formats: PNG, JPG/JPEG, PDF.

Inputs: file_path, base64_data, start_page_id, end_page_id, +1 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 1 tool

    Disambiguation5/5

    Only one tool exists, so there is no possibility of confusing it with another. Its purpose is clearly described as extracting text from files or URLs.

    Naming Consistency5/5

    The single tool name 'extract_text' follows a clear verb_noun pattern. With only one tool, there are no inconsistencies to assess.

    Tool Count3/5

    A single tool serves a narrow OCR purpose, but by the rubric 1-2 tools feels thin. It is functional but borderline for a full MCP server.

    Completeness4/5

    The tool covers the core OCR workflow for common formats (PNG, JPG, PDF) from both local files and URLs. It lacks advanced features like batch processing or layout detection, but these are not essential for basic text extraction.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      D
      maintenance
      Enables multimodal AI capabilities through GLM-4.5V API for image processing, visual querying with OCR/QA/detection modes, and file content extraction from various formats including PDFs, documents, and images.
      3
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to recognize and extract text from images using PaddleOCR, supporting both file paths and base64 input with structured results including confidence scores and text positions.
      2
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides OCR services powered by Google's Gemini API to extract text from images via file paths or base64 strings. It enables high-accuracy text recognition and CAPTCHA processing through simple MCP tools.
      8
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides image understanding and OCR via GLM-4.6V-Flash, supporting URL, base64, and local file inputs. Enables AI assistants to analyze images and extract text from screenshots, documents, and more.
      70 npm
      MIT