glm-subagent-mcp
Click on "Deploy 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-mcpuse glm_agent to add unit tests for utils.py in this repo, then summarize the changes"
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.
With this MCP server, Claude Code can call a GLM model as a sub-agent.
English | 简体中文
What It Does | Quick Start | How It Works | Settings | Safety | Acknowledgements
💡 What It Does
Sub-agents in Claude Code are configured with Claude models, so everything a sub-agent reads or runs is billed as Claude tokens. glm-subagent-mcp provides the same delegation pattern backed by a GLM model: one MCP tool, glm_agent, that carries a bounded coding task to completion on GLM and returns only the outcome.
Each call is a delegated run with three parts:
Input.
task,workdir, and optionallycontextandmodel. GLM sees these and nothing else from the Claude conversation.Execution. GLM works in
workdirthrough five actions (read, write and edit a file, list a directory, run a shell command), driven in a loop against its Anthropic-compatible/v1/messagesendpoint.Output. The final text, the changed file paths, and token usage. The intermediate tool traffic stays on the GLM side, so it is billed to the Coding Plan and kept out of Claude's context.
Name the tool in a prompt to start a run:
Use glm_agent to add unit tests for utils.py in this repo, then summarize what changed.Delegated runs fit tasks with a clear specification that do not depend on earlier conversation: scaffolding, tests, translation, docs, local refactors.
Related MCP server: local-llm-mcp
🚀 Quick Start
You need Claude Code, Node.js 18 or newer, and an API key from a GLM Coding Plan.
1. Download and install
git clone https://github.com/HOWILLMAKEIT/glm-subagent-mcp.git
cd glm-subagent-mcp
npm install2. Add it to Claude Code
claude mcp add glm -s user -e GLM_API_KEY=YOUR_KEY -- node /absolute/path/to/glm-subagent-mcp/src/index.jsIf your Coding Plan account is on the mainland-China site (bigmodel.cn), add one more setting. The default address is the international one:
claude mcp add glm -s user -e GLM_API_KEY=YOUR_KEY -e GLM_BASE_URL=https://open.bigmodel.cn/api/anthropic -- node /absolute/path/to/glm-subagent-mcp/src/index.js3. Restart Claude Code and ask for it by name
Delegate the README translation to GLM with glm_agent. Work in /path/to/project.To check the setup without a key, run npm test. It runs the whole flow against a fake GLM server on your machine.
🔍 How It Works
flowchart LR
A["You"] -->|"use glm_agent to ..."| B["Claude Code"]
B -->|"task + project folder"| C["glm_agent"]
C <-->|"what next? / here is the result"| D["GLM model"]
C <-->|"read, edit, run commands"| E[("your project folder")]
C -->|"short report"| BA delegated run proceeds in three steps:
Claude Code calls
glm_agentover MCP stdio.The server POSTs to
{GLM_BASE_URL}/v1/messageswithstream: trueand the five tool definitions. Eachtool_useblock is executed locally and itstool_resultis appended to the messages. The loop ends when the model replies without a tool call, atGLM_AGENT_MAX_ITERS(30), or on cancel.The server returns a header (model, status, iterations, directory), token counts, the changed files and GLM's final text, truncated at 50,000 characters.
Long runs and unreliable networks are handled by these mechanisms:
Concern | Mechanism |
Long-running calls | Progress notifications (iteration, output tokens, tok/s); cancelling aborts the in-flight request |
Transient API errors | Exponential backoff on 429, 5xx and concurrency errors, up to |
Stalled streams | A stream silent for |
Concurrency limits | One request in flight at a time ( |
Filesystem scope | File actions are confined to |
changed files is recorded from the write and edit actions only. Files modified through the shell action are not tracked.
Tool options
Option | Required | Meaning |
| ✅ | What GLM should do. Write it in full, since GLM cannot see your chat. |
| ✅ | Absolute path of the folder GLM works in. |
| Extra background or constraints. | |
|
|
GLM has five actions inside that folder: read a file, write a file, edit a file, list a directory, and run a shell command.
📋 Settings
Pass settings with -e NAME=value when you run claude mcp add.
Setting | Default | Meaning |
| none | Your Coding Plan API key. Required. |
|
| Coding Plan address. Mainland-China accounts: |
|
| Model to use. The Coding Plan supports |
Z.ai warns that using the wrong address means your Coding Plan quota is not used (docs, accessed 2026-10-07).
Setting | Default | Meaning |
|
| Maximum rounds per task |
|
| Time limit for one shell command |
|
| Output limit per round (this project's choice, not an official cap) |
|
| Requests sent to GLM at the same time |
|
| How long to wait in silence before retrying |
|
| Retries on 429, 5xx and concurrency errors |
🔒 Safety
File actions are confined to
workdir. Paths outside it are refused, including paths that reach outside through symbolic links.Shell actions start in
workdirand run with your user's privileges, so their reach is that of your account. Use delegated runs on folders you are comfortable letting GLM modify.
🙏 Acknowledgements
Thanks to djerok/glm-mcp (MIT). This project started from its GLM client and agent loop.
Available Tools
1 toolglm_agentRun a GLM sub-agentADestructive
Delegate a self-contained coding task to a GLM sub-agent (use when the user asks for GLM or glm_agent, or wants to save Claude tokens). GLM works inside workdir with its own read/write/edit/list/bash tools and returns a summary plus the list of changed files. Give a complete task description (goal, constraints, how to verify); GLM does not see this conversation. workdir must be an absolute path. File tools cannot leave workdir; bash is not sandboxed.
| Name | Required | Description | Default |
|---|---|---|---|
| task | Yes | Complete, self-contained task for the sub-agent. | |
| model | No | GLM model id. Default glm-5.3. Coding Plan models: glm-5.3, glm-5.3-flash. | |
| context | No | Optional extra background or constraints. | |
| workdir | Yes | Absolute path of the directory GLM works in. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Adds substantial behavior beyond the annotations: GLM runs with its own read/write/edit/list/bash tools inside workdir, returns a summary plus the list of changed files, does not see this conversation, file tools are confined to workdir, and bash is explicitly NOT sandboxed. The last point is a critical safety disclosure that no annotation conveys.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Front-loads the purpose and trigger, then layers behavioral and safety constraints in dense parenthetical-free sentences. Each sentence earns its place; it is slightly long but not padded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no output schema, the description still specifies the return ('a summary plus the list of changed files'), the sandboxing boundary, the absolute-path requirement, and the isolation from this conversation. An agent has everything needed to call this correctly and safely.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so all four parameters are already documented. The description reinforces the two required params (absolute workdir, complete self-contained task) and hints at why 'context' exists via 'GLM does not see this conversation', but adds no syntax or format detail beyond the schema. Baseline 3 is correct.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource ('Delegate a self-contained coding task to a GLM sub-agent') and immediately establishes scope and the nature of the delegate. An agent can tell exactly what this does without inspecting the schema, and there are no siblings to confuse it with.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Gives explicit trigger conditions ('use when the user asks for GLM or glm_agent, or wants to save Claude tokens') and the qualifier that the task be self-contained. It stops short of stating when not to delegate, but the 'self-contained' constraint and the token-saving rationale cover the practical decision well.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v0.1.0- First observed
glm_agent
TDQS
Scored across 1 tool
Only one tool is exposed, so there is zero risk of selecting the wrong tool. Its purpose—delegating a self-contained coding task to a GLM sub-agent—is clearly stated and distinct.
The single tool uses snake_case (`glm_agent`), which is a standard, predictable convention. With only one tool, consistency is trivially satisfied.
One tool is slightly below the typical 3–15 range, but the server is a focused, single-purpose delegation wrapper. The tool is substantial rather than trivial, so the count is reasonable though thin.
The tool covers the core delegation lifecycle: accept a task, run it in a workdir, return summary and changed files. However, it lacks follow-up operations like status, cancellation, or session continuation, which could be useful for long tasks.
Maintenance
Related MCP Connectors
Project management MCP for AI agents with safe task reads and writes.
Path-scoped team memories, rules and skills for Claude Code, Cursor, Codex and other MCP clients.
Safe folder access for ChatGPT and Claude: read, write and search files, risky tools opt-in.
Share one project context across ChatGPT, Claude, Telegram and any MCP client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP bridge for calling local coding-agent CLIs (Codex, Claude) from another agent, enabling bounded tasks like code review, verification, and bug hunting.MIT
- AlicenseAqualityCmaintenanceMCP server connecting Claude Code to LM Studio, delegating token-expensive tasks to a local model while keeping the cloud model in control. It reduces cloud context usage by reading files locally and returning only the processed results.4MIT
- FlicenseNot gradedqualityBmaintenanceDelegates coding tasks to the local Claude Code CLI via MCP, offering run, review, and status tools for MCP-compatible agents.14 npm-
- AlicenseAqualityBmaintenanceEnables ChatGPT and Codex to safely work with explicitly authorized local project folders through MCP, providing constrained file reading, searching, patch editing, Git inspection, and whitelisted tasks without exposing arbitrary shell, deletion, or deployment capabilities.17MIT