Skip to main content
Glama

cursor-rust-tools

by terhechte

光标 Rust 工具

MCP服务器允许 Cursor 中的 LLM 访问 Rust Analyzer、Crate Docs 和 Cargo Commands。

包括用于配置的 UI。

媒体/示例.png

它的作用

目前,各种 AI 代理均不支持 AI 从 LSP 访问 Rust 类型信息。这带来了一个障碍,因为 LLM 无法直接看到类型,而是需要推理出潜在的类型。

此外,关于依赖项(例如tokio )的唯一信息是它们所训练的内容,而这些信息已经过时,并且可能是其他版本。这可能会导致各种问题。

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

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

媒体/屏幕截图.png

工作原理

对于 LSP 功能src/lsp它会启动一个新的 Rust 分析器,像编辑器中运行的一样索引你的代码库。我们无法查询编辑器中运行的 Rust 分析器,因为 Rust 分析器只能由单个用户使用(例如, open document操作需要按正确的顺序close document ,等等)。

对于文档,它将运行cargo docs ,然后在本地将 HTML 文档解析为 Markdown 格式。此信息存储在项目根目录的.docs-cache文件夹中。

安装

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

使用 UI 运行

cursor-rust-tools

这将打开一个 UI,您可以在其中添加项目、安装mcp.json并查看活动。

无 UI 运行

或者,一旦你在项目中设置了~/.cursor-rust-tools ,你也可以通过以下方式运行它

cursor-rust-tools --no-ui

配置

除了使用 UI 创建配置之外,您还可以自己设置~/.cursor-rust-tools

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

ignore_crates是一个 crate 依赖项名称列表,这些名称你不想被索引到文档中。例如,因为它们太大了。

配置光标

应用程序运行时,您可以配置 Cursor 来使用它。这需要多个步骤。

  1. project-dir/.cursor/mcp.json文件添加到你的项目中。Cursor Cursor Rust Tools UI 中有一个按钮可以帮你完成此操作。即使不通过 UI 运行它,终端中也会显示mcp.json内容。
  2. 一旦您保存该文件,Cursor 将检测到已添加新的 MCP 服务器并要求您启用它。(在右下角的对话框中)。
  3. 您可以检查光标设置(在MCP下)以查看其是否正常工作
  4. 要进行测试,请确保在当前Chat中选择了Agent Mode 。然后,您可以要求它使用其中一个新工具,例如cargo_check工具。
  5. 您可能需要添加游标规则,以告知法学硕士 (LLM) 尽可能优先使用这些工具。我仍在尝试这个方法。

媒体/光标.png

所有mcp.json的内容都相同。Cursor Rust Tools 通过文件路径找到正确的项目

打开待办事项

  • [ ] 创建一个Zed扩展以允许使用这个
  • [ ] 正常关机,无错误
  • [ ] 目前删除项目有点困难(在 UI 中)
  • [ ] 公开更多 LSP 命令
  • [ ] 允许 LLM 执行Grit 操作
-
security - not tested
F
license - not found
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

MCP 服务器允许 Cursor 中的 LLM 访问 Rust Analyzer、Crate Docs 和 Cargo Commands。

  1. 它的作用
    1. 工作原理
      1. 安装
        1. 使用 UI 运行
        2. 无 UI 运行
      2. 配置
        1. 配置光标
          1. 打开待办事项

            Related MCP Servers

            • -
              security
              A
              license
              -
              quality
              MCP server for toolhouse.ai. This does not rely on an external llm unlike the official server.
              Last updated -
              1
              Python
              MIT License
            • A
              security
              A
              license
              A
              quality
              An MCP server that enables secure terminal command execution, directory navigation, and file system operations through a standardized interface for LLMs.
              Last updated -
              10
              58
              Python
              MIT License
              • Apple
            • -
              security
              F
              license
              -
              quality
              An MCP server that allows Claude and other LLMs to manage persistent memories across conversations through text file storage, enabling commands to add, search, delete and list memory entries.
              Last updated -
              2
              TypeScript
            • -
              security
              F
              license
              -
              quality
              An MCP server that provides AI tools with access to Rust documentation from docs.rs, enabling search for crates, documentation, type information, feature flags, version information, and source code.
              Last updated -
              3
              TypeScript

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/terhechte/cursor-rust-tools'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server