ZR

zeenix/rust-analyzer-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

91 stars 23 forks 质量 74 趋势 15MIT

zeenix/rust-analyzer-mcp 是从 https://github.com/zeenix/rust-analyzer-mcp. 导入的 MCP 服务器候选

概览

zeenix/rust-analyzer-mcp 是从 https://github.com/zeenix/rust-analyzer-mcp. 导入的 MCP 服务器候选

概述(AI 翻译)

这是一个模型上下文协议(MCP)服务器,提供与 Rust-analyzer 集成,允许 AI助手可以分析Rust代码,获取悬浮信息,查找定义、参考文献等。 用Rust编写,以实现最佳性能和原生集成。

先修条件

  1. 防锈分析仪:确保防锈分析仪已安装并可用在您的PATH中

  2. Rust:版本1.70及以上,带货运

  3. A Rust 项目:服务器在有效的 Rust 工作区(包含 Cargo.toml)时工作效果最佳

为什么是Rust?

这种Rust实现相比其他实现具有多项优势:

  • 性能:原生Rust二进制,开销最小
  • 内存安全:内存问题不会导致运行时错误
  • 生态系统集成:非常适合Rust开发工作流程
  • 小二进制大小:带LTO优化的版本
  • 并发安全:Tokio异步运行时高效处理多个请求
  • 原生LSP处理:直接集成Rust-analyzer协议

安装

来自 crates.io(推荐)

直接从 crates.io 安装:

二进制文件会安装到你的Cargo bin目录(通常是’~/.’

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

rust-analyzer MCP Server

This is a Model Context Protocol (MCP) server that provides integration with rust-analyzer, allowing AI assistants to analyze Rust code, get hover information, find definitions, references, and more. Written in Rust for optimal performance and native integration.

Prerequisites

  1. rust-analyzer: Make sure rust-analyzer is installed and available in your PATH

    # Install via rustup (recommended)
    rustup component add rust-analyzer
    
    # Or install directly
    cargo install rust-analyzer
    
    # Verify installation
    rust-analyzer --version
    
  2. Rust: Version 1.70 or higher with Cargo

  3. A Rust project: The server works best with a valid Rust workspace (containing Cargo.toml)

Why Rust?

This Rust implementation offers several advantages over alternative implementations:

  • Performance: Native Rust binary with minimal overhead
  • Memory Safety: No runtime errors from memory issues
  • Ecosystem Integration: Perfect fit for Rust development workflows
  • Small Binary Size: Optimized release builds with LTO
  • Concurrent Safety: Tokio async runtime handles multiple requests efficiently
  • Native LSP Handling: Direct integration with rust-analyzer’s protocol

Installation

From crates.io (Recommended)

Install directly from crates.io:

cargo install rust-analyzer-mcp

The binary will be installed to your Cargo bin directory (usually ~/.cargo/bin/rust-analyzer-mcp).

From Source

  1. Clone the repository:

    git clone https://github.com/zeenix/rust-analyzer-mcp.git
    cd rust-analyzer-mcp
    
  2. Build the project:

    cargo build --release
    
  3. The binary will be available at target/release/rust-analyzer-mcp

Configuration

Claude Code Configuration

Add an MCP server configuration to one of these locations:

Option 1: Project-specific (.mcp.json in your Rust project root):

{
  "mcpServers": {
    "rust-analyzer": {
      "command": "rust-analyzer-mcp"
    }
  }
}

Option 2: User-wide (~/.claude.json or ~/.claude/settings.json):

{
  "mcpServers": {
    "rust-analyzer": {
      "command": "rust-analyzer-mcp"
    }
  }
}

Note: If you installed from crates.io, the command will be in your PATH. If you built from source, use the full path to the binary. You can also configure servers using Claude Code’s CLI wizard too.

Claude Desktop Configuration

Add this to your Claude Desktop configuration (claude_desktop_config.json):

{
  "mcpServers": {
    "rust-analyzer": {
      "command": "rust-analyzer-mcp"
    }
  }
}

Note: If installed from crates.io, the command will be in your PATH. For Claude Desktop, you may want to specify a cwd parameter if you want to analyze a specific project by default.

Cargo features

By default rust-analyzer analyses and checks your crate with whatever features its manifest makes

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "rust-analyzer": { "command": "rust-analyzer-mcp" } } }