Skip to main content
Glama

License: MIT Node 18+ MCP Tools GLM

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 optionally context and model. GLM sees these and nothing else from the Claude conversation.

  • Execution. GLM works in workdir through five actions (read, write and edit a file, list a directory, run a shell command), driven in a loop against its Anthropic-compatible /v1/messages endpoint.

  • 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 install

2. 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.js

If 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.js

3. 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"| B

A delegated run proceeds in three steps:

  1. Claude Code calls glm_agent over MCP stdio.

  2. The server POSTs to {GLM_BASE_URL}/v1/messages with stream: true and the five tool definitions. Each tool_use block is executed locally and its tool_result is appended to the messages. The loop ends when the model replies without a tool call, at GLM_AGENT_MAX_ITERS (30), or on cancel.

  3. 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 GLM_MAX_RETRIES (4)

Stalled streams

A stream silent for GLM_STALL_TIMEOUT_MS is aborted and retried

Concurrency limits

One request in flight at a time (GLM_MAX_CONCURRENT)

Filesystem scope

File actions are confined to workdir (see Safety)

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

task

✅

What GLM should do. Write it in full, since GLM cannot see your chat.

workdir

✅

Absolute path of the folder GLM works in.

context

Extra background or constraints.

model

glm-5.3 (default) or glm-5.3-flash.

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

GLM_API_KEY

none

Your Coding Plan API key. Required.

GLM_BASE_URL

https://api.z.ai/api/anthropic

Coding Plan address. Mainland-China accounts: https://open.bigmodel.cn/api/anthropic

GLM_MODEL

glm-5.3

Model to use. The Coding Plan supports glm-5.3 and glm-5.3-flash.

Z.ai warns that using the wrong address means your Coding Plan quota is not used (docs, accessed 2026-10-07).

Setting

Default

Meaning

GLM_AGENT_MAX_ITERS

30

Maximum rounds per task

GLM_AGENT_BASH_TIMEOUT_MS

120000

Time limit for one shell command

GLM_MAX_TOKENS

32768

Output limit per round (this project's choice, not an official cap)

GLM_MAX_CONCURRENT

1

Requests sent to GLM at the same time

GLM_STALL_TIMEOUT_MS

120000

How long to wait in silence before retrying

GLM_MAX_RETRIES

4

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 workdir and 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 tool
glm_agentRun a GLM sub-agentA
Destructive

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
taskYesComplete, self-contained task for the sub-agent.
modelNoGLM model id. Default glm-5.3. Coding Plan models: glm-5.3, glm-5.3-flash.
contextNoOptional extra background or constraints.
workdirYesAbsolute path of the directory GLM works in.

TDQS

A4.4/5.0
Behavior5/5

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.

Conciseness4/5

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.

Completeness5/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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. 1 tool updatev0.1.0
    • First observedglm_agent

TDQS

A4.4/5.0

Scored across 1 tool

Disambiguation5/5

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.

Naming Consistency5/5

The single tool uses snake_case (`glm_agent`), which is a standard, predictable convention. With only one tool, consistency is trivially satisfied.

Tool Count4/5

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.

Completeness4/5

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

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    MCP 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.
    4
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Delegates coding tasks to the local Claude Code CLI via MCP, offering run, review, and status tools for MCP-compatible agents.
    14 npm
    -
  • A
    license
    A
    quality
    B
    maintenance
    Enables 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.
    17
    MIT