MechCrate CLI Quick Reference
Build Commands
# Build all (debug)cargo build
# Build all (release)cargo build --release
# Build specific cratecargo build -p mx-clicargo build -p mx-mcp-servercargo build -p mx-lib
# Watch and rebuildcargo watch -x 'build -p mx-cli'Test Commands
# All testscargo test
# Specific cratecargo test -p mx-lib
# With outputcargo test -- --nocaptureQuality Commands
# Formatcargo fmt
# Lintcargo clippy
# All checkscargo fmt && cargo clippy && cargo testBinaries
| Binary | Location | Purpose |
|---|---|---|
mx | target/release/mx | Main CLI |
mx-mcp | target/release/mx-mcp | MCP server for AI agents |
Crate Structure
crates/├── mx-lib/ # Shared library (use from CLI and MCP)├── mx-cli/ # CLI commands└── mx-mcp-server/ # MCP JSON-RPC serverAdding a Command (Checklist)
- Create
crates/mx-cli/src/commands/mycommand.rs - Add
pub mod mycommand;tocommands/mod.rs - Add import in
main.rs - Add variant to
Commandsenum - Add handler in
match cli.command - Build and test:
cargo build -p mx-cli && ./target/debug/mx mycommand --help
Adding an MCP Tool (Checklist)
- Add logic to
mx-libif needed - Add
ToolHandler::MyToolvariant intools/mod.rs - Add
ToolDefinitioninregister_tools() - Add execute handler in
execute_tool() - Build and test:
cargo build -p mx-mcp-server
Key Imports
// CLI commandsuse anyhow::Result;use clap::Args;use console::style;use dialoguer::{Select, Input, Confirm};
// Shared libraryuse mx_lib::{templates_dir, is_initialized, home_dir};use mx_lib::recipe::RecipeInstaller;use mx_lib::project::ProjectDetector;Debug Logging
RUST_LOG=debug mx doctorRUST_LOG=mx_lib=trace mx new my-projectPath Resolution Priority
MECH_CRATE_ROOTenv var~/.mech-crate/templates- Relative to executable
Installation Workflow
# 1. Buildcargo build --release
# 2. Initialize (copies templates to ~/.mech-crate)# MECH_CRATE_ROOT only needed for first init from dev environmentMECH_CRATE_ROOT=$(pwd) ./target/release/mx init
# 3. Use anywhere - no env vars needed!./target/release/mx recipes list./target/release/mx doctor./target/release/mx new my-projectCommon Commands
mx init # Install MechCrate templatesmx init --update # Update templates (keep config)mx doctor # Check system healthmx recipes list # List available recipesmx new myproject # Create new projectmx add api --recipe rust-api # Add service with recipemx router install # Install global Traefikmx router up # Start routermx mcp build # Build MCP servermx rag ingest # Ingest docs/development into the techniques corpusmx upgrade --dry-run # Preview project upgrade