Get the FREE Ultimate OpenClaw Setup Guide →

rust-analyzer

A Model Context Protocol (MCP) server that provides integration with rust-analyzer

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio zeenix-rust-analyzer-mcp rust-analyzer-mcp

How to use

This MCP server provides an integration layer for rust-analyzer, exposing a set of MCP-compatible tools that let you analyze Rust code, navigate symbols, and perform common IDE-like actions via AI assistants. Once running, you can query the server for symbol extraction, definitions, references, hover information, completions, formatting, code actions, diagnostics, and workspace-wide diagnostics. The server speaks the MCP protocol over stdio and is designed to work with Claude Code and other MCP clients by referencing the rust-analyzer-mcp binary in your PATH or by providing a direct path when built from source.

To use it, configure the MCP client to point at the rust-analyzer-mcp command. If you installed from crates.io, the command will typically be rust-analyzer-mcp in your PATH; if you built from source, use the full path to the binary (e.g., target/release/rust-analyzer-mcp or ~/.cargo/bin/rust-analyzer-mcp). Once connected, you can leverage the available tools under the rust_analyzer_* namespace (e.g., rust_analyzer_definition, rust_analyzer_hover, rust_analyzer_completion) to perform code analysis, navigation, and editing tasks directly from your prompts or UI.

How to install

Prerequisites:\n- Rust toolchain (rustc, cargo) and a compatible Rust environment.\n- rust-analyzer installed and available in PATH if you plan to use the executable wrapper.\n- Optional: a Rust project workspace for best results.\n\nStep 1: Install the MCP server binary\n- Option A: Install from crates.io (recommended)\n - cargo install rust-analyzer-mcp\n - This places rust-analyzer-mcp in your Cargo bin directory (usually ~/.cargo/bin).\n\n- Option B: Build from source\n - git clone https://github.com/zeenix/rust-analyzer-mcp.git\n - cd rust-analyzer-mcp\n - cargo build --release\n - The binary will be at target/release/rust-analyzer-mcp. You can also run cargo run during development.\n\nStep 2: Verify installation\n- Ensure the binary runs: rust-analyzer-mcp --version (or simply run the binary to see help output).\n- If you built from source, you can run: ./target/release/rust-analyzer-mcp.\n\nStep 3: Run in development or production mode\n- Development: cargo run (in the project root) or cargo run --release for optimized builds.\n- Production: Use the installed binary in your PATH (rust-analyzer-mcp).\n\nStep 4: Connect your MCP client\n- Point your MCP client to the rust-analyzer-mcp command. If you installed from crates.io, this should be available in PATH. If you built from source, provide the full path to the binary.

Additional notes

Tips and common issues:\n- Rust toolchain: Make sure you have Rust 1.70 or newer and Cargo installed.\n- rust-analyzer availability: Ensure rust-analyzer is installed and accessible in PATH if you rely on external tooling. You can install it via rustup component add rust-analyzer or cargo install rust-analyzer.\n- Workspace considerations: The server works best with a valid Cargo.toml workspace. Point the MCP client to the workspace root when analyzing a project.\n- Logging: For verbose output, run with RUST_LOG=debug to diagnose lint or analysis issues.\n- CLI configuration: If you’re embedding in Claude Code or Claude Desktop, you can configure the command in .mcp.json or the corresponding UI settings to point to rust-analyzer-mcp.\n- Updates: When upgrading, revalidate that the new binary path (or updated PATH) is reflected in your MCP client configuration.\n- Performance: Build in release mode for production deployments to reduce overhead.

Related MCP Servers

Sponsor this space

Reach thousands of developers