Provides safe, cargo-oriented MCP operations like build, test, lint, and run inside a controlled context.
Configuration
View docs{
"mcpServers": {
"jbr-cargo-mcp": {
"command": "/path/to/cargo-mcp/cargo-mcp",
"args": [
"serve"
],
"env": {
"CARGO_MCP_DEFAULT_TOOLCHAIN": "YOUR_TOOLCHAIN"
}
}
}
}You can safely access and orchestrate Rust project operations from your editor or IDE through a dedicated MCP server. It exposes common Cargo tasks in a controlled environment, enabling you to run checks, format, test, build, and more without leaving your workspace.
Connect your MCP client to the Cargo MCP Server you configured. Use the client’s MCP configuration to point at the local or remote server and enable the desired tools. You can run checks, format, lint, build, bench, add or remove dependencies, clean artifacts, and execute binaries in the context of your Rust project. All commands run against the target project directory and only whitelisted Cargo operations are allowed for safety.
Prerequisites: you need a Rust toolchain installed on your system. Ensure you have Rust and Cargo available in your shell.
Install the MCP server command for Cargo by running the following command in your terminal.
cargo install cargo-mcpThe server exposes a set of Cargo tools that you can invoke through the MCP client. Each tool supports a configurable environment via the cargo_env parameter and can specify a rust toolchain through the toolchain parameter.
If you encounter issues connecting to the server, verify the MCP client configuration matches the server’s address and that the cargo-mcp toolchain is available in the environment. Ensure your current directory contains Cargo.toml so path validation can confirm a valid Rust project.
Verify code compiles without producing executables by running cargo check in the target project.
Run the Clippy linter to provide code quality suggestions and potential fixes.
Execute the project's tests using cargo test.
Check code formatting without modifying files using cargo fmt -- --check.
Build the project in either debug or release mode using cargo build or cargo build --release.
Run benchmark suites with cargo bench to measure performance.
Add dependencies to Cargo.toml using cargo add.
Remove dependencies from Cargo.toml using cargo remove.
Update dependencies to the latest compatible versions with cargo update.
Remove artifacts produced by Cargo to reclaim space with cargo clean.
Run a binary or example package using cargo run.