rust-mcp-server is a server that implements the Model Context Protocol (MCP). It acts as a bridge between a large language model (LLM) like GitHub Copilot and your local Rust development environment.
By exposing local tools and project context to the LLM, rust-mcp-server allows the model to perform actions on your behalf, such as building, testing, and analyzing your Rust code.
Integrating an LLM with your local development environment via rust-mcp-server can significantly enhance your productivity. The LLM can:
- Automate common tasks: Run
cargo check,cargo build,cargo test, andcargo fmtdirectly. - Manage dependencies: Add new dependencies with
cargo add, find unused dependencies withcargo-machete - Apply Rust best practices: Use
cargo clippyto lint your code and catch common mistakes, ensuring adherence to Rust guidelines. The LLM can also leverage other tools to help you write idiomatic and robust Rust code.
Essentially, it turns your AI assistant into an active participant in your development workflow, capable of executing commands and helping you manage your project.
rust-mcp-server exposes a comprehensive set of Rust development tools to the LLM:
cargo-build: Compile your packagecargo-check: Analyze the current package and report errors, but don't build itcargo-test: Run the testscargo-fmt: Format the code according to the project's stylecargo-clippy: Check for common mistakes and improve code quality using Clippycargo-clean: Clean the target directory
cargo-new: Create a new cargo packagecargo-generate_lockfile: Generate or update the Cargo.lock filecargo-list: List installed cargo commands
cargo-add: Add dependencies to yourCargo.tomlcargo-remove: Remove dependencies from yourCargo.tomlcargo-update: Update dependencies to newer versionscargo-metadata: Output project metadata in machine-readable format (JSON)cargo-search: Search for packages in the registrycargo-info: Display information about a package
cargo-deny-check: Check for security advisories, license compliance, and banned cratescargo-deny-init: Create a cargo-deny config from a templatecargo-deny-list: List all licenses and the crates that use themcargo-deny-install: Install cargo-deny toolcargo-machete: Find unused dependenciescargo-machete-install: Install cargo-machete tool
rustup-show: Show the active and installed toolchainsrustup-toolchain-add: Install or update toolchainsrustup-update: Update Rust toolchains and rustup
For a complete list with detailed descriptions and parameters, see tools.md.
- Rust: You need the Rust toolchain installed. You can get it from rustup.rs.
- [Optional] cargo-deny: Install with
cargo install cargo-deny. - [Optional] cargo-machete: Install with
cargo install cargo-machete.
- Clone this repository.
- Build the server in release mode:
The executable will be located at
cargo build --release
target/release/rust-mcp-server.exe.
The rust-mcp-server supports several command line arguments to customize its behavior:
- Description: Sets the timeout for processing a request in seconds
- Type: Integer
- Default: 600 (10 minutes)
- Example:
--timeout 300(5 minutes)
- Description: Sets the logging level for the server
- Type: String
- Options:
error,warn,info,debug,trace - Default:
info - Example:
--log-level debug
- Description: Specifies a file path for logging output. If not provided, logs are written to stderr
- Type: String (file path)
- Default: None (logs to stderr)
- Example:
--log-file /var/log/rust-mcp-server.log
- Description: Disables a specific tool by name. Can be specified multiple times to disable multiple tools
- Type: String (tool name)
- Default: None (all tools enabled)
- Example:
--disable-tool cargo-test --disable-tool cargo-clippy
- Description: Displays help information about available command line arguments
- Example:
rust-mcp-server --help
- Description: Displays the version information of the server
- Example:
rust-mcp-server --version
Basic usage with default settings:
rust-mcp-serverWith custom timeout and debug logging:
rust-mcp-server --timeout 300 --log-level debugWith file logging and disabled tools:
rust-mcp-server --log-file /tmp/mcp-server.log --disable-tool cargo-testTo make GitHub Copilot in VS Code use this MCP server, you need to update your VS Code settings.
-
Enable MCP server in VS Code settings - ⚙️chat.mcp.enabled
-
Add new MCP server into
.vscode/mcp.json.{ "servers": { "rust-mcp-server": { "type": "stdio", "command": "C:/path/to/your/rust-mcp-server.exe", "args": ["--log-file", "log/folder/rust-mcp-server.log"], } } }
More information you can find by this link.
This project uses mcp-discovery to automatically generate comprehensive documentation of all available MCP tools and capabilities.
Install mcp-discovery:
cargo install mcp-discoveryRun the documentation generation script to update the tools documentation:
python scripts/generate-docs.pyThis will regenerate tools.md with the latest tool descriptions and capabilities.
