Skip to content

First-class install target + prompt-hook for ZCode (Z.ai) #1535

Description

@dogking95

Request

Add ZCode (Z.ai's coding agent harness, https://zcode.z.ai) as a first-class --target for codegraph install, so codegraph install --target=zcode writes the MCP config automatically.

Related: tracking issue #649 (zcode is already listed there from #962). Opening a dedicated issue to attach the concrete config format and hook details so the target is easier to land.

Why

ZCode is a first-class MCP + hooks-capable agent. Today, ZCode users have to hand-edit the MCP config. CodeGraph works great once configured manually — the ask is just the one-command install target like the other agents have.

What ZCode needs

1. MCP server config (install target)

ZCode reads MCP servers from ~/.zcode/cli/config.json (user scope) or <workspace>/.zcode/config.json (workspace scope), under mcp.servers:

{
  "mcp": {
    "servers": {
      "codegraph": {
        "type": "stdio",
        "command": "codegraph",
        "args": ["serve", "--mcp"],
        "enabled": true,
        "timeoutMs": 60000
      }
    }
  }
}

That's it for MCP — same codegraph serve --mcp as everywhere else. A new file in src/installer/targets/ plus a registry entry, as you noted in #649.

2. (Bonus) UserPromptSubmit prompt-hook

ZCode also exposes a UserPromptSubmit hook that can inject context per turn. If CodeGraph shipped a prompt-hook for ZCode (analogous to what exists for Claude Code), it could inject relevant-symbols context on each prompt. This is optional — the MCP target alone is the main ask.

ZCode hooks docs: https://zcode.z.ai/cn/docs/hooks
ZCode plugin/MCP docs: https://zcode.z.ai/cn/docs/plugin

Config location summary

Scope Path
User ~/.zcode/cli/config.json
Workspace <workspace>/.zcode/config.json

Happy to test a PR on Windows if that helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions