Skip to main content
Glama
glm-subagent-mcp

glm-subagent-mcp

by gaztrabisme

glm-subagent-mcp

MCP server that delegates work to a Claude Code subprocess billed against a GLM Coding Plan.

Parent agent keeps its own auth. The child claude -p process is isolated (CLAUDE_CONFIG_DIR, --bare) so it cannot steal the parent's Anthropic OAuth or recurse into this MCP server.

Install

uvx --from git+https://github.com/gaztrabisme/glm-subagent-mcp glm-subagent-mcp

Claude Code

{
  "mcpServers": {
    "glm-subagent": {
      "command": "uvx",
      "args": [
        "--from", "git+https://github.com/gaztrabisme/glm-subagent-mcp",
        "glm-subagent-mcp"
      ],
      "env": {
        "GLM_API_KEY": "your-z.ai-key",
        "GSA_WORKSPACE": "/path/to/your/project"
      }
    }
  }
}

Requires claude on PATH (Claude Code CLI). Do not put ANTHROPIC_BASE_URL into ~/.claude/settings.json — that would reroute the parent. This server injects GLM credentials only into the child process.

Related MCP server: opencode-mcp

Tools

Tool

What it does

glm_delegate

Start a new Claude Code subagent on a task. Returns agent_id and run_id immediately.

glm_await

Block until a run finishes; returns the result.

glm_continue

Follow-up work in the same Claude Code session (--resume).

glm_list

Every agent this server owns, with state, cost, and run history.

glm_cancel

SIGTERM the in-flight process and close the agent.

glm_transcript

Activity log — tool calls, messages, raw response.

Typical loop: glm_delegate → glm_await → (glm_continue) → glm_cancel.

Every delegation needs a verification command. The server runs it after the child finishes. Exit 0 → completed; otherwise completed_unverified. Pass "true" if there is nothing to check.

Isolation

  • Child env: ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic, ANTHROPIC_AUTH_TOKEN=$GLM_API_KEY

  • CLAUDE_CONFIG_DIR under .gsa-sessions/agents/<id>/claude-home

  • --bare so project .mcp.json and host ~/.claude are not loaded (recursion kill)

  • --dangerously-skip-permissions plus a PreToolUse guard (same policy as deepseek-subagent-mcp)

  • Default model: glm-5.3[1m] (GSA_MODEL / glm_delegate(model=...))

Configuration

Every setting is an environment variable on the server process. See wiki/implementation-brief.md for the full table. Common ones:

Variable

Default

Meaning

GLM_API_KEY

—

Z.ai API key (also ZAI_API_KEY or ANTHROPIC_AUTH_TOKEN)

GSA_BASE_URL

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

Anthropic-compatible GLM endpoint

GSA_MODEL

glm-5.3[1m]

Model for delegated work

GSA_FLASH_MODEL

glm-5.3-flash[1m]

Haiku-slot mapping

GSA_WORKSPACE

server cwd

Directory the child reads and writes

GSA_MAX_AGENTS

4

Concurrent in-flight children

GSA_MAX_STEPS

40

--max-turns

GSA_RUN_TIMEOUT

1800

Seconds before a run is killed

GSA_SUPERVISOR

auto

auto / agent / sampling / elicitation / off

Limits

  • claude must be on PATH. This server does not bundle Claude Code.

  • --bare skips the workspace CLAUDE.md; if the file exists it is passed via --append-system-prompt-file.

  • Cancel is SIGTERM. Edits already written stay on disk.

  • A GLM Coding Plan key is required at spawn time, not at import.

Development

uv sync
uv run pytest -q

Available Tools

6 tools
glm_awaitA

Wait for a run to finish and return its result.

Safe to call repeatedly. If the run is still going when wait_seconds elapses, this returns the current state rather than an error. Runs whose agent has since been reaped are still readable — their results are archived.

Args: run_id: The run to wait on, from glm_delegate or glm_continue. wait_seconds: Maximum time to block. Use a longer value for big tasks.

