mcp-glm-ocr
_
_ __ ___ ___ _ __ __ _| |_ __ ___ ___ ___ _ __
| '_ ` _ \ / __| '_ \ _____ / _` | | '_ ` _ \ _____ / _ \ / __| '__|
| | | | | | (__| |_) |_____| (_| | | | | | | |_____| (_) | (__| |
|_| |_| |_|\___| .__/ \__, |_|_| |_| |_| \___/ \___|_|
|_| |___/
Free OCR & vision for any AI coding client, powered by GLM-4.6V-Flash.
mcp-glm-ocr is an MCP server that gives
OCR and image-understanding capabilities to AI clients that cannot process
images themselves (Claude Code, Claude Desktop, Cursor, Cline, OpenCode, and
any other MCP-compatible client).
Under the hood it sends the image to GLM-4.6V-Flash, z.ai's vision-language model, which is completely free (input and output). The model reads the image and returns text, so your text-only client gets full vision capabilities at zero cost.
Why this exists: z.ai's official vision MCP server is exclusive to paid GLM Coding Plan subscribers. This one works with a plain free z.ai account.
Tools
| Tool | Description |
|---|---|
ocr_image(image) |
Extract all text from an image (screenshots, photos, receipts, document pages). |
describe_image(image) |
Detailed description of what an image shows. |
analyze_image(image, prompt) |
Answer a custom question about an image (charts, tables, diagrams, UI screenshots, math...). |
All tools accept:
- a local file path (absolute, or relative to the client's working directory), e.g.
demo.png - an http(s) URL, e.g.
https://example.com/photo.jpg - a
file://URL or adata:URL
Requirements
- Python 3.10+ (or just
uv) - A free z.ai API key
Get a free API key
- Go to https://z.ai/model-api and create an account (or log in).
- Create an API key at https://z.ai/manage-apikey/apikey-list.
- GLM-4.6V-Flash costs nothing to use.
Installation & configuration
1. Claude Code
claude mcp add glm-ocr --env ZAI_API_KEY=your_key -- uvx mcp-glm-ocr
Then in any conversation:
> what does demo.png say?
> read the text from receipt.jpg
> describe this image: ~/Pictures/screenshot.png
> analyze this chart: chart.png — what is the trend?
2. Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"glm-ocr": {
"command": "uvx",
"args": ["mcp-glm-ocr"],
"env": { "ZAI_API_KEY": "your_key" }
}
}
}
3. Cursor
In .cursor/mcp.json at the root of your project:
{
"mcpServers": {
"glm-ocr": {
"command": "uvx",
"args": ["mcp-glm-ocr"],
"env": { "ZAI_API_KEY": "your_key" }
}
}
}
4. Cline (VS Code)
In Cline settings → MCP servers:
{
"mcpServers": {
"glm-ocr": {
"command": "uvx",
"args": ["mcp-glm-ocr"],
"env": { "ZAI_API_KEY": "your_key" }
}
}
}
5. OpenCode
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"glm-ocr": {
"type": "local",
"command": ["uvx", "mcp-glm-ocr"],
"environment": { "ZAI_API_KEY": "your_key" }
}
}
}
Without uv (pip / Docker)
pip install mcp-glm-ocr
mcp-glm-ocr # requires ZAI_API_KEY env var
docker run --rm -i -e ZAI_API_KEY=your_key mcp-glm-ocr
Environment variables
| Variable | Default | Description |
|---|---|---|
ZAI_API_KEY |
— | Required. Your z.ai API key. Z_AI_API_KEY is also accepted. |
ZAI_MODEL |
glm-4.6v-flash |
Model to use. Switch to glm-4.6v for higher quality (paid), or glm-ocr for a dedicated cheap OCR model. |
ZAI_BASE_URL |
https://api.z.ai/api/paas/v4/ |
API base URL. Lets you point at a proxy or self-hosted gateway. |
ZAI_TIMEOUT |
120 |
HTTP timeout in seconds. |
ZAI_MAX_TOKENS |
4096 |
Max output tokens per call. |
ZAI_MAX_IMAGE_MB |
15 |
Max local image size in MB (larger files are rejected). |
Development
uv sync --all-groups # install deps + dev deps
uv run pytest -q # unit tests (no network, no API key)
uv run python scripts/smoke_stdio.py # boots the real stdio MCP server, lists tools
uv run mcp-glm-ocr # run the server locally (needs ZAI_API_KEY)
uv run mcp-glm-ocr --version
uv run python scripts/banner.py # print the banner in color (terminal)
# real end-to-end call against the z.ai API (needs a real key).
# Omitting the image uses the bundled test fixture (tests/fixtures/test_image.png):
ZAI_API_KEY=your_key uv run python scripts/live_test.py
ZAI_API_KEY=your_key uv run python scripts/live_test.py path/to/your/image.png
How it works
- The client model calls
ocr_image/describe_image/analyze_image. - The server resolves the image (local file → base64
data:URL, or passthrough for URLs). - It calls
POST /chat/completionson the z.ai OpenAI-compatible API with modelglm-4.6v-flash. - The text answer is returned to the client model.
Limitations
- Images only (no video). Video is out of scope for this free model.
- Free tier has rate limits set by z.ai; check the rate limits docs.
- Very large images are rejected by default (
ZAI_MAX_IMAGE_MB=15).
Releasing (maintainer)
Option A: tag a version and let GitHub Actions build and publish automatically:
git tag v0.1.0 && git push --tags
Prerequisite: create a PyPI API token at https://pypi.org/manage/account/token/
and store it as the PYPI secret in the GitHub repo settings.
Option B: publish manually:
uv build # build sdist + wheel
uv publish # push to PyPI (requires a PyPI token)
After publishing, users install with uvx mcp-glm-ocr or pip install mcp-glm-ocr.
Remember to bump version in pyproject.toml and src/mcp_glm_ocr/__init__.py
for each release.
License
MIT
Metadata
Release files for mcp-glm-ocr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mcp_glm_ocr-0.1.0.tar.gz | 356.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_glm_ocr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 365.1 kB
Release files / mcp_glm_ocr-0.1.0.tar.gz
| Download URL | mcp_glm_ocr-0.1.0.tar.gz |
|---|---|
| Size | 356.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bdc4580f15835950bfb4e85ad4e96db9c3de0917360990320c4cc895808f22e9
|
|
BLAKE2b-256 checksum How to use checksums |
b4f5cca248b2304386dcc3524cffea34bed4ae7acd8d344ea2a9b6aa9402bcd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / mcp_glm_ocr-0.1.0-py3-none-any.whl
| Download URL | mcp_glm_ocr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2d0bf861658e706ff4ebac3adf5a4cfac4b499a4ea1209e44959b116c9e183d
|
|
BLAKE2b-256 checksum How to use checksums |
af6fe8cf4337004e9e40ca55ada8109febfa6c1ee2d9ebed806c9e9351cd202c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|