mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-07 00:24:50 +08:00
PARITY.md called out missing MCP management in the Rust CLI, so this adds a focused read-only /mcp path instead of expanding the broader config surface first. The new command works in the REPL, with --resume, and as a direct 7[1G[2K[m⠋ 🦀 Thinking...[0m8[1G[2K[m✘ ❌ Request failed [0m entrypoint. It lists merged MCP server definitions, supports detailed inspection for one server, and adds targeted tests for parsing, help text, completion hints, and config-backed rendering. Constraint: Keep the enhancement inside the existing Rust slash-command architecture Rejected: Extend /config with a raw mcp dump only | less discoverable than a dedicated MCP workflow Confidence: high Scope-risk: narrow Directive: Keep /mcp read-only unless MCP lifecycle commands gain shared runtime orchestration Tested: cargo test -p commands parses_supported_slash_commands Tested: cargo test -p commands rejects_invalid_mcp_arguments Tested: cargo test -p commands renders_help_from_shared_specs Tested: cargo test -p commands renders_per_command_help_detail_for_mcp Tested: cargo test -p commands ignores_unknown_or_runtime_bound_slash_commands Tested: cargo test -p commands mcp_usage_supports_help_and_unexpected_args Tested: cargo test -p commands renders_mcp_reports_from_loaded_config Tested: cargo test -p rusty-claude-cli parses_login_and_logout_subcommands Tested: cargo test -p rusty-claude-cli parses_direct_agents_mcp_and_skills_slash_commands Tested: cargo test -p rusty-claude-cli repl_help_includes_shared_commands_and_exit Tested: cargo test -p rusty-claude-cli completion_candidates_include_workflow_shortcuts_and_dynamic_sessions Tested: cargo test -p rusty-claude-cli resume_supported_command_list_matches_expected_surface Tested: cargo test -p rusty-claude-cli init_help_mentions_direct_subcommand Tested: cargo run -p rusty-claude-cli -- mcp help Not-tested: Live MCP server connectivity against a real remote or stdio backend
🦞 Claw Code — Rust Implementation
A high-performance Rust rewrite of the Claw Code CLI agent harness. Built for speed, safety, and native tool execution.
Quick Start
# Build
cd rust/
cargo build --release
# Run interactive REPL
./target/release/claw
# One-shot prompt
./target/release/claw prompt "explain this codebase"
# With specific model
./target/release/claw --model sonnet prompt "fix the bug in main.rs"
Configuration
Set your API credentials:
export ANTHROPIC_API_KEY="sk-ant-..."
# Or use a proxy
export ANTHROPIC_BASE_URL="https://your-proxy.com"
Or authenticate via OAuth:
claw login
Features
| Feature | Status |
|---|---|
| Anthropic API + streaming | ✅ |
| OAuth login/logout | ✅ |
| Interactive REPL (rustyline) | ✅ |
| Tool system (bash, read, write, edit, grep, glob) | ✅ |
| Web tools (search, fetch) | ✅ |
| Sub-agent orchestration | ✅ |
| Todo tracking | ✅ |
| Notebook editing | ✅ |
| CLAUDE.md / project memory | ✅ |
| Config file hierarchy (.claude.json) | ✅ |
| Permission system | ✅ |
| MCP server lifecycle | ✅ |
| Session persistence + resume | ✅ |
| Extended thinking (thinking blocks) | ✅ |
| Cost tracking + usage display | ✅ |
| Git integration | ✅ |
| Markdown terminal rendering (ANSI) | ✅ |
| Model aliases (opus/sonnet/haiku) | ✅ |
| Slash commands (/status, /compact, /clear, etc.) | ✅ |
| Hooks (PreToolUse/PostToolUse) | 🔧 Config only |
| Plugin system | 📋 Planned |
| Skills registry | 📋 Planned |
Model Aliases
Short names resolve to the latest model versions:
| Alias | Resolves To |
|---|---|
opus |
claude-opus-4-6 |
sonnet |
claude-sonnet-4-6 |
haiku |
claude-haiku-4-5-20251213 |
CLI Flags
claw [OPTIONS] [COMMAND]
Options:
--model MODEL Set the model (alias or full name)
--dangerously-skip-permissions Skip all permission checks
--permission-mode MODE Set read-only, workspace-write, or danger-full-access
--allowedTools TOOLS Restrict enabled tools
--output-format FORMAT Output format (text or json)
--version, -V Print version info
Commands:
prompt <text> One-shot prompt (non-interactive)
login Authenticate via OAuth
logout Clear stored credentials
init Initialize project config
doctor Check environment health
self-update Update to latest version
Slash Commands (REPL)
Tab completion now expands not just slash command names, but also common workflow arguments like model aliases, permission modes, and recent session IDs.
| Command | Description |
|---|---|
/help |
Show help |
/status |
Show session status (model, tokens, cost) |
/cost |
Show cost breakdown |
/compact |
Compact conversation history |
/clear |
Clear conversation |
/model [name] |
Show or switch model |
/permissions |
Show or switch permission mode |
/config [section] |
Show config (env, hooks, model) |
/memory |
Show CLAUDE.md contents |
/diff |
Show git diff |
/export [path] |
Export conversation |
/session [id] |
Resume a previous session |
/version |
Show version |
Workspace Layout
rust/
├── Cargo.toml # Workspace root
├── Cargo.lock
└── crates/
├── api/ # Anthropic API client + SSE streaming
├── commands/ # Shared slash-command registry
├── compat-harness/ # TS manifest extraction harness
├── runtime/ # Session, config, permissions, MCP, prompts
├── rusty-claude-cli/ # Main CLI binary (`claw`)
└── tools/ # Built-in tool implementations
Crate Responsibilities
- api — HTTP client, SSE stream parser, request/response types, auth (API key + OAuth bearer)
- commands — Slash command definitions and help text generation
- compat-harness — Extracts tool/prompt manifests from upstream TS source
- runtime —
ConversationRuntimeagentic loop,ConfigLoaderhierarchy,Sessionpersistence, permission policy, MCP client, system prompt assembly, usage tracking - rusty-claude-cli — REPL, one-shot prompt, streaming display, tool call rendering, CLI argument parsing
- tools — Tool specs + execution: Bash, ReadFile, WriteFile, EditFile, GlobSearch, GrepSearch, WebSearch, WebFetch, Agent, TodoWrite, NotebookEdit, Skill, ToolSearch, REPL runtimes
Stats
- ~20K lines of Rust
- 6 crates in workspace
- Binary name:
claw - Default model:
claude-opus-4-6 - Default permissions:
danger-full-access
License
See repository root.