glm-mcp
MCP server for ZhipuAI GLM — exposes chat, text embeddings, translation, vision, and OCR to Claude Code (and any MCP-compatible client) via the OpenAI-compatible API.
Tools
| Tool | Description |
|---|---|
glm_chat |
Text completion — default model glm-4-flash, pass model= to use any GLM chat model (e.g. glm-5). Supports single-turn and multi-turn (messages= parameter). Sampling: temperature=0.7, top_p=0.95 (pass top_p=None to omit). Auto-fallback on transient errors (429/503/timeout/connection) via auto_fallback=True (default). Use avoid_peak_hours=True to pre-emptively switch during peak hours (UTC+8 14:00–18:00). |
glm_embed |
Text embeddings — default model embedding-3, pass model= to override |
glm_usage_summary |
Query token usage from ~/.glm-mcp/usage.jsonl. Parameters: days (default 7), model (optional filter). Returns period, total tokens, by_tool, by_model. |
glm_translate |
Pure single-language translation — default model glm-4.7. Parameters: text, target_lang ("ja", "zh", "en"), source_lang (default "auto"), style ("formal" or "casual", default "formal"). Sampling: temperature=1.0, top_p=0.8 (GLM-4.7 Plan B: top_p as primary control; pass top_p=None to omit). Outputs ONLY the target language, solving the mixed Chinese–Japanese output problem common with general LLMs. |
glm_vision |
Multimodal image analysis — default model glm-4.6v. Parameters: image_url (HTTP/HTTPS URL or Base64 string), prompt, detail ("auto", "low", "high"), max_tokens (default 2048). Sampling: temperature=0.2, top_p=0.9 (focused stable analysis; pass top_p=None to omit). Auto-fallback to glm-4.6v-flash on 429/503/timeout. Bare Base64 strings are automatically prefixed with data:image/png;base64,. |
glm_ocr |
Document and image OCR — default model glm-ocr. Parameters: file (HTTP/HTTPS URL, Base64 string, data: URI, or local file path), model, start_page_id, end_page_id. Returns extracted text as Markdown. Local files are auto-encoded as Base64; bare Base64 strings are prefixed with data:application/pdf;base64,. |
Quick Start
Install via uvx (recommended)
uvx glm-mcp
Add to Claude Code
Add to ~/.claude.json:
{
"mcpServers": {
"glm-mcp": {
"type": "stdio",
"command": "uvx",
"args": ["glm-mcp"],
"env": {
"GLM_API_KEY": "your_api_key_here"
}
}
}
}
Get your API key at https://open.bigmodel.cn/.
Run from source
git clone https://github.com/sky-zhang01/glm-mcp
cd glm-mcp
uv sync
GLM_API_KEY=your_key uv run glm-mcp
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
GLM_API_KEY |
Yes | — | ZhipuAI API key |
GLM_BASE_URL |
No | https://open.bigmodel.cn/api/paas/v4/ |
API endpoint override |
GLM_MCP_LOG_DIR |
No | ~/.glm-mcp/ |
Directory for usage.jsonl token log |
Token Usage Logging
Each tool call appends a JSON line to ~/.glm-mcp/usage.jsonl:
{"timestamp": "...", "tool": "glm_chat", "model": "glm-4-flash", "input_tokens": 13, "output_tokens": 15, "fallback_used": false, "original_model": null, "fallback_reason": null}
When fallback is triggered:
{"timestamp": "...", "tool": "glm_chat", "model": "glm-4.7", "input_tokens": 13, "output_tokens": 15, "fallback_used": true, "original_model": "GLM-5", "fallback_reason": "429"}
Development
uv sync --dev
uv run pytest --cov=glm_mcp --cov-report=term-missing
License
MIT
Metadata
Release files for glm-mcp 0.8.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_mcp-0.8.1.tar.gz | 10.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| glm_mcp-0.8.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.6 kB
Release files / glm_mcp-0.8.1.tar.gz
| Download URL | glm_mcp-0.8.1.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f03f56cf21cc31997d9a1ac0c3ca4b222335fca31bcd545612a6489f55735be3
|
|
BLAKE2b-256 checksum How to use checksums |
d4037c0debc299ba05f3d5a2ed4254dd60ee9bbbc6c11db6909236105dd72ff3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","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 / glm_mcp-0.8.1-py3-none-any.whl
| Download URL | glm_mcp-0.8.1-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e015d4a4fc2dad568e6a35f5a847b6e6ba4bbc7e7affd3be30e6e146f574f8b8
|
|
BLAKE2b-256 checksum How to use checksums |
d725a7d252e96e454db82ee2058320c844096e5c143052690dcb7de5c72a51e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","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}
|
Security for glm-mcp 0.8.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.