Castor README

The full upstream README, mirrored for reference. Install config, tool schemas, adoption signals and our own overview live on the Castor listing page.

Castor

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.

npm CI Rust 2024 License AGPL-3.0

Website · 88-Day Proof · Deployment Atlas · Security · Docs

Castor — Alpine Mineral & Glacial Cobalt


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:

Terminal
npx -y mcp-castor install --client all

Or install globally / build from source:

bash
# 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:

bash
castor server status   # probes 127.0.0.1:18020/v1 automatically

"Refactor the auth middleware to use JWT and verify with cargo test using castor."

If your serving engine runs on another port or host, set CASTOR_BASE_URL:

server.ts
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.

Castor execution architecture

DimensionCloud-only agentCastor HybridLocal-only (with local host)
Planning & reviewFrontier modelFrontier model (unchanged)Local orchestrator (opencode, goose, aider)
File, grep, edit & test loopFrontier API, re-billed every turnYour local / VPC GPU ($0 tokens)Your local / VPC GPU ($0 tokens)
Raw logs & file dumpsSent to cloud on every turnStays inside workspace / GPUStays inside perimeter
Context windowFills with terminal noiseOnly short verified results returnIsolated to local engine
Execution safetyHost-dependent5-layer path + shell + Landlock + AST gate5-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.

MetricMeasured valueNotes
Local tokens processed3.30 B58,045 turns across 1,396 sessions (427 tasks)
Tool calls79,76097.3% success rate (43.1% bash, 24.9% read, 12.4% edit)
KV prefix-cache hit93.9%Engine-reported cache reads over cache-eligible prompt tokens
Decode velocity111.1 tok/sToken-weighted decode (127 tok/s single-stream peak)
Prefill / ingestion914 / 3,659 tok/sFresh prefill / effective ingestion; engine timings + labelled backfill
Cloud counterfactual$2,617.90Claude Sonnet 5 list ($3 / $0.30 read / $15 output, 5-min TTL)
Local electricity$12.3168.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):

bash
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

ClientIntegrationStatus
Claude Codecastor install --client claudeSupported (writes ~/.claude.json)
Google Antigravitycastor install --client antigravitySupported (writes ~/.gemini/config/mcp_config.json)
Cursor / Codex / Claude DesktopManual stdio MCP configDocumented
opencode / goose / aiderLocal orchestrator over stdio MCPLocal-only loop
Any stdio MCP clientStandard mcpServers blockSupported
Manual stdio MCP configuration (Cursor, Codex, Claude Desktop)
config.json
{
  "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:

EngineDefault portNotes
vLLM18020Auto-detected; guided_choice DGI probe + per-request metrics
llama.cpp (llama-server)18020Managed start/stop via castor server; --jinja tool calling
LM Studio1234Set CASTOR_BASE_URL="http://127.0.0.1:1234/v1"
SGLang30000Set CASTOR_BASE_URL="http://127.0.0.1:30000/v1"
Ollama11434Set 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

Castor five-layer workspace containment pipeline

  • 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 add ast_search / ast_replace (ast, enabled by default) and paper_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_EXCL leases 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 that web_search and web_fetch are 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

bash
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:

bash
cargo test --all-features
cargo clippy --all-targets --all-features -- -D warnings

Documentation

GuideCovers
Getting StartedInstallation, manual MCP config, and engine connection
ArchitectureDGI, zero-turn lifecycle, semaphore, SSE proxy, Evo, and MCP tools
SecurityZero-trust workspace containment pipeline and SECURITY.md
CLI & DevelopmentCommand reference, telemetry contract, and build gates
Engine Profiles · llama.cppServing-engine tuning and managed llama-server
ContributingDevelopment 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.