Skip to main content
Glama
zcode-worker-mcp
by Hope-08

zcode-worker-mcp

English | 简体中文

A lightweight, transparent MCP server to delegate coding tasks to local ZCode (zcode / ZCode Desktop) with per-task model selection, detached worker survival across MCP restarts, OS PID start-time verification, and unified real-time session observability.

Why zcode-worker-mcp?

Capability

Legacy Bridge Setup

zcode-worker-mcp

Per-task model & reasoning

Relies on global default or opaque overrides

zcode_models probes live ZCode catalog; zcode_start / zcode_continue sets model + provider_id + reasoning_level scoped to that session (persistAsWorkspaceLastUsed: false)

MCP restart / stdin EOF survival

Child worker often dies or becomes orphaned on MCP reload

Workers run detached with logs redirected to disk; reconnecting MCP picks up state cleanly from SQLite

Windows PID reuse safety

Naive PID tree checks can misidentify recycled PIDs (e.g. OneDrive) and deadlock cancel

Captures OS process creation ticks (StartTime.ToUniversalTime().Ticks / ps lstart) and refuses to kill or block on recycled PIDs

Mid-run observability

Isolated MCP SQLite DB hides ZCode Desktop/CLI sessions and internal progress

Unified observer joins state.sqlite, ~/.zcode/cli/db/db.sqlite, and ~/.zcode/v2/tasks-index.sqlite

Existing session resume

Usually starts from scratch or only by bridge task ID

zcode_start(..., resume_session_id: "sess_...") can attach directly to an existing Desktop/CLI session

Runtime footprint

Large monolithic bundled JS + heavy process coordination

Clean TypeScript + @modelcontextprotocol/server v2 + Node built-in node:sqlite

Related MCP server: dsh-zcode-bridge

Requirements

  • Node.js >= 22.18.0 (tested on Node 24.x, using built-in node:sqlite — zero native C++ addons)

  • Local ZCode Desktop or ZCode runtime installed and signed in

Quick Start

If installed from npm (or directly from GitHub):

npm install -g zcode-worker-mcp
# Or before publishing to npm:
# npm install -g github:Hope-08/zcode-worker-mcp

Or from a local clone:

git clone https://github.com/Hope-08/zcode-worker-mcp.git
cd zcode-worker-mcp
npm install
npm run build
npm link

Then configure your MCP client with the global binary name (no local path needed):

{
  "mcpServers": {
    "zcode": {
      "command": "zcode-worker-mcp"
    }
  }
}

Option 2: Zero-install via npx

{
  "mcpServers": {
    "zcode": {
      "command": "npx",
      "args": ["-y", "zcode-worker-mcp"]
    }
  }
}

Note (GitHub & Windows): Before publishing to npm, replace "zcode-worker-mcp" with "github:Hope-08/zcode-worker-mcp". On Windows hosts that invoke spawn() without shell: true, use "command": "npx.cmd" (or "cmd" with ["/c", "npx", "-y", ...]) if "npx" fails with ENOENT/EINVAL.

Option 3: Direct node invocation (fastest startup, zero npm wrapper overhead)

{
  "mcpServers": {
    "zcode": {
      "command": "node",
      "args": ["/path/to/zcode-worker-mcp/dist/index.js"]
    }
  }
}

Claude Code / Codex CLI

claude mcp add zcode -- zcode-worker-mcp
# or:
claude mcp add zcode -- npx -y zcode-worker-mcp

Optional environment variables:

  • ZCODE_WORKER_MCP_DATA_DIR: Override state DB and worker log directory (defaults to ~/.zcode-worker-mcp).

  • ZCODE_HOME / ZCODE_DATA_BASE_DIR: Override where ZCode's cli/db/db.sqlite and v2/tasks-index.sqlite live if customized.

  • ZCODE_INSTALL_DIR / ZCODE_WINDOWS_APP_INSTALL_DIR: Override the ZCode desktop installation root if installed in a non-standard directory.

