magi-code 0.77.1

Repository-aware CLI coding agent for terminal work
Documentation
# MCP guide

## Scope

Connects configured MCP servers, discovers tools, and routes cancellable calls.

## Where to look

| Task | Path |
| --- | --- |
| Initialize and request lifecycle | `client.rs`, `protocol.rs`, `jsonrpc.rs` |
| Server isolation and registry | `manager.rs` |
| Qualified names and schema conversion | `names.rs`, `tool_schema.rs` |
| Child transport | `stdio.rs` |
| HTTP requests and notification streams | `http.rs`, `sse.rs` |
| Header references | `headers.rs` |
| OAuth facade and helpers | `oauth.rs`, `oauth/discovery.rs`, `oauth/login.rs`, `oauth/storage.rs`, `oauth/tokens.rs` |

## Local rules

- Initialization uses protocol `2025-03-26`. Keep validation with the protocol/client boundary.
- Construct and parse routes through `QualifiedMcpToolName`: `mcp__server__tool`, at most 64 bytes, non-empty ASCII name components without `__`. Server names must not end in `_` because that makes routing ambiguous.
- Keep bad-server isolation and duplicate-route detection in the manager; do not advertise ambiguous names.
- Stdio uses newline JSON-RPC, not LSP Content-Length framing. Preserve the 1 MiB frame limit and pending-request failure on EOF.
- POST accepts JSON or SSE and carries the HTTP session id. GET notification SSE is best effort; unsupported GET must not break POST calls.
- The isolated current-thread Tokio runtime is only for GET-SSE notifications. Preserve shutdown/cancellation and HTTP-session DELETE teardown.
- Request timeout terminates the connection; do not leave a timed-out request usable for later calls.
- Sensitive headers use environment references. OAuth storage remains behind its private facade with token locks and protected files under the configured home.