Skip to main content
Glama
README.md
# jcode-mcp

An [MCP](https://modelcontextprotocol.io) server that lets Claude (Desktop or Code) orchestrate [jcode](https://github.com/1jehuang/jcode) agent sessions. Claude plans and verifies. jcode agents do the work in parallel, one git worktree each.

Connected to your own jcode, the sessions it creates are normal jcode sessions: they appear in the jcode TUI and in jcode Desktop, where you can watch or steer them.

```
Claude Desktop / Claude Code
        |  MCP (stdio)
        v
    jcode-mcp  --- @1jehuang/jcode-sdk --->  jcode harness API bridge  ---> jcode daemon
                                                                              |  |  |
                                                                  agent sessions (worktrees)
                                                                              ^
                                                              jcode TUI / jcode Desktop
```

## Install

Requires Node 20 or newer. The jcode runtime ships inside the SDK package, so no separate jcode install is needed (installing jcode yourself works too).

```sh
git clone https://github.com/ymatrix1/jcode-mcp
cd jcode-mcp
npm ci && npm run build
```

### Claude Desktop

Add to `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "jcode": {
      "command": "node",
      "args": ["/absolute/path/to/jcode-mcp/dist/src/cli.js"],
      "env": { "JCODE_MCP_AUTOSTART_BRIDGE": "1" }
    }
  }
}
```

### Claude Code

```sh
claude mcp add jcode -e JCODE_MCP_AUTOSTART_BRIDGE=1 -- node /absolute/path/to/jcode-mcp/dist/src/cli.js
```

Optionally copy `skills/orchestrate-jcode` into your skills directory so Claude follows a consistent delegate, wait, verify workflow.

## Tools

| Tool | Purpose |
|---|---|
| `spawn_agent` | Start a jcode session on a task, optionally in a fresh git worktree and branch. Returns at once. |
| `wait_agents` | Block up to 50 s until any or all agents finish or ask for a permission. |
| `agent_status` / `list_agents` | State, tool counts, token usage, pending permissions, warnings. |
| `agent_output` | Last final message, optionally the last N transcript messages. |
| `message_agent` | Soft-interrupt a running agent, or start a new turn on an idle one. |
| `respond_permission` | Allow or deny a pending tool permission request. |
| `cancel_agent` | Interrupt the current turn. |
| `close_agent` | Stop tracking; optionally archive the session and remove the worktree. |
| `list_jcode_sessions` | Sessions the jcode daemon knows, including ones not spawned here. |

States: `starting`, `running`, `idle`, `failed`, `cancelled`, `disconnected`, `closed`. After a daemon reload, running agents show `disconnected`; `message_agent` re-attaches and starts a new turn.

## Configuration

| Variable | Default | Meaning |
|---|---|---|
| `JCODE_MCP_MODE` | `connect` | `connect` attaches to your jcode so sessions are visible in Desktop and the TUI. `launch` starts a private instance (not visible to your own clients, dies with this process). |
| `JCODE_MCP_AUTOSTART_BRIDGE` | off | Set `1` to start `jcode api-bridge` if nothing is listening. Opening jcode Desktop also starts it. |
| `JCODE_MCP_INHERIT_LOGINS` | `1` | `launch` mode: copy your provider logins into the private instance. `0` starts with none. |
| `JCODE_MCP_SOCKET` | SDK default | Harness API socket path. |
| `JCODE_MCP_BINARY` | bundled | Path to a jcode binary. |
| `JCODE_MCP_WORKTREE_ROOT` | `~/.jcode-mcp/worktrees` | Where worktrees are created. |
| `JCODE_MCP_ALLOWED_ROOTS` | unrestricted | Colon-separated directories agents may work in. Strongly recommended. |

## Seeing sessions in jcode Desktop

In `connect` mode this server talks to the same harness API socket that jcode Desktop uses, and Desktop lists sessions from the daemon. Two things to know:

- Desktop refreshes its session list every `workspace.session_refresh_seconds` (default 60, minimum 5). A new session can take that long to appear.
- Desktop's nested swarm tree is built from jcode's own swarm ownership. Sessions spawned here are ordinary top-level sessions, named `label: title`.

## Safety

- jcode agents run as your OS user with your provider logins. Per-session tool limits are not a sandbox. Use `JCODE_MCP_ALLOWED_ROOTS`, keep `auto_approve` off by default, and review diffs before merging.
- jcode picks up provider credentials it finds on the machine. If an agent turn ends with a `warning` about no output, check which provider jcode is using.
- Using a Claude subscription login through third-party harnesses may be restricted by Anthropic's terms. Prefer an API key.

## Development

```sh
npm test                      # unit tests with a fake jcode client and real git
JCODE_MCP_E2E=1 npm test      # also runs the real jcode binary in throwaway state
```

Tests cover the worktree helpers, agent state machine (including reconnect, cancel, permissions, wait), config, and the MCP tool layer through an in-memory MCP client. The e2e test needs no model credentials, so it proves session creation, naming and listing, not model output.

## License

MIT

TDQS

A3.6/5.0

Scored across 10 tools

Disambiguation4/5

Each tool has a distinct role in the agent lifecycle (spawn, observe, interact, terminate), and descriptions clearly differentiate them. The only mild overlap is between list_agents, agent_status, and list_jcode_sessions, though the descriptions distinguish server-spawned agents from daemon-wide sessions.

Naming Consistency4/5

Eight of ten tools follow a verb_noun pattern (spawn_agent, list_agents, wait_agents, message_agent, cancel_agent, close_agent, respond_permission, list_jcode_sessions). agent_status and agent_output break the pattern with noun-first naming, a minor but noticeable deviation.

Tool Count5/5

Ten tools is well-scoped for an agent orchestration server, covering exactly the lifecycle phases a caller needs. No tool appears redundant or vestigial.

Completeness4/5

The surface covers spawn, monitor, message, wait, cancel, close, and permission handling — a full lifecycle. Minor gaps include no tool to fetch an agent's diff or worktree state (descriptions tell you to inspect manually) and no resume/restart operation for a closed agent.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues