Skip to content

Commit 578c77e

Browse files
committed
Add initial readme
1 parent 1c98d9d commit 578c77e

5 files changed

Lines changed: 82 additions & 10 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/target
2+
.DS_Store
3+
.docs-cache

README.md

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,85 @@
1-
# Blah
1+
# Cursor Rust Tools
22

3-
## High Level calls
3+
A **MCP** server for cursor (and potentially other editors) to give them access to Rust
4+
documentation and Rust analyzer.
45

5-
- get implementation for symbol (name of symbol, line): returns the file
6-
- get documentation for symbol (name of symbol, line): returns the docs
7-
- resolve symbol (name of the symbol, file): will try to resolve the symbol and return the information it has on it
8-
- search docs
9-
- get errors
6+
Includes an UI for configuration.
107

11-
-> document symbols is always used first to retrieve individual symbols and fine the
12-
one with the highest match likelihood
8+
![media/example.png](media/example.png)
139

10+
## What it does
1411

15-
- [ ] start indexing when project is added
12+
Currently, various AI agents don't offer the AI the ability to access Rust type information from the LSP.
13+
This is a hurdle because instead of seeing the type, the LLM has to reason about the potential type.
14+
15+
In addition, the only information about the dependencies (say `tokio`) are what they were trained on which is
16+
out of date and potentially for a different version. This can lead to all kinds of issues.
17+
18+
`Cursor Rust Tools` makes these available over the Model Context Protocol (`MCP`).
19+
20+
- Get the documentation for a `crate` or for a specific symbol in the `crate` (e.g. `tokio` or `tokio::spawn`)
21+
- Get the hover information (type, description) for a specific symbol in a file
22+
- Get a list of all the references for a specific symbol in a file
23+
- Get the implementation of a symbol in a file (retrieves the whole file that contains the implementation)
24+
- Find a type just by name in a file the project and return the hover information
25+
- Get the output of `cargo test`
26+
- Get the output of `cargo check`
27+
28+
![media/screenshot.png](media/screenshot.png)
29+
30+
## How it works
31+
32+
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)
33+
34+
For documentation, it will run `cargo docs` and then parse the html documentation into markdown locally.
35+
This information is stored in the project root in the `.docs-cache` folder.
36+
37+
38+
39+
## Running it
40+
41+
### With UI
42+
43+
``` sh
44+
cargo run --release
45+
```
46+
47+
This will bring up a UI in which you can add projects, install the `mcp.json` and see the activity.
48+
49+
### Without UI
50+
51+
Alternatively, once you have a `~/.cursor-rust-tools` set up with projects, you can also just run it via
52+
53+
``` sh
54+
cargo run --release -- --no-ui
55+
```
56+
57+
## Configuration
58+
59+
In stead of using the UI to create a configuration, you can also set up `~/.cursor-rust-tools` yourself:
60+
61+
``` toml
62+
[[projects]]
63+
root = "/Users/terhechte/Developer/Rust/example1"
64+
ignore_crates = []
65+
66+
[[projects]]
67+
root = "/Users/terhechte/Developer/Rust/example2"
68+
ignore_crates = []
69+
```
70+
71+
`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.
72+
73+
## Configuring Cursor
74+
75+
One the app is running, you can configure Cursor to use it. This requires multiple steps.
76+
77+
1. Add a `project-dir/.cursor/mcp.json` to your project. The `Cursor Rust Tools` UI has a button to do that for you. Running it without UI will also show you the `mcp.json` contents in the terminal.
78+
2. As soon as you save that file, Cursor will detect that a new MCP server has been added and ask you to enable it. (in a dialog in the bottom right).
79+
3. You can check the Cursor settings (under `MCP`) to see where it is working correctly
80+
4. To test, make sure you have `Agent Mode` selected in the current `Chat`. And then you can ask it to utilize one of the new tools, for example the `cargo_check` tool.
81+
82+
![media/cursor.png](media/cursor.png)
83+
84+
**The contents of all the `mcp.json` is the same. Cursor Rust Tools figures out the correct project via
85+
the filepath**

media/cursor.png

136 KB
Loading

media/example.png

171 KB
Loading

media/screenshot.png

640 KB
Loading

0 commit comments

Comments
 (0)