MTPLX/Docs/Claude Code

Claude Code on a local model.

MTPLX serves an Anthropic-compatible /v1/messages endpoint on your Mac. Claude Code talks to it the way it talks to Anthropic, with the full tool loop, and the model is Qwen 3.8 27B running on Apple Silicon with native MTP speculative decoding. Nothing leaves the machine.

Three steps: start the MTPLX server, export the Anthropic variables, run claude. Since MTPLX 0.3.7 (17 May 2026) the Anthropic route has carried Claude Code's complete client-tool loop, and since 2.10.2 (1 Sep 2026) first turns of 165k tokens survive the prefill.

Setup

Install MTPLX from the DMG or with Homebrew, then start the server. The app's play button does the same thing; the CLI and the app share one server, so mtplx start attaches to a model the app already has loaded instead of loading a second copy.

brew install youssofal/mtplx/mtplx
mtplx start            # pick Qwen 3.8 27B Optimized Speed, serve on 127.0.0.1:8000

Print the exact configuration for your install, including the served model id:

mtplx connect claude-code

Environment

Export these in the shell you launch Claude Code from. The auth token is any non-empty string for a localhost server; API_TIMEOUT_MS is raised because a cold 100k-token prefill on a 27B takes minutes.

export ANTHROPIC_BASE_URL=http://127.0.0.1:8000
export ANTHROPIC_AUTH_TOKEN=mtplx-local
export ANTHROPIC_API_KEY=
export ANTHROPIC_MODEL=mtplx-qwen38-27b-optimized-speed
export ANTHROPIC_DEFAULT_OPUS_MODEL=mtplx-qwen38-27b-optimized-speed
export ANTHROPIC_DEFAULT_SONNET_MODEL=mtplx-qwen38-27b-optimized-speed
export ANTHROPIC_DEFAULT_HAIKU_MODEL=mtplx-qwen38-27b-optimized-speed
export CLAUDE_CODE_SUBAGENT_MODEL=mtplx-qwen38-27b-optimized-speed
export API_TIMEOUT_MS=3000000
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
claude

All four model slots point at the same local model so Claude Code never falls back to a cloud tier for subagents or quick tasks.

What to expect

Decode on Qwen 3.8 27B Optimized Speed runs through the native MTP path: the model drafts three tokens ahead with its own MTP head, the target verifies them in one forward pass, and acceptance is exact rejection sampling at the model's shipped sampler (temperature 1.0, top-p 0.95, top-k 20 for Qwen 3.8). The measured decode curve on an M5 Max, MTPLX 2.10.0, stock settings: 64.3 tok/s on a 3k-token chat answer, 30.4 tok/s at 88k context, 18.4 tok/s at 147k. The full set is on the benchmarks page.

Between turns the session cache carries the transcript. MTPLX checkpoints the attention KV cache and the recurrent GDN state at commit boundaries, so a follow-up turn restores the prefix instead of re-prefilling the transcript. The Anthropic bridge reports cache_read_input_tokens and input_tokens as disjoint fields, so Claude Code's context meter shows the true delta and does not auto-compact early (fixed in 2.10.2, PR #417).

Long first turns

Large MCP toolsets put 137k to 165k tokens in the first request. Claude Code's stream watchdog resets only on real message events, so a first turn whose prefill outlives the 300-second idle window used to die with "Stream idle timeout". Since 2.10.2 the bridge emits prefill keep-alives as empty thinking_delta events inside the thinking block the model was about to open. Measured on the 27B: a 165k-token first turn completes its tool calls, and the follow-up turn serves 165,165 of 165,502 tokens from cache with 3.9 seconds to first token.

Memory. The memory governor (2.10.0) sizes the context window to what your Mac can hold and prints the plan in the serve banner: a 48 GB Mac serving the 27B Speed pack resolves 196,608 tokens instead of the nominal 262,144, and at 42k context the release gate measured 33 tok/s decode on that seat. A request that cannot fit is refused up front with an HTTP 507 naming the shortfall (2.10.2), instead of dying mid-stream.

Model ids

The served id follows the pack. mtplx connect claude-code prints the one for the model you loaded.

PackServed idRAM
Qwen 3.8 27B Optimized Speed (recommended for coding)mtplx-qwen38-27b-optimized-speed32 GB+
Qwen 3.8 27B Optimized Quality (8-bit)mtplx-qwen38-27b-optimized-quality36 GB+
Qwen 3.8 Flash-Next Optimized Speed (125B MoE)mtplx-flash-next-optimized-speed96 GB+
Qwen 3.5 9B Optimized Speedmtplx-qwen35-9b-optimized-speed16 GB+

Details for each pack, including the quantization map and the measured speeds, are on the models pages.