Inputs: run_id (required), wait_seconds. Returns: object

glm_cancelA

Stop a subagent and release its runtime process.

The harness protocol has no mid-turn cancel, so this kills the child process. Any in-flight run is reported as cancelled, and file edits it already made stay on disk. Cancelling ends the session: its context cannot be resumed, so start a new agent rather than continuing this one.

Args: agent_id: Agent to stop.

Inputs: agent_id (required). Returns: object

glm_continueA

Send follow-up work to an existing subagent, in its original session.

The child keeps the full context of its earlier turns, so refer to prior work directly ("the migration you just wrote"). Work is queued: if the agent is mid-run, this message runs after it.

Args: agent_id: Agent to continue, from glm_delegate or glm_list. message: The follow-up instruction. verification: Command proving this follow-up is done. Omit to skip verification for this turn; the run then reports completed_unverified. wait_seconds: Block up to this long for the run to finish. 0 returns at once.

Inputs: message (required), agent_id (required), verification, wait_seconds. Returns: object

glm_delegateA

Start a new Claude Code subagent on a task.

Returns immediately with an agent_id and run_id unless wait_seconds is set. Each call creates a fresh agent with its own runtime process and session; use glm_continue to give more work to an agent that already exists.

Args: task: What to do, with a clear definition of done. The child cannot ask you clarifying questions, so state the acceptance criteria. verification: The shell command that proves the task is done, run by this server in the workspace after the child finishes — e.g. "pytest -q" or "npm test && npm run lint". Its exit code decides whether the run is reported completed or completed_unverified. Pass "true" if there is genuinely nothing to check. workspace: Directory the child reads and writes. Relative paths resolve against the server's configured workspace. Defaults to that workspace. instructions: Optional standing guidance prepended to the task, e.g. coding conventions or files to leave alone. model: GLM model id. Defaults to the server's configured model. name: Human label for this agent, shown in glm_list. wait_seconds: Block up to this long for the run to finish. 0 returns at once.

Inputs: task (required), verification (required), name, model, +3 more. Returns: object

glm_listA

List every subagent this server owns, with its state, cost, and run history.

Inputs: no named parameters. Returns: object

glm_transcriptA

Show what a subagent actually did during a run.

Returns the tail of its activity log — tool calls, assistant messages, turn endings. Use this to check progress on a long run, or to understand a failure. Returns live data while the run is still going.

Args: run_id: The run to inspect. limit: How many of the most recent activity lines to return. raw: Also return the child's full uncapped response. glm_delegate returns a distilled version when the answer is large; this is where the original text lives.

Inputs: run_id (required), raw, limit. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct lifecycle action: listing, delegating, waiting, continuing, cancelling, and inspecting subagents. The only potentially related pair, glm_await and glm_transcript, are clearly separated by wait-for-result versus inspect-activity-log semantics.

    Naming Consistency5/5

    All tools share a consistent glm_ prefix followed by a single clear verb or noun: list, delegate, await, continue, cancel, transcript. The naming pattern is uniform, predictable, and matches each tool's purpose.

    Tool Count5/5

    Six tools is well-scoped for a subagent management server. Each tool covers a necessary part of the agent lifecycle without redundancy or bloat.

    Completeness5/5

    The surface covers the full subagent workflow: create via glm_delegate, follow-up via glm_continue, monitor via glm_await and glm_transcript, terminate via glm_cancel, and observe overall state via glm_list. Archived results and live progress handling close the remaining operational gaps.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Wraps Claude Code as tools for MCP clients, enabling autonomous coding tasks via a 4-tool lifecycle with session management, async polling, and permission controls.
      4
      93 npm
      21
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Delegates coding tasks to the local Claude Code CLI via MCP, offering run, review, and status tools for MCP-compatible agents.
      25 npm
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables orchestrators to drive Claude Code as a structured software-engineering worker over HTTP, with tools to submit coding tasks, poll for normalized results, resume, review, and cancel jobs.
      -