Private LLM infrastructure without the cloud tax.
Keep your frontier model for planning. Run file reads, greps, edits, and tests on your own GPU inside a zero-trust Rust sandbox.
Website · 88-Day Proof · Deployment Atlas · Security · Docs
Castor is an in-process agent microkernel written in Rust. It exposes three MCP tools over stdio (castor_coworker, castor_task, castor_server) so cloud coding agents—or local orchestrators—can delegate multi-turn workspace execution to any OpenAI-compatible local or VPC serving engine.
Quickstart
Register Castor with every detected MCP client in one command:
npx -y mcp-castor install --client all
Or install globally / build from source:
# Global npm CLI
npm install -g mcp-castor
castor install --client all
# From source (Rust 2024, Node 22+ for npm shim)
cargo build --release
Verify your local engine and ask your agent to use Castor:
castor server status # probes 127.0.0.1:18020/v1 automatically
"Refactor the auth middleware to use JWT and verify with
cargo testusing castor."
If your serving engine runs on another port or host, set CASTOR_BASE_URL:
export CASTOR_BASE_URL="http://127.0.0.1:1234/v1" # e.g. LM Studio
How it works
In a cloud-only agent, every file read, grep, and test log gets re-sent and re-billed on every turn. Castor keeps the high-level plan in the cloud (or a local orchestrator) and executes the raw tool loop locally at $0 in API tokens.
| Dimension | Cloud-only agent | Castor Hybrid | Local-only (with local host) |
|---|---|---|---|
| Planning & review | Frontier model | Frontier model (unchanged) | Local orchestrator (opencode, goose, aider) |
| File, grep, edit & test loop | Frontier API, re-billed every turn | Your local / VPC GPU ($0 tokens) | Your local / VPC GPU ($0 tokens) |
| Raw logs & file dumps | Sent to cloud on every turn | Stays inside workspace / GPU | Stays inside perimeter |
| Context window | Fills with terminal noise | Only short verified results return | Isolated to local engine |
| Execution safety | Host-dependent | 5-layer path + shell + Landlock + AST gate | 5-layer path + shell + Landlock + AST gate |
See docs/architecture.md for the full microkernel specification.
Measured 88-day ledger & benchmarks
Figures below come from castor stats across 4 Sep to 1 Dec 2026 (single-developer workstation: RTX 3090 24 GB, Qwen3.8-27B-W4A16-AutoRound, vLLM 0.33.0, 150K context), including 432 earlier sessions folded in from the archived baseline.
| Metric | Measured value | Notes |
|---|---|---|
| Local tokens processed | 3.30 B | 58,045 turns across 1,396 sessions (427 tasks) |
| Tool calls | 79,760 | 97.3% success rate (43.1% bash, 24.9% read, 12.4% edit) |
| KV prefix-cache hit | 93.9% | Engine-reported cache reads over cache-eligible prompt tokens |
| Decode velocity | 111.1 tok/s | Token-weighted decode (127 tok/s single-stream peak) |
| Prefill / ingestion | 914 / 3,659 tok/s | Fresh prefill / effective ingestion; engine timings + labelled backfill |
| Cloud counterfactual | $2,617.90 | Claude Sonnet 5 list ($3 / $0.30 read / $15 output, 5-min TTL) |
| Local electricity | $12.31 | 68.4 kWh at 250 W, $0.18/kWh ($0.0037/1M vs $0.794/1M, hardware excluded) |
Independent coding quality for Qwen3.8-27B measured by Vals AI (2026-09-01, separate from vendor model cards): 84.0% LiveCodeBench v6, 86.0% SWE-bench Verified, and 58.4% Terminal-Bench 2.1.
Reproduce the ledger check locally (--live-only restricts to sessions still on disk, --verify re-derives cold and fails on drift):
castor stats --verify
Full methodology, tool distribution, and GPU sizing recipes (16 GB workstation through L40S / H100 / multi-node) are published at usecastor.github.io/proof and usecastor.github.io/deployments.
Supported clients & engines
Clients
| Client | Integration | Status |
|---|---|---|
| Claude Code | castor install --client claude | Supported (writes ~/.claude.json) |
| Google Antigravity | castor install --client antigravity | Supported (writes ~/.gemini/config/mcp_config.json) |
| Cursor / Codex / Claude Desktop | Manual stdio MCP config | Documented |
| opencode / goose / aider | Local orchestrator over stdio MCP | Local-only loop |
| Any stdio MCP client | Standard mcpServers block | Supported |
Manual stdio MCP configuration (Cursor, Codex, Claude Desktop)
{
"mcpServers": {
"castor": {
"command": "npx",
"args": ["-y", "mcp-castor", "mcp"]
}
}
}
Local serving engines
Castor auto-detects /v1/models, model ID, and max_model_len on 127.0.0.1:18020, or wherever CASTOR_BASE_URL points:
| Engine | Default port | Notes |
|---|---|---|
| vLLM | 18020 | Auto-detected; guided_choice DGI probe + per-request metrics |
llama.cpp (llama-server) | 18020 | Managed start/stop via castor server; --jinja tool calling |
| LM Studio | 1234 | Set CASTOR_BASE_URL="http://127.0.0.1:1234/v1" |
| SGLang | 30000 | Set CASTOR_BASE_URL="http://127.0.0.1:30000/v1" |
| Ollama | 11434 | Set CASTOR_BASE_URL="http://127.0.0.1:11434/v1" |
Loopback ports: :18020 serving engine, :18021 long-poll wait server, :18022 SSE stream proxy, :18030 local trace UI.
Runtime & security model
- In-process Rust runtime (< 0.1 ms tool dispatch): Core worker tools (
read_file,write_file,edit_file,list_dir,search_code,bash,web_search,web_fetch) run in-process without per-tool subprocess overhead. Optional Cargo gates addast_search/ast_replace(ast, enabled by default) andpaper_lookup(paper). - DGI mega-prompt firewall: A 1-forward-pass logit probe rejects overloaded multi-subsystem prompts before they burn GPU compute or lease a slot; warm continuations bypass the probe with zero overhead.
- Token-budget semaphore: Atomic two-phase
O_EXCLleases bound concurrent KV allocation against GPU capacity and coordinate cooperative yielding under load. - Zero-turn reactive wakeups: Tasks exceeding the sync window return a task ID and block on
castor wait <id>(HTTP long-poll on:18021) so the cloud supervisor sleeps at $0. - Stream guard & context ceiling: The SSE proxy (
:18022) halts degenerate repetition loops mid-stream; an in-flight 90% context ceiling stops tool calls cleanly before HTTP 400 overflows. - Five-layer containment sandbox: Canonical root anchoring, symlink realpath checks, out-of-tree refusal, traversal/null-byte normalization, binary sniffing, a lexical shell scanner with dead-man fuse, Linux 5.13+ Landlock confinement, and a 27-grammar tree-sitter AST gate with atomic rollback (137 sandbox test vectors: 123 blocked, 14 allowed).
- Honest egress boundary: Castor binds strictly to
127.0.0.1, ships zero telemetry beacons or auto-updaters, and logs every tool verdict to an append-only JSONL ledger (~/.castor/telemetry/). Note thatweb_searchandweb_fetchare compiled into the default open-source build; compile-time web-tool exclusion, hash-chained audit verification, and SSO are delivered separately in sovereign pilots.
CLI & building from source
castor mcp # stdio MCP server (default entry point)
castor install --client all # register with Claude Code and Antigravity
castor server <status|start|stop> # manage local serving engine lifecycle
castor stats [--live-only] [--verify] # derive telemetry ledger and cost counterfactual
castor wait <task-id> # long-poll task completion (:18021 + disk fallback)
castor trace # local execution trace viewer (:18030)
castor config # print effective config (env > config.json > defaults)
castor archive | clean # archive stale debris or prune per retention policy
Verification gates from source:
cargo test --all-features
cargo clippy --all-targets --all-features -- -D warnings
Documentation
| Guide | Covers |
|---|---|
| Getting Started | Installation, manual MCP config, and engine connection |
| Architecture | DGI, zero-turn lifecycle, semaphore, SSE proxy, Evo, and MCP tools |
| Security | Zero-trust workspace containment pipeline and SECURITY.md |
| CLI & Development | Command reference, telemetry contract, and build gates |
| Engine Profiles · llama.cpp | Serving-engine tuning and managed llama-server |
| Contributing | Development workflow and PR requirements |
Deployment services & license
Castor's open-source engine is licensed under AGPL-3.0; if your team needs inference sizing/tuning, a managed hybrid rollout, an air-gapped sovereign pilot, or commercial dual-licensing without copyleft obligations, see usecastor.github.io/pricing or contact m.abdullah.ali.2523@gmail.com.