Get the FREE Ultimate OpenClaw Setup Guide →

rust

Model Context Protocol server for Rust development tools (clippy, rustfmt, cargo check, cargo test)

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio lh-rust-mcp-server docker run -i lh-rust-mcp-server \
  --env RUST_MCP_PROJECT_PATH="Optional default project path for relative operations"

How to use

This MCP server provides a Rust development toolkit exposed via the MCP protocol. It implements tools for syntax checking, linting, formatting, testing, and building Rust projects: cargo_check validates syntax and type correctness (with optional workspace support), cargo_clippy performs linting with configurable levels and automatic fixes, rustfmt formats code (with an option to check formatting without applying changes), cargo_test runs tests with flexible filtering and capture options, and cargo_build compiles projects in either debug or release mode (supporting workspace builds). You can invoke these tools through Claude Code or any MCP-compatible client by listing available tools and issuing a tool call with the desired name and parameters. Typical usage includes running cargo_check across a workspace to ensure code health, linting with cargo_clippy to catch common mistakes, and formatting with rustfmt to maintain consistent style before commits. When integrated with Claude Code, natural language commands like “Check this Rust code for errors” or “Format this Rust file” will map to the corresponding MCP tool invocations.

To use the server in a session, first initialize the MCP connection, then list tools to confirm availability, and finally call the needed tools with appropriate parameters, e.g., cargo_check with workspace set to true for workspace-wide validation, or cargo_test to run targeted tests. The server returns standardized JSON responses detailing success, exit codes, and stdout/stderr, enabling you to surface actionable feedback in your editor or assistant workflow.

How to install

Prerequisites:

  • Rust toolchain (rustc, cargo, rustfmt, clippy) installed and available in PATH
  • Tokio async runtime support (as required by the server)

Build from source:

  1. Install Rust and set up the environment as per https://rust-lang.org
  2. Clone the repository: git clone https://github.com/lh/rust-mcp-server
  3. Build the server in release mode: cd rust-mcp-server cargo build --release
  4. (Optional) Run locally for testing: ./target/release/rust-mcp-server

If you’re integrating with Claude Code or another client, ensure the MCP wrapper is correctly exposed. The server is designed to be accessible through MCP-compatible tooling that can communicate via JSON-RPC over standard IO.

Additional notes

Tips and common issues:

  • Ensure the Rust toolchain is fully installed (cargo, rustc, clippy, rustfmt) and available in PATH to enable all tools.
  • If the server cannot connect in Claude Code, verify that the server binary path is absolute and that you’re using the correct --separator (e.g., -- before the binary path when invoking via Claude Code integration).
  • For workspace builds and checks, point the server to the correct project path with --project-path (when supported by the integration), and ensure Cargo.toml files exist for all workspace members.
  • If you encounter JSON-RPC errors, check that responses conform to the MCP 2.0 spec (avoid returning error: null in successful responses).
  • When using Claude Code, you can add the server under a custom name (e.g., rust-tools) and reference the binary path with project context to enable project-scoped operations.

Related MCP Servers

Sponsor this space

Reach thousands of developers