MX Rust CLI & MCP Server Quick Reference
Build Commands
# Build all (debug)cargo build
# Build all (release)cargo build --release
# Build specific cratecargo build -p mx-cli --releasecargo build -p mx-mcp-server --release
# Watch modecargo watch -x 'build -p mx-cli'Binary Locations
target/debug/mx # Debug CLItarget/debug/mx-mcp # Debug MCP servertarget/release/mx # Release CLItarget/release/mx-mcp # Release MCP serverRunning
# CLI./target/release/mx --help./target/release/mx doctor
# MCP Server./target/release/mx-mcpRUST_LOG=debug ./target/release/mx-mcp./target/release/mx-mcp --mech-crate-root /path # --no-rag skips the techniques corpusMCP Server Management
mx mcp build # Build MCP servermx mcp status # Corpus backend + doc/chunk countsmx mcp config # Show client configmx mcp run # Run the server interactivelyTechniques Corpus (pgvector)
mx rag ingest # Ingest docs/development into the corpusmx rag ingest --clear # Clear and re-ingestmx rag ingest --dry-run # Parse/chunk only (no DB or embeddings)mx rag status # Backend, doc/chunk counts, embedding modelTesting
cargo test # All testscargo test -p mx-lib # Specific cratecargo test test_name # Specific testcargo test -- --nocapture # With outputRUST_LOG=debug cargo test # With loggingLinting
cargo fmt # Format codecargo clippy -- -D warnings # Lint checkcargo fmt && cargo clippy && cargo test # Full checkWorkspace Structure
crates/├── mx-lib/ # Shared library (core logic)├── mx-cli/ # CLI binary (mx)└── mx-mcp-server/ # MCP server (mx-mcp)Adding a CLI Command
- Create
crates/mx-cli/src/commands/mycommand.rs - Add
pub mod mycommand;tocommands/mod.rs - Add variant to
Commandsenum inmain.rs - Add handler in
main()match
Adding an MCP Tool
- Add
MyToolvariant toToolHandlerenum - Add
ToolDefinitionindefine_all_tools() - Add handler case in
execute()match
Environment Variables
| Variable | Description |
|---|---|
MECH_CRATE_ROOT | MechCrate installation path |
MX_RAG_DATABASE_URL | Neon corpus URL (local Postgres fallback otherwise) |
OPENAI_API_KEY | Embedding API key (text-embedding-3-small) |
RUST_LOG | Log level (debug, info, warn, error) |
MCP Client Config (Claude Desktop)
{ "mcpServers": { "mechcrate": { "command": "/path/to/mx-mcp", "env": { "MECH_CRATE_ROOT": "/path/to/mech-crate" } } }}Key Files
| File | Purpose |
|---|---|
Cargo.toml | Workspace manifest |
crates/mx-cli/src/main.rs | CLI entry point |
crates/mx-mcp-server/src/main.rs | MCP entry point |
crates/mx-mcp-server/src/tools/mod.rs | Tool definitions (44 tools) |
crates/mx-lib/src/lib.rs | Library exports |
MCP Tool Categories
| Category | Count | Prefix |
|---|---|---|
| Global MX | 13 | mx_ |
| Project | 3 | mx_ |
| Make | 9 | make_ |
| Analysis | 4 | project_, service_ |
| RAG | 8 | rag_ |
| Unyform | 8 | unyform_ |
Debugging
# Verbose CLImx -v doctor
# Debug loggingRUST_LOG=debug mx new my-projectRUST_LOG=mx_lib::recipe=trace mx add api
# MCP debugRUST_LOG=debug ./target/release/mx-mcpCommon Issues
| Issue | Solution |
|---|---|
| Build errors | cargo clean && cargo build |
| MCP root not found | Set MECH_CRATE_ROOT |
| Corpus offline | Check mx rag status; start local pgvector or set MX_RAG_DATABASE_URL |
| RAG no results | mx rag ingest --clear |