GLM Subagent MCP
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GLM Subagent MCPAsk glm to review and fix the bug in server.js"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GLM-as-Subagent for Claude Code β plug & play
π¦ Canonical source: https://github.com/djerok/glm_mcp_claude β created by @djerok. If you found this via a fork, mirror, or an awesome-list, the original lives here. Please β / file issues / open PRs at the source.
Add GLM (Zhipu / Z.ai) to Claude Code as a cheap, full-capability subagent (~10Γ cheaper than Opus), with automatic per-task routing between Opus and GLM. Your main agent stays on Opus; GLM does the well-specified, cost-sensitive work β and can read, write, edit, and run your files directly. One command to install.
β Works in the Claude Code app on a subscription-based Claude. Your main agent runs on the Claude you already pay for through the Claude Code app (Pro / Max / Team subscription) β no separate pay-per-token Anthropic API key required. Only GLM needs a (cheap) Z.ai key. Opus orchestrates on your subscription; GLM does the heavy lifting for a fraction of the cost.

β The glm subagent (orchestrated by Haiku 4.5, the cheap layer) reading the repo and offloading the heavy work to GLM via the MCP tools β the Opus β Haiku β GLM hybrid in action.
# no clone needed β run straight from GitHub:
npx github:djerok/glm_mcp_claude --key YOUR_ZAI_API_KEY
# or clone and run the installer:
node install.mjs --key YOUR_ZAI_API_KEYβ¦then restart Claude Code. That's it. (Details below.)
π Your key must be from the Z.ai / Zhipu GLM Coding Plan. Get one at https://z.ai β subscribe to the GLM Coding Plan, then create an API key. A generic / free key without coding-plan access will not work for the coding models used here.
What you get
glmsubagent β a full-tool subagent (read/write/edit/bash) powered by GLM.glm_agenttool β GLM as a real file-editing agent with built-in oversight (diff, dry-run, git revert).glm_delegate/glm_recommend/glm_statusβ draft-only delegation, a free routing advisor, and a health check.Auto-delegation hook β when you spawn a subagent, it injects a GLM-vs-Opus verdict so cheap work goes to GLM automatically. Zero token cost when you're not spawning subagents.
If you explicitly name an agent ("use opus", "use the sonnet agent", "use glm"), the hook stays silent and just routes where you asked.
Related MCP server: Ollama MCP Server
Prerequisites
The Claude Code app (desktop or CLI), signed in with a subscription-based Claude (Pro / Max / Team). Your main agent uses this β no Anthropic API key needed. The
claudeCLI should be on your PATH (claude --version).Node.js β₯ 18 (
node -v)A Z.ai / Zhipu API key with GLM Coding Plan access β get one at https://z.ai. β οΈ It must be on the GLM Coding Plan (the coding-plan subscription); a generic or free key won't have access to the coding models this uses. This is the only paid key required, and GLM is ~10Γ cheaper than Opus.
Git (optional, but enables
glm_agent's one-command revert)
Install (recommended: global, all projects)
# from this folder:
node install.mjs --key YOUR_ZAI_API_KEYThe installer:
copies the server to
~/.claude/glm-mcp/and runsnpm install,writes your key into
~/.claude/glm-mcp/.env,installs the
glmsubagent (~/.claude/agents/glm.md) and the hook (~/.claude/hooks/),wires the hook into
~/.claude/settings.json(backs it up first),adds a short delegation policy to
~/.claude/CLAUDE.md,registers the MCP server with
claude mcp add glm -s user.
Then restart Claude Code and run glm_status β you should see "api_key_loaded": true.
Options:
--no-register(skip the CLI step),--skip-npm,--claude-dir PATH(custom config dir). Re-running is safe (idempotent). No key on the command line? Runnode install.mjs, then edit~/.claude/glm-mcp/.envand setGLM_API_KEY=....
Per-project instead of global
Don't want it everywhere? Skip the installer. Copy glm-mcp/ into your project, cd glm-mcp && npm install,
copy .mcp.json.example β .mcp.json in the project root, set the key, and (optionally) copy
agents/glm.md to .claude/agents/ and the hook into .claude/ + .claude/settings.json.
How it works (the short version)
You ask for something
β Opus orchestrates
β wants to delegate a chunk β spawns a subagent
β [hook fires] "[GLM router] GLM-suitable repo task β use glm_agent (dry_run first)"
(or "keep on Opus" for hard/sensitive work)
β Opus runs glm_agent (GLM edits the files, runs tests) β or keeps it on Opus
β you get a diff + action log + a one-command revertThe routing rules live in glm-mcp/src/router.js and the hook β not in always-on context β
so they cost nothing until a subagent is actually spawned.
Routing in one line: GLM is the default (it's ~10Γ cheaper); Opus is the exception for work where being wrong is expensive β subtle debugging, architecture, large refactors, security, tool-heavy dependent loops, huge context, vision, or anything you mark sensitive.
The tools
Tool | Cost | What it does |
| free (local) | GLM-or-Opus decision + model pick + reasons. |
| free (local) | Peak window, active model, key/config health. |
| GLM tokens | Text in β text out. GLM drafts; you place it. |
| GLM tokens | GLM works your repo directly (read/write/edit/bash). Returns a diff + action log + git revert; supports |
Example: directly calling the GLM agent
A real run β asking GLM (via glm_agent) to write a file end-to-end on disk:

Prompt: "Using the GLM agent
glm_agent, write a 2000-word essay in Shakespearean format about the usefulness of an umbrella, into my Desktop."
GLM did it itself β created the file directly, no round-tripping the content through the main agent:
Output:
Umbrella-Essay-Shakespeare.mdβ ~2,260 words of Early Modern English (thee/thou/thy, doth/hath) with two blank-verse interludesWork: 18 tool-loop iterations; one file created, nothing existing touched
Cost: ~$0.064 β a fraction of running the same task on Opus
That's the point: the orchestrator stays on Opus while glm_agent does the heavy, file-touching work for cents.
Oversight (how you stay in control of glm_agent)
Entry: you/Opus choose when to call it and with which
workdir.dry_run: true: GLM proposes a full diff and writes nothing β approve, then apply.After a real run: you get the unified diff, an action log, and a one-command git revert (
git checkout <baseline> -- .).
Note: file/bash ops inside glm_agent run in the MCP server process (not gated per-edit) and are
scoped to the workdir you pass. That's intentional (max autonomy) β point it only at repos you're
fine letting it modify.
Configuration (~/.claude/glm-mcp/.env)
Var | Default | Meaning |
| β | Your Z.ai key. Required. |
|
| Anthropic-compatible endpoint. |
|
| How hard to favor GLM (it's ~10Γ cheaper). Higher = more GLM; |
|
| Output-token cap. Off by default = generous (up to 131072 per call). Set |
|
| The hard per-call limit applied only when |
|
| The generous default used when the cap is off. |
|
| GLM caps in-flight requests; keep at 1. |
|
| Model(s) for |
|
| Peak window (China hour, UTC+8). |
|
| Max tool-loop turns for |
Full list with comments: glm-mcp/.env.example.
Uninstall
node uninstall.mjs # remove agent, hook, settings entry, MCP registration
node uninstall.mjs --purge # also delete ~/.claude/glm-mcp (and its .env)Security
Never commit/share your
.envor a.mcp.jsoncontaining the key..gitignoreexcludes them.GLM routes through servers in China β don't send secrets/regulated code you wouldn't send to a third-party API. (Routing keeps
sensitive-flagged work on Opus, but you decide what to delegate.)
Troubleshooting
Symptom | Fix |
| Restart Claude Code; |
| Set |
Server fails to start |
|
| Expected under load; it auto-retries. Don't fan out parallel GLM calls. |
Hook not firing | Check |
More background and the research behind the routing rules: see docs/.
Contributing
PRs and issues welcome β see CONTRIBUTING.md. Good first areas: routing
rules (glm-mcp/src/router.js + the hook), provider adapters, and docs. Please never commit
secrets/.env.
License
Original / canonical repository: https://github.com/djerok/glm_mcp_claude. If you fork, mirror, or redistribute this project, please keep a link back to the source so others can find updates, file issues, and contribute. Built by @djerok.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/djerok/glm_mcp_claude'
If you have feedback or need assistance with the MCP directory API, please join our Discord server