TC

terhechte/cursor-rust-tools

开发工具

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

83 stars 13 forks 质量 43 趋势 14

terhechte/cursor-rust-tools 是从 https://github.com/terhechte/cursor-rust-tools. 导入的 MCP 服务器候选

概览

terhechte/cursor-rust-tools 是从 https://github.com/terhechte/cursor-rust-tools. 导入的 MCP 服务器候选

概述(AI 翻译)

一个MCP服务器,允许光标中的LLM在 访问Rust分析仪、箱子文件和货物命令。

包含一个配置界面。

它的作用

目前,各种AI代理并不允许AI访问LSP中Rust类型的信息。 这是一个障碍,因为LLM不是看到类型,而是要推理潜在类型的情况。

此外,关于依赖关系(比如tokio)的唯一信息是它们训练的对象,也就是 过时了,可能还会有不同版本。这会导致各种问题。

Cursor Rust Tools 通过模型上下文协议(MCP)提供这些功能。

  • 获取crate或crate中特定符号的文档(例如tokio或tokio::spawn)
  • 获取文件中特定符号的悬停信息(类型、描述)
  • 获取文件中特定符号的所有引用列表
  • 获取文件中符号的实现(检索包含该实现的整个文件)
  • 在项目文件中仅按名称查找类型,返回悬停信息
  • 得到 cargo test 的输出
  • 得到 cargo check 的输出

它是如何运作的

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

README

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

Cursor Rust Tools

A MCP server to allow the LLM in Cursor to access Rust Analyzer, Crate Docs and Cargo Commands.

Includes an UI for configuration.

What it does

Currently, various AI agents don’t offer the AI the ability to access Rust type information from the LSP. This is a hurdle because instead of seeing the type, the LLM has to reason about the potential type.

In addition, the only information about the dependencies (say tokio) are what they were trained on which is out of date and potentially for a different version. This can lead to all kinds of issues.

Cursor Rust Tools makes these available over the Model Context Protocol (MCP).

  • Get the documentation for a crate or for a specific symbol in the crate (e.g. tokio or tokio::spawn)
  • Get the hover information (type, description) for a specific symbol in a file
  • Get a list of all the references for a specific symbol in a file
  • Get the implementation of a symbol in a file (retrieves the whole file that contains the implementation)
  • Find a type just by name in a file the project and return the hover information
  • Get the output of cargo test
  • Get the output of cargo check

How it works

For the LSP functionality src/lsp it spins up a new Rust Analyzer that indexes your codebase just like the on running in your editor. We can’t query the one running in the editor because Rust Analyzer is bound to be used by a single consumer (e.g. the open document action requires a close document in the right order, etc)

For documentation, it will run cargo docs and then parse the html documentation into markdown locally. This information is stored in the project root in the .docs-cache folder.

Installation

cargo install --git https://github.com/terhechte/cursor-rust-tools

Run With UI

cursor-rust-tools

This will bring up a UI in which you can add projects, install the mcp.json and see the activity.

Run Without UI

Alternatively, once you have a ~/.cursor-rust-tools set up with projects, you can also just run it via

cursor-rust-tools --no-ui

Configuration

In stead of using the UI to create a configuration, you can also set up ~/.cursor-rust-tools yourself:

[[projects]]
root = "/Users/terhechte/Developer/Rust/example1"
ignore_crates = []

[[projects]]
root = "/Users/terhechte/Developer/Rust/example2"
ignore_crates = []

ignore_crates is a list of crate dependency names that you don’t want to be indexed for documentation. For example because they’re too big.

Configuring Cursor

One the app is running, you can configure Cursor to use it. This requires multiple steps.

在 GitHub 查看完整 README

安装

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

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