- Explore MCP Servers
- rust-mcp-server
Rust Mcp Server
What is Rust Mcp Server
rust-mcp-server is a Model Context Protocol server designed to provide essential Rust development tools such as syntax checking, linting, formatting, testing, and building for AI assistants and IDEs.
Use cases
Use cases include real-time syntax checking during coding, automated linting to catch common mistakes, formatting code according to style guidelines, running tests, and building Rust projects efficiently.
How to use
To use rust-mcp-server, clone the repository, build it using Cargo, and integrate it with your development environment, such as Claude Code, by adding it as a tool.
Key features
Key features include cargo_check for syntax and type validation, cargo_clippy for code linting, rustfmt for code formatting, cargo_test for executing tests, and cargo_build for building projects.
Where to use
rust-mcp-server can be used in software development environments, particularly for Rust programming, enhancing the capabilities of IDEs and AI assistants.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Rust Mcp Server
rust-mcp-server is a Model Context Protocol server designed to provide essential Rust development tools such as syntax checking, linting, formatting, testing, and building for AI assistants and IDEs.
Use cases
Use cases include real-time syntax checking during coding, automated linting to catch common mistakes, formatting code according to style guidelines, running tests, and building Rust projects efficiently.
How to use
To use rust-mcp-server, clone the repository, build it using Cargo, and integrate it with your development environment, such as Claude Code, by adding it as a tool.
Key features
Key features include cargo_check for syntax and type validation, cargo_clippy for code linting, rustfmt for code formatting, cargo_test for executing tests, and cargo_build for building projects.
Where to use
rust-mcp-server can be used in software development environments, particularly for Rust programming, enhancing the capabilities of IDEs and AI assistants.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Rust MCP Server
A Model Context Protocol (MCP) server that provides essential Rust development tools for AI assistants and IDEs. This server enables real-time syntax checking, linting, formatting, testing, and building of Rust projects through the standardized MCP interface.
Features
Available Tools
-
cargo_check - Syntax and type validation
- Validates Rust code syntax and type checking
- Supports workspace-wide checking
- Provides detailed error messages and suggestions
-
cargo_clippy - Code linting
- Catches common mistakes and suggests improvements
- Supports automatic fixes where possible
- Configurable lint levels and rules
-
rustfmt - Code formatting
- Formats Rust code according to style guidelines
- Can check formatting without applying changes
- Supports individual file or project-wide formatting
-
cargo_test - Test execution
- Runs Rust tests with detailed output
- Supports specific test patterns and packages
- Configurable output capture for debugging
-
cargo_build - Project building
- Builds Rust projects in debug or release mode
- Supports workspace builds
- Provides build status and error details
Installation
Prerequisites
- Rust toolchain (rustc, cargo, clippy, rustfmt)
- Tokio async runtime support
Build from source
git clone https://github.com/lh/rust-mcp-server
cd rust-mcp-server
cargo build --release
Claude Code Integration
Quick Install
# Clone and build the server
git clone https://github.com/lh/rust-mcp-server
cd rust-mcp-server
cargo build --release
# Add to Claude Code (adjust the project path as needed)
claude mcp add rust-tools -s user -- $(pwd)/target/release/rust-mcp-server --project-path ~/Code
# Verify installation
claude mcp list | grep rust-tools
Alternative Installation Methods
Using absolute path:
claude mcp add rust-tools -s user -- /path/to/rust-mcp-server/target/release/rust-mcp-server --project-path /path/to/your/rust/projects
Project-specific installation:
# Navigate to your Rust project
cd /path/to/your/rust/project
# Add the server with current directory as project path
claude mcp add rust-tools -s project -- /path/to/rust-mcp-server/target/release/rust-mcp-server --project-path .
Verify Connection
After installation, restart Claude Code and check the server status:
/mcp
You should see rust-tools: connected
in the list.
Usage
Command Line
# Run in current directory
./target/release/rust-mcp-server
# Specify project path
./target/release/rust-mcp-server --project-path /path/to/rust/project
Using with Claude Code
Once installed, you can use natural language to invoke Rust tools:
- “Check this Rust code for errors” → runs
cargo check
- “Lint my Rust project” → runs
cargo clippy
- “Format this Rust file” → runs
rustfmt
- “Run the tests” → runs
cargo test
- “Build the project in release mode” → runs
cargo build --release
MCP Integration
The server communicates via JSON-RPC over stdin/stdout following the MCP protocol:
Initialize
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {}
}
List Available Tools
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}
Execute Tool
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "cargo_check",
"arguments": {
"workspace": true
}
}
}
Tool Parameters
cargo_check
cargo_clippy
rustfmt
cargo_test
cargo_build
Output Format
All tools return standardized JSON responses:
{
"success": true,
"exit_code": 0,
"stdout": "compilation output...",
"stderr": "warnings and errors...",
"command": "cargo check"
}
Integration Examples
Claude Code Integration
This server is designed to work seamlessly with AI assistants like Claude Code, providing real-time feedback during code development:
- Syntax Validation: Automatically check code as it’s written
- Lint Suggestions: Get improvement suggestions and apply fixes
- Code Formatting: Ensure consistent code style
- Test Execution: Validate changes don’t break existing functionality
- Build Verification: Confirm project compiles successfully
VS Code Extension
Can be integrated with VS Code through MCP to provide enhanced Rust development experience alongside existing language servers.
Error Handling
The server provides detailed error information for:
- Invalid tool names
- Missing required parameters
- Compilation errors
- Process execution failures
- File system errors
Troubleshooting
Server Not Connecting
If you see connection errors in Claude Code:
-
Ensure the binary is built:
cd /path/to/rust-mcp-server cargo build --release ls -la target/release/rust-mcp-server # Should exist and be executable
-
Check the – separator:
# ✅ Correct claude mcp add rust-tools -- /path/to/rust-mcp-server/target/release/rust-mcp-server # ❌ Incorrect (missing --) claude mcp add rust-tools /path/to/rust-mcp-server/target/release/rust-mcp-server
-
Test the server manually:
cd /path/to/rust-mcp-server python3 test_server.py
-
Check logs:
Look for error messages when runningclaude --mcp-debug
Common Issues
- “cargo: command not found”: Ensure Rust is installed and in your PATH
- “failed to find cargo.toml”: Make sure
--project-path
points to a Rust project - Server disconnects immediately: Check that the binary path is absolute, not relative
- Server connects but no tools available: This was a bug in v0.1.0 where the server included
"error": null
in successful responses, violating JSON-RPC 2.0 spec. Fixed in v0.1.1.
Contributing
- Fork the repository
- Create a feature branch
- Implement your changes
- Add tests if applicable
- Submit a pull request
License
MIT License
Changelog
v0.1.1 (fix/json-rpc-error-field)
- Fixed JSON-RPC 2.0 compliance issue where
error: null
was incorrectly included in successful responses - This fix resolves connection issues with Claude Code where the server would connect but tools wouldn’t be available
- Added
#[serde(skip_serializing_if = "Option::is_none")]
to the error field in McpResponse
v0.1.0
- Initial release
- Core MCP server implementation
- Support for cargo check, clippy, rustfmt, test, and build
- JSON-RPC communication over stdin/stdout
- Configurable project path
- Comprehensive error handling
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.