DR

dexwritescode/rust-mcp

开发工具

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

37 stars 17 forks 质量 59 趋势 0MIT

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

概览

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

概述(AI 翻译)

一个全面的模型上下文协议(MCP)服务器,提供 Rust-analyzer 集成,用于 LLM 辅助的 Rust 开发。该服务器使 Claude 等 AI 工具能够通过 Rust-analyzer 的语言服务器协议功能,以惯用方式处理 Rust 代码,避免字符串操作,提供智能代码分析和重构。

快速启动

  1. 构建:cargo build --release
  2. 配置你的MCP客户端使用target/release/rustmcp
  3. **通过AI助手使用,带有自然语言提示,比如“用调试生成用户结构,克隆派生”

功能 - 完整工具套件(19 个工具)

代码分析(4个工具)

  • find_definition - 导航至符号定义
  • find_references - 查找所有符号的用途
  • get_diagnostics - 获取编译器错误/警告并修复
  • workspace_symbols - 搜索项目符号

代码生成(4个工具)

  • generate_struct - 创建带有衍生和构造子的结构
  • generate_enum - 创建带有变体的枚举
  • generate_trait_impl - 生成带有存根的特征实现
  • generate_tests - 创建单元或集成测试模板

重构(5个工具)

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

README

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

Rust MCP Server

A comprehensive Model Context Protocol (MCP) server that provides rust-analyzer integration for LLM-assisted Rust development. This server enables AI tools like Claude to work with Rust code idiomatically through rust-analyzer’s Language Server Protocol capabilities, avoiding string manipulation and providing intelligent code analysis and refactoring.

Quick Start

  1. Build: cargo build --release
  2. Configure your MCP client to use target/release/rustmcp
  3. Use through AI assistants with natural language prompts like “Generate a User struct with Debug and Clone derives”

Features - Complete Tool Suite (19 Tools)

Code Analysis (4 tools)

  • find_definition - Navigate to symbol definitions
  • find_references - Find all symbol uses
  • get_diagnostics - Get compiler errors/warnings with fixes
  • workspace_symbols - Search project symbols

Code Generation (4 tools)

  • generate_struct - Create structs with derives and constructors
  • generate_enum - Create enums with variants
  • generate_trait_impl - Generate trait implementations with stubs
  • generate_tests - Create unit or integration test templates

Refactoring (5 tools)

  • rename_symbol - Rename with scope awareness
  • extract_function - Extract code into functions
  • inline_function - Inline function calls
  • organize_imports - Sort and organize use statements
  • format_code - Apply rustfmt formatting

Quality Assurance (2 tools)

  • apply_clippy_suggestions - Apply clippy automatic fixes
  • validate_lifetimes - Check lifetime and borrow checker issues

Project Management (2 tools)

  • analyze_manifest - Parse and analyze Cargo.toml
  • run_cargo_check - Execute cargo check with error parsing

Advanced Features (4 tools)

  • get_type_hierarchy - Get type relationships for symbols
  • suggest_dependencies - Recommend crates based on code patterns
  • create_module - Create new Rust modules with visibility control
  • move_items - Move code items between files

Additional Advanced Tools

  • change_signature - Modify function signatures safely

Prerequisites

  • Rust toolchain (1.70+)
  • rust-analyzer installed (defaults to ~/.cargo/bin/rust-analyzer)
  • An MCP-compatible client (Claude, Roo, etc.)

Installation

  1. Clone this repository:
git clone 
cd rust-mcp
  1. Build the server:
cargo build --release
  1. The server binary will be available at target/release/rustmcp

Configuration

Environment Variables

The server supports the following environment variables:

  • RUST_ANALYZER_PATH - Path to rust-analyzer binary (default: ~/.cargo/bin/rust-analyzer)

You can set this when running the server:

RUST_ANALYZER_PATH=/usr/local/bin/rust-analyzer ./target/release/rustmcp
在 GitHub 查看完整 README

安装

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

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

配置

{ "mcpServers": { "rust-analyzer": { "command": "/path/to/rust-mcp/target/release/rustmcp", "args": [], "env": { "RUST_ANALYZER_PATH": "/custom/path/to/rust-analyzer" } } } }