MCP Tools (9 Total)

Discovery & Environment

Tool

Description

zcode_doctor

Inspect ZCode installation paths, SQLite stores, node runtime, and active workers (automatically reconciles dead workers; never exposes API keys).

zcode_models

Probe ZCode's app-server (via a deferred ephemeral session) and return the active model plus all available provider_id, model_id, and reasoning_levels.

Task Execution & Control

Tool

Description

zcode_start

Start a structured task in a detached worker, optionally specifying mode, model ({ provider_id?, model_id, reasoning_level? }), worktree_path, and resume_session_id. Enforces one active task per normalized execution directory.

zcode_continue

Resume a finished or failed managed task on its bound ZCode session_id with follow-up feedback, extra requirements, or an updated model / mode. Supports operation_id idempotency.

zcode_reply

Respond to a waiting_input permission prompt (decision: "allow" | "deny"), plan approval (approve_plan), or user-input form (answers).

zcode_cancel

Safely terminate verified app-server and worker process trees (guarding against OS PID reuse) and release the workspace lock.

Unified Observability

Tool

Description

zcode_list_sessions

List paginated sessions (limit/offset, total, has_more, next_offset) across zcode-worker-mcp, ZCode Desktop, and ZCode CLI with live PID checks, model/mode info, todo counters, and assistant previews.

zcode_inspect_session

Inspect full live details by either task_id or session_id: effective_state, diagnosis, internal todos, recent tool calls, assistant messages, pending interactions, and parsed JSON report (protected by a 25,000-character response budget).

zcode_watch_session

Short-poll (<=25s, AbortSignal-aware) a task or session for periodic progress inspection or hosts without background command wakeup.

Waiting Modes: Notification-First (wait) & Periodic Inspection

After zcode_start or zcode_continue, two complementary workflows are supported:

  1. Default — Zero-polling completion wakeup (wait CLI): Run the local blocker command in the background and end your agent turn so zero LLM polling tokens are burned while ZCode works:

    zcode-worker-mcp wait <task_id_or_session_id> --timeout 3600 [--notify]
    • Checks SQLite & OS process health quietly without touching stdout until the task reaches a terminal state (completed, failed, cancelled, stalled_or_exited) or waiting_input, then prints a single JSON snapshot and exits 0 (124 on timeout, 2 if not found).

    • Pass --notify (or --toast) to also trigger a best-effort OS desktop notification.

  2. Optional — Periodic inspection: Use zcode_watch_session / zcode_inspect_session (or delegate to a lightweight watcher subagent / schedule) when periodic progress updates are desired or when the MCP client has no background shell wakeup.

Best-practice workflow guidance (worktree isolation, per-task model scoping, wait-first notifications, safe interaction replies, and independent post-task verification) is built directly into the MCP server's instructions and tool descriptions, so any MCP client gets it out of the box without installing extra skills.

Architecture Overview

MCP Client (Antigravity / Claude Code / Codex)
   ├── stdio JSON-RPC ──► zcode-worker-mcp (McpServer @modelcontextprotocol/server v2 + instructions)
   │     ├── Read-only Observability ──► ~/.zcode/cli/db/db.sqlite + v2/tasks-index.sqlite + state.sqlite
   │     ├── Model Probe ──────────────► zcode.cjs app-server (persistence: "deferred")
   │     └── Task Dispatch / Cancel ───► detached node dist/worker.js <dataRoot> <taskId>
   │                                            ├── survives MCP server restart / EOF
   │                                            ├── stores state & interactions in state.sqlite (WAL)
   │                                            └── drives zcode.cjs app-server (--surface desktop)
   └── background wait ─► zcode-worker-mcp wait <task_id> [--notify]  (0 LLM polling, exits on done/waiting_input)

Development

npm run typecheck   # TypeScript strict check
npm run build       # Compile src/ -> dist/
npm test            # Build + run node --test suite

License

MIT — see LICENSE.

Available Tools

9 tools
zcode_cancelSafely Cancel a Managed ZCode Worker TaskA
DestructiveIdempotent

Terminate verified worker/app-server processes (strictly guarding against Windows PID reuse) and release the workspace lock.

Inputs: task_id (required), reason.

zcode_continueContinue an Existing Managed TaskB

Continue an existing task on its bound ZCode session_id with new feedback, optional updated requirements, or a different model/mode.

Inputs: task_id (required), feedback (required), mode, model, +2 more.

zcode_doctorZCode Environment & Worker Health CheckA
Read-onlyIdempotent

Inspect local ZCode CLI/Desktop installation, SQLite stores, configured runtime availability, and live worker processes without leaking credentials.

Inputs: no named parameters.

zcode_inspect_sessionInspect Live Progress of Any ZCode Task or SessionA
Read-only

Get real-time progress by task_id or session_id: effective state, live PID check, todos, recent tool calls, assistant messages, pending interactions, and final result/report.

Inputs: task_id, session_id, tool_limit, message_limit.

zcode_list_sessionsList Unified ZCode SessionsA
Read-only

List sessions across zcode-worker-mcp, ZCode Desktop, and ZCode CLI with live runtime PID checks, model/mode info, todo counts, pagination, and latest assistant previews.

Inputs: limit, offset, workspace, active_only, +1 more.

zcode_modelsList Available ZCode ModelsA
Read-only

Probe local ZCode app-server for the current model selection and all available providers, model_id values, and reasoning levels (sanitized, no API keys).

Inputs: workspace.

zcode_replyReply to a Pending Worker Permission or Input RequestB

Answer a waiting_input task's pending interaction (permission allow/deny, plan approval, or user input answers) so ZCode resumes.

Inputs: task_id (required), reason, answers, decision, +2 more.

zcode_startStart (or Resume) a Detached ZCode Worker TaskA

Dispatch a structured coding or analysis task to a detached ZCode worker that survives MCP restarts. Supports per-task model/provider/reasoning selection and optional resume_session_id.

Inputs: task_id (required), objective (required), workspace (required), mode, +11 more.

zcode_watch_sessionWatch a ZCode Session for Progress or CompletionA
Read-only

Short-poll (<=25s) for periodic progress checks or environments without background commands. For zero-token completion wakeup, prefer running zcode-worker-mcp wait <task_id> in background.

Inputs: task_id, session_id, tool_limit, interval_ms, +2 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 9 tools

    Disambiguation4/5

    Most tools target distinct lifecycle actions (start, continue, reply, cancel), but zcode_list_sessions, zcode_inspect_session, and zcode_watch_session all touch session progress monitoring and could be confused. Descriptions clarify snapshot vs short-poll behavior, so the overlap is manageable.

    Naming Consistency4/5

    All names use a uniform zcode_ prefix and snake_case, with mostly verb-led names like zcode_start and zcode_inspect_session. zcode_models and zcode_doctor are noun-style exceptions, but the overall pattern remains readable and predictable.

    Tool Count5/5

    Nine tools is well-scoped for a worker orchestration server, and each maps to a clear lifecycle stage: discovery, start, continue, monitor, reply, and cancel. There is no obvious bloat.

    Completeness4/5

    The surface covers model discovery, environment diagnostics, task dispatch, continuation, monitoring, interaction replies, and cancellation, which is strong lifecycle coverage. Minor gaps include no explicit session deletion/cleanup operation and no standalone result-only endpoint, though zcode_inspect_session covers final results.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      Enables 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.
      12
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to delegate bounded tasks to a local OpenCode worker while monitoring progress, reviewing evidence, and managing session rework or recovery. It also supports persistent TUI tabs for delegated task workspaces.
      2
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Codex conversations to delegate tasks to persistent worker subagents backed by models configured in VS Code, including BYOK endpoints. Provides workspace inspection and controlled editing tools, approval-gated shell commands, transcripts, and worker lifecycle management.
      1
      MIT