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=trueto return structured JSON withoutmd_results(contains page parsing details likebbox_2d,content,label, etc.)
Parameters:
- file_path: Local file path or URL for
png,jpg/jpeg, orpdf - base64_data: Optional data URL/base64 payload (use when
file_pathis 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.truereturns JSON;falsereturns 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)
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
Metadata
Release files for glm-ocr-mcp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| glm_ocr_mcp-0.1.1.tar.gz | 48.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| glm_ocr_mcp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.8 kB
Release files / glm_ocr_mcp-0.1.1.tar.gz
| Download URL | glm_ocr_mcp-0.1.1.tar.gz |
|---|---|
| Size | 48.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
304645f10e3444698228f46603b7a99f86cdab306b45fc0fbb86f19fc51e4f4c
|
|
BLAKE2b-256 checksum How to use checksums |
b6d1044ae34b093fa6af9cc5f0ceb161b280e9b8110d02d5bb7a75326c874146
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / glm_ocr_mcp-0.1.1-py3-none-any.whl
| Download URL | glm_ocr_mcp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36aae77499fc1dfca90f205944c05a8809eba3e4f39bf5031b0f12266ebf1c6c
|
|
BLAKE2b-256 checksum How to use checksums |
0c4cca108b465b9a3c2ef9a7b0851fc3f84012edfe28e2365675ee9bc9505b13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Security for glm-ocr-mcp 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.