magi-code 0.105.1

Repository-aware CLI coding agent for terminal work
Documentation
# Connect a local client

Use `magi-code serve --stdio` to run an owned local-agent process over Unix pipes. The backend handles models, tools, approvals, and durable history. Your client handles drafts and display.

## Start the backend

1. Configure providers, enabled models, and MCP approvals through Mission Control.
2. Launch an absolute path to the installed binary with arguments `serve --stdio`.
3. Set the working directory explicitly. Let `MC_HOME` select storage independently.
4. Provide stdin/stdout pipes and drain stderr separately. Do not use a TTY, regular file, or socketpair as a protocol endpoint.
5. Send `initialize` with the capabilities your client requires.

Readiness confirms local configuration, not remote provider availability. Initialization may start approved MCP servers. Never copy credentials into the client or fall back to client-side provider calls.

## Keep state distinct

- Admission is not proof that input was saved. Save a relaunch session ID only after a durable acknowledgement.
- Replace deltas with complete `message.reconcile` parts. A completed message is not a completed run.
- Wait for `run.finished` before another turn or history request. Use its history revision.
- Scope transient IDs to the child process. Reopen only an acknowledged durable session ID after restart.
- Do not replay uncertain requests. Inspect history explicitly after lost output or process failure.

## Stop safely

Request cancellation, keep draining output, then wait for terminal accounting. On application exit, close input and give the child a bounded time to finish before terminating and reaping it. Cancellation does not undo completed effects.

See the [protocol](local-agent-protocol.md) for exact frames, limits, and errors, [session discovery](local-agent-discovery-handoff.md), and [model selection](local-agent-selection-handoff.md).

## Historical evidence

[Archived handoff and integrated acceptance](../archive/local-agent-handoff.md) preserves pinned revisions and [captured traces](https://github.com/magimetal/magi-code/tree/main/docs/features/local-agent-traces). They are examples from those revisions, not proof of current runtime coverage.