ZCode MCP Server
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., "@ZCode MCP Server start a ZCode session and have it fix the failing auth tests"
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.
mnehmos.zcode.mcp
An MCP server that controls ZCode (the Z.ai / Zhipu desktop AI coding agent) programmatically.
Status: working. All 15 tools are implemented and dispatch through the MCP protocol, and a real agent turn runs end to end — one
zcode_chatcall creates a session, sends the prompt, and returns the answer. Two capabilities are declared limitations rather than bugs, because a bare agent runtime is a subset of what the desktop can do (see Capability boundaries below).Start with
specs/001-zcode-control/quickstart.md. The audit is inZCODE_*.md; corrections from a second pass are in.re/findings_ADDENDUM.md, which wins where they disagree.
What was found
ZCode is not a monolith and not a VS Code fork. It is three tiers: an Electron shell, a host/broker process, and a separate headless agent runtime. That third tier is the discovery that makes this project possible:
printf '{"id":1,"method":"session/list","params":{}}\n' \
| node "E:/zcode/resources/glm/zcode.cjs" app-server --stdio
# → {"id":1,"result":{"sessions":[ … real sessions … ]}}zcode app-server is documented in ZCode's own --help as "Run the ZCode Protocol stdio app
server". It speaks a named, versioned, zod-validated protocol ("ZCode Protocol", v1; v4 wire
version 3) over newline-delimited JSON on stdin/stdout, exposing 65 methods plus 21 v4
methods, including v4/command with 30 command types.
The whole design rests on this: control ZCode by owning one of its agent runtimes and speaking its own protocol — never by simulating a user.
The five findings that shaped the design
# | Finding | Consequence |
1 | The agent runtime is spawnable and scriptable by an unrelated process, over stdio | Rating A control surface; no UI automation anywhere |
2 | The runtime needs its own model-provider config and does not inherit the desktop's — not even the providers configured in ZCode's own model management | The MCP must provision a provider, and the key reaches it by environment. The key itself has to be placed in the environment of whatever launches this server; this server never generates a file containing one, and never reads ZCode's credential store |
3 | Owning the runtime makes us its only client, so it sends us the approval requests | A default-deny policy module is mandatory, not a nicety, or turns deadlock |
4 |
| The chat tool must observe a terminal turn event before claiming success |
5 | ZCode has no editor document service | "get active editor" / "replace selection" are not buildable; file mutation goes through the agent's own tools, which is the only path that produces checkpoints and participates in rewind |
Related MCP server: chatgpt-with-codex
Repository contents
The reverse-engineering audit
Document | What it covers |
three-tier architecture, processes, flows, boundaries — the main reconstruction | |
every process, service, module and dependency, with the process diagram | |
every communication surface: 66 protocol methods, 129 IPC channels, host RPC, HTTP endpoints, env vars | |
all six command/event registries, the 25 session-event types, the 30+ agent tools | |
UI surfaces → internal actions, and the editor-API non-capability | |
the split state model, every entity, persistence map, safe-write rules | |
model providers, registry sync, turn lifecycle, tools, permissions, subagents, MCP | |
surfaces ranked A–F, and the full control-surface matrix per operation | |
the evidence log: what was run, what was seen, labelled CONFIRMED / INFERRED / HYPOTHESIS | |
open questions, each with the experiment that settles it | |
the proposed MCP architecture and tool surface | |
staged build order from smallest proof of control | |
corrections from the second deep CLI pass — read this alongside the above |
Working artifacts (ASAR reader, protocol prober, extracted bundles, raw agent reports) are in .re/.
The specification (Spec Kit)
.specify/memory/constitution.md the eight articles every design decision must pass
specs/001-zcode-control/
├── spec.md user stories P1–P5, 45 functional requirements, 12 success criteria
├── plan.md technical context, Constitution Check, project structure
├── research.md the decision record, each decision with its alternatives
├── data-model.md external entities + internal entities + state transitions
├── contracts/ 15 files: the shared envelope + one per tool
├── quickstart.md clone → first successful call, with checkpoints
└── tasks.md 85 tasks in 8 phases, grouped by user storyThe tool surface
14 tools with discriminated-union actions — deliberately not one tool per operation, because the model provider rejects requests above roughly 89–94 registered tools.
Tool | Actions | Read-only? | Status |
|
| ✅ | works |
|
| mixed | works |
|
| ❌ | works |
|
| mixed | works |
|
| mixed | works |
|
| ✅ | works |
|
| ✅ | works |
|
| mixed | works |
|
| mixed | works |
|
| mixed | works; |
|
| mixed | works, gated |
|
| ❌ | works |
|
| mixed | declared limitation |
|
| mostly | partial — see below |
★ = the P1 journey. Everything else is prerequisite plumbing or convenience.
Capability boundaries
An owned agent runtime is a subset of what the desktop can do. Two capabilities resolve to methods that exist in the protocol's vocabulary but need a host tier that is not present:
zcode_automation—automation/*answers-32601. Scheduling appears to be a host-side capability; the desktop's host provides it and its client inherits it. Reported asmethod_not_supported: unreliable.zcode_files changes/rewind_preview—v4/conversation/fileChangesrequires abaseRevisionthat no call exposes to a bare runtime's client.baseLogEpochis obtainable (fromrowsRange.atLogEpoch, confirmed because a wrong epoch is rejected) but every derivable revision is rejected withproto.staleRevision. Reported astoken_unobtainable: unreliable.
The rest of zcode_files works, including rewind_apply, which is implemented as a fork — the
safe form, since it keeps the pre-rewind state reachable.
Both are recorded in .re/findings_ADDENDUM.md §A22 and §A23, with the full evidence.
Non-capabilities, stated plainly
These were requested but cannot be built on any stable interface, because ZCode has no editor document service (CONFIRMED, not inferred):
zcode.editor.active · zcode.editor.selection · zcode.editor.replace_selection ·
zcode.file.read (as the editor sees it) · zcode.file.save · zcode.diff.accept/.reject (only
partially, via rewind)
The substitutes are documented per tool in specs/001-zcode-control/contracts/, and the reasoning is
in ZCODE_UI_MAP.md §7.
Design principles
From .specify/memory/constitution.md:
Semantic control only. Every tool resolves to a named protocol method, a parser-verified CLI flag, or a documented config file. No clicks. No minified identifiers. No live-DB writes.
No success without read-back. Every mutating action re-reads and fails on contradiction. Admission is not completion.
noopis not success.Schemas are contracts. zod before spawn; protocol version asserted at first contact; loud on drift.
Secret handling. API keys travel by environment, never a file this server generates; redaction is on by default; ZCode's credential store is never read or written. Where the key physically lives is the launcher's business — a
.envfornpm run start:env, or theenvblock of the MCP client's registration for a client that starts the server itself. The one place that does not work is ZCode's model-management config, which a spawned runtime does not read.Deny by default. The approval policy defaults to deny; blanket auto-approval is prohibited.
Bounded resources. Timeouts, owned process groups, hard kill on every path, no orphans.
The repo is the memory. Audit row per call, hashed artifacts, evidence labels on every claim.
Tests are reflexes. Codec, schemas, redaction, policy and log-token retry are unit-tested; a real turn, a denied write with no side effect (verified by hash), and zero orphans are integration-tested.
Safety: what this server will not do
Simulate mouse or keyboard input.
Write to ZCode's live SQLite databases.
Read, write or relocate
~/.zcode/v2/credentials.json.Auto-approve tool use.
Report a mutation as successful without reading the result back from ZCode.
Expose arbitrary protocol methods by default (the escape hatch is off, allowlisted, and kill-switchable).
Known hazards, disclosed in the tools themselves
Hazard | Where |
|
|
Desktop settings changes need a ZCode restart |
|
Enabling plugins consumes the model's tool budget ( |
|
Creating an automation grants standing unattended authority at the recorded mode |
|
|
|
Open items
ZCODE_UNKNOWNS.md — 9 of 14 questions are resolved. What remains is low-impact except U-14 (the
un-analysed hooks trust family). The two that mattered most resolved decisively:
U-1 — Web Remote Control. There is no local network surface: the desktop opens no listener and is an outbound
wsclient to a Z.ai relay. This ruled out the "attach to the running desktop" design entirely, which is why stdio to an owned runtime is the only boundary.U-4 — credential protection. Provider keys in
config.jsonare plaintext;credentials.jsonis AES-256-GCM but with a key derived from the machine's own identity whenZCODE_CREDENTIAL_SECRETis unset, so it is obfuscated rather than truly encrypted.
Open in this server
zcode_models select scope=serverdoes not warn that a workspace which already remembers a model keeps it. A switch can therefore look applied and have no effect on the next turn.zcode_commandis withheld. Its schema is designed and its protocol methods exist, but no dispatcher was written, so calling it returnedunknown toolwhile it was still advertised. An advertised tool that cannot work is worse than an absent one, so it is not published until it has a dispatcher, a contract and tests.The tool budget needs re-measuring. The recorded 87 was taken while these 15 tools were being rejected by the client, so it is roughly 15 too low (14 published tools plus one withheld). The 89-94 ceiling is a GLM limitation and does not apply to other providers.
Giving it a model
Configure your provider in ZCode — that is the whole setup. The model menu writes
~/.zcode/v2/config.json, and this server reads the credential for the provider it is about to call
from there. Nothing needs to be duplicated anywhere, and no key has to be pasted a second time.
Resolution order, and the environment always wins:
source | when |
| you set one deliberately — it wins |
the matching provider in | the fallback, so the model menu alone is enough |
A key that came from the registry is reported as provider_key_from_registry (advisory) naming the
provider, so which credential is being spent is never a mystery. Point the server at a model and
endpoint with ZCODE_MCP_MODEL and ZCODE_MCP_BASE_URL.
Switching models
A runtime spawned from the environment knows exactly one model, so its catalogue has one entry and
there is nothing to switch to. zcode_settings upsert_provider widens that catalogue on a running
runtime, gated behind ZCODE_MCP_ALLOW_PROVIDER_EDIT=1; zcode_models select then switches:
scope | mechanism | can introduce a new model |
| this process's default, for runtimes spawned afterwards | yes |
|
| only from the runtime's catalogue |
|
| only from the runtime's catalogue |
Measured end to end: the catalogue goes 1 → 2 models, a switch selects the added one, and the turn
that follows runs on it. One limit worth knowing: a workspace that already remembers a model keeps
it — select scope=server applies to runtimes spawned afterwards in a workspace with no stronger
persisted state.
Two things this deliberately does not do: it never opens ~/.zcode/v2/credentials.json (that
file has a machine-derivable cipher and is off-limits by policy, not by difficulty), and it never puts
a key in a tool result, a log line, or a warning — only the provider's id.
Two things worth doing on your machine
Set
ZCODE_CREDENTIAL_SECRET. Without it, the key protecting~/.zcode/v2/credentials.jsonis derived from the machine's own identity rather than from a secret you hold — so the file is obfuscated, not really encrypted, and anyone with a copy of it can read your tokens.Treat provider keys in
~/.zcode/v2/config.jsonas plaintext secrets, because they are. They sit in a JSON file, not a keychain.
Neither is something this MCP uses; both are reported because the audit found them. The Web Remote
Control QR is also a bearer secret (hash=<passHash>), so a photographed QR stays live until
reset-pairing is run.
License
MIT. See LICENSE.
Available Tools
14 toolszcode_approvalA
Answer the agent's approval, input and elicitation requests. Owning a runtime makes this server the runtime's only client, so unanswered requests block turns. The default policy is DENY. persist_rule writes a durable permission rule and requires ZCODE_MCP_ALLOW_PERSIST_RULES=1.
zcode_automationB
Manage scheduled agent runs. Creating an automation grants STANDING, UNATTENDED authority at the mode recorded at creation time. At most 20 automations are retained.
zcode_chatB
Submit work to the ZCode agent and follow it to a terminal state. Success is only reported after a terminal turn event is observed; an accepted-but-unobserved command is reported degraded. Use tool_allowlist:["Read"] for a guaranteed non-mutating turn.
zcode_conversationA
Read a conversation: rows, messages, events, plans, usage. Read-only. Reads carry logEpoch and revision; on staleness the read is retried once, then reported degraded.
zcode_filesA
Inspect what a turn changed, preview a rewind, and move attachments. ZCode has NO editor document API: there is no "read the file as the editor sees it". File mutation goes through the agent's own Write/Edit tools, which is the only path that produces checkpoints and participates in rewind. rewind_apply is destructive and requires confirm:true.
zcode_headlessB
One-shot headless run via the zcode CLI, requiring no protocol. Emits only flags verified to parse; unverified flags are reported as skipped. Needs a configured model provider.
Inputs: text (required), action (required), mode, output, +5 more.
zcode_mcpA
Inspect and manage ZCode's MCP client surface. WARNING: "list" and "status" START the configured MCP servers as a side effect; the started instance ids are reported. Use "servers" to read configuration without starting anything. Config edits require ZCODE_MCP_ALLOW_MCP_CONFIG_EDIT=1 and a restart.
zcode_modelsA
Discover models and providers, and select one. ACTION "catalog" is the decision surface: it lists what ZCode can talk to with context windows, modalities, reasoning levels and whether this server holds a credential for that provider — filterable, and deliberately NOT ranked, because choosing a model is the job of the caller. "available" reports what the runtime has wired up (a different question). "select" applies a choice at session, workspace or server scope; server scope affects only newly spawned runtimes in this process and does not persist.
zcode_pluginsB
Enumerate and manage extensions. Enabling plugins consumes the model's tool budget: the provider rejects requests above roughly 89-94 registered tools with [1210] Invalid API parameter, so this warns when the count approaches the budget. install/update/uninstall require ZCODE_MCP_ALLOW_PLUGIN_INSTALL=1.
zcode_protocolA
Escape hatch: raw ZCode Protocol access. Disabled by default (ZCODE_MCP_DISABLE_PROTOCOL=1 turns it off entirely) and restricted to an allowlist; mutating methods need ZCODE_MCP_PROTOCOL_ALLOW_MUTATIONS=1. Results are always marked unreliable because no read-back or schema guarantee is applied.
zcode_sessionC
ZCode session lifecycle and per-session settings. Mutating actions re-read the session and fail if the observed value disagrees with the request.
zcode_settingsA
Read and change configuration. Protocol-backed actions take effect immediately; file-backed actions (set_desktop) are read by ZCode at startup and report that a restart is required. Provider mutations require ZCODE_MCP_ALLOW_PROVIDER_EDIT=1. Secrets are redacted in all output.
zcode_statusB
Report the state of this MCP server and of ZCode itself. Read-only; starts no turn. "probe" is the diagnostic entry point (runtime version, protocol identity, session count).
zcode_usageC
Token and activity analytics. Read-only.
Inputs: range (required), action (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Each tool targets a distinct ZCode subsystem (status, session, chat, conversation, files, settings, plugins, MCP, automation, usage, models, approval, headless, protocol), limiting direct overlap. However, execution-related tools (zcode_chat, zcode_headless, zcode_automation, zcode_protocol) and read/analytics tools (zcode_conversation, zcode_usage) could be confused at a glance, so not entirely unambiguous.
All 14 tools use the identical zcode_ snake_case prefix and noun-based naming pattern (zcode_status, zcode_session, etc.). No mixing of camelCase, verb styles, or other conventions.
14 tools is within the well-scoped 3–15 range and matches the breadth of the ZCode platform. Each tool corresponds to a distinct subsystem rather than a trivial action, so the set is not bloated.
The surface covers core lifecycle and management areas: status, session, chat, conversation, files, settings, plugins, MCP, automation, usage, models, approval, headless, and raw protocol. Minor gaps remain—e.g., no explicit abort/cancel-turn operation and no direct file-read tool (an intentional architectural limitation)—so an agent may need workarounds for edge cases.
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Chat with your Zihin.ai agents, list them and load platform skills from any MCP client.
Real-time chat for AI agents. Claude Code, Cursor, Cline and Codex join channels over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceDelegates autonomous coding tasks to Z.ai's GLM models with a genuine agent loop, file operations, and verification via git and real process results.41 npmMIT
- AlicenseNot gradedqualityBmaintenanceA local MCP bridge that lets ChatGPT chat mode operate the user's own computer, running project, file, and shell tasks through a local executor and returning progress and results to the conversation. It also coordinates Codex sessions (persistent or one-off) and other agent CLIs as sub-agents.1MIT
- AlicenseAqualityAmaintenanceEnables a DeepSeek Harness agent to delegate bounded coding tasks to a local ZCode runtime, follow their progress through events, and review the resulting diffs before accepting or continuing the work. It also exposes model catalog, default-model, and setup-diagnostics tools for managing those delegated tasks.12Apache 2.0
- AlicenseCqualityFmaintenanceThis MCP server gives an AI coding host controlled, client-agnostic access to a local machine's developer capabilities: transactional file edits, shell and PTY execution, Git and project inspection, language-server operations, isolated browser automation, Windows UI automation, VS Code state, durable jobs, and checkpoints, all bounded by filesystem root allowlisting and resource admission controls. It speaks standard MCP over stdio, Streamable HTTP, and legacy HTTP+SSE, and can also run headless as a long-lived job runner without any hosted model vendor.114ISC