Cargo MCP Server
Provides tools for interacting with Rust projects via Cargo, enabling automated builds, testing, linting, formatting, documentation generation, and dependency management.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Cargo MCP Serverrun the tests and then check the project with clippy"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Cargo MCP Server
A Model Context Protocol (MCP) server that provides tools for running Cargo commands. This server allows AI agents to interact with Rust projects through Cargo, enabling automated builds, tests, documentation generation, and more.
Features
The server provides the following Cargo tools:
cargo_build- Build a Rust project with Cargocargo_test- Run tests for a Rust projectcargo_run- Run a Rust binarycargo_check- Check a project for errors without buildingcargo_clippy- Run Clippy lintercargo_fmt- Format Rust code using rustfmtcargo_doc- Generate documentationcargo_clean- Clean build artifactscargo_tree- Display dependency treecargo_update- Update dependencies in Cargo.lockcargo_bench- Run benchmarks
Related MCP server: cursor-rust-tools
Installation
Prerequisites
Python 3.8 or higher
Rust and Cargo installed on your system
Access to install Python packages
Install from source
Clone this repository:
git clone <repository-url>
cd cargo-mcpInstall the package:
pip install -e .Usage
With Claude Desktop
Add the server to your claude_desktop_config.json:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"cargo-mcp": {
"command": "cargo-mcp"
}
}
}With other MCP clients
The server can be used with any MCP-compatible client. Start the server using:
cargo-mcpTesting with MCP Inspector
You can test the server using the MCP Inspector:
npx @modelcontextprotocol/inspector cargo-mcpTool Documentation
cargo_build
Build a Rust project with Cargo.
Parameters:
release(boolean, optional): Build in release mode with optimizationsfeatures(array, optional): List of features to activatetarget(string, optional): Build for the given target tripleworkspace_path(string, optional): Path to the workspace root (auto-detected if not provided)
cargo_test
Run tests for a Rust project.
Parameters:
test_name(string, optional): Name of specific test to runrelease(boolean, optional): Run tests in release modefeatures(array, optional): List of features to activateworkspace_path(string, optional): Path to the workspace root
cargo_run
Run a Rust binary.
Parameters:
bin_name(string, optional): Name of the binary to run (for multi-binary projects)args(array, optional): Arguments to pass to the binaryrelease(boolean, optional): Run in release modefeatures(array, optional): List of features to activateworkspace_path(string, optional): Path to the workspace root
cargo_check
Check a Rust project for errors without building it.
Parameters:
features(array, optional): List of features to activateworkspace_path(string, optional): Path to the workspace root
cargo_clippy
Run Clippy linter on a Rust project.
Parameters:
fix(boolean, optional): Automatically apply suggested fixesfeatures(array, optional): List of features to activateworkspace_path(string, optional): Path to the workspace root
cargo_fmt
Format Rust code using rustfmt.
Parameters:
check(boolean, optional): Check if files are formatted without modifying themworkspace_path(string, optional): Path to the workspace root
cargo_doc
Generate documentation for a Rust project.
Parameters:
open(boolean, optional): Open documentation in browser after generationno_deps(boolean, optional): Don't build documentation for dependenciesworkspace_path(string, optional): Path to the workspace root
cargo_clean
Clean build artifacts.
Parameters:
workspace_path(string, optional): Path to the workspace root
cargo_tree
Display dependency tree.
Parameters:
package(string, optional): Package to display tree forfeatures(array, optional): List of features to activateworkspace_path(string, optional): Path to the workspace root
cargo_update
Update dependencies in Cargo.lock.
Parameters:
package(string, optional): Specific package to updateworkspace_path(string, optional): Path to the workspace root
cargo_bench
Run benchmarks.
Parameters:
bench_name(string, optional): Name of specific benchmark to runfeatures(array, optional): List of features to activateworkspace_path(string, optional): Path to the workspace root
Project Structure Detection
The server automatically detects Rust projects by searching for Cargo.toml files. It walks up the directory tree from the current working directory to find the nearest Cargo.toml file and uses that directory as the workspace root.
You can override this behavior by providing the workspace_path parameter to any tool.
Error Handling
The server provides detailed error messages and logs for troubleshooting:
Checks if Cargo is installed and available in PATH
Validates that Cargo.toml exists in the target directory
Captures both stdout and stderr from Cargo commands
Provides detailed command execution information
Development
Setup
Clone the repository
Install development dependencies:
pip install -e ".[dev]"Testing
Run tests using pytest:
pytestCode Formatting
Format code using black:
black src/Lint code using ruff:
ruff check src/License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions:
Create an issue on GitHub
Check the MCP documentation for general MCP questions
This server cannot be deployed
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
A registry of AI agent tools — MCP servers, APIs, CLIs, SDKs — kept current by automated ingestion.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that provides AI tools with access to Rust documentation from docs.rs, enabling search for crates, documentation, type information, feature flags, version information, and source code.33-
- FlicenseNot gradedqualityCmaintenanceA MCP server to allow the LLM in Cursor to access Rust Analyzer, Crate Docs and Cargo Commands.83-
- AlicenseAqualityCmaintenanceAn MCP server that enables searching for Rust crates and their documentation from docs.rs, allowing AI agents to find required crates and access the latest documentation.476 npm38MIT
- FlicenseNot gradedqualityDmaintenanceA Docs.rs MCP server that enables AI models to deeply access Rust crate documentation, including searching crates, viewing API definitions, feature flags, and code examples, all within the editor.8 npm2-