copilot 0.0.2

MCP Server for Cargo
<p align="center">
  <a href="https://pyk.sh">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://github.com/pyk/cargo-copilot/blob/main/.github/logo-dark.svg">
      <img alt="pyk/cargo-copilot logo" src="https://github.com/pyk/cargo-copilot/blob/main/.github/logo-light.svg">
    </picture>
  </a>
</p>

<p align="center">
  MCP Server for Rust
<p>

<p align="center">
  <img src="https://img.shields.io/crates/v/copilot.svg?colorA=00f&colorB=fff&style=flat&logo=rust" alt="Crates.io">
  <img src="https://img.shields.io/crates/d/copilot?colorA=00f&colorB=fff&style=flat&logo=rust" alt="Downloads">
  <img src="https://img.shields.io/github/license/pyk/cargo-copilot?colorA=00f&colorB=fff&style=flat" alt="MIT License">
</p>

## Getting started

`cargo-copilot` is a Model Context Protocol (MCP) server that gives LLMs access
to your local Cargo workspace context and documentation.

### Installation

Install the binary:

```sh
cargo install copilot
```

### Configuration

#### VSCode (with MCP Extension)

Configure `.vscode/mcp.json`:

```json
{
  "servers": {
    "cargo-copilot": {
      "command": "cargo",
      "args": ["copilot"]
    }
  }
}
```

## Tools

`cargo-copilot` allows the LLM to inspect dependencies and read local
documentation generated by `cargo doc`.

| Tool                 | Description                                                                                                                                             |
| :------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `cargo_dependencies` | Lists all available dependencies in the current workspace as crate ids (`name@version`). Useful for discovering what packages are available to inspect. |
| `cargo_doc_overview` | Fetches the main documentation page for a specific crate. It runs `cargo doc --package <name> --no-deps` internally to ensure docs are available.       |
| `cargo_doc_index`    | Lists all symbols (modules, macros, structs, enums, functions, types) found in a crate's generated documentation.                                       |
| `cargo_doc_get`      | Retrieves the full documentation for a specific symbol (e.g., `de/struct.Deserializer`) as Markdown.                                                    |

## Instructions

To get the best results, provide the following system prompt to your LLM:

```text
# CRITICAL: cargo-copilot Tool Usage

You have access to the `cargo-copilot` MCP server. Follow this strict workflow
to answer questions about the codebase:

1.  **Discovery**: Use `cargo_dependencies` to see available crates.
2.  **Overview**: Use `cargo_doc_overview` to understand a crate's purpose.
3.  **Lookup**: Use `cargo_doc_index` to find the generated documentation
    location for a symbol.
4.  **Retrieval**: Use `cargo_doc_get` to read the documentation.

**IMPORTANT CONSTRAINT**: Generated documentation paths (HTML) often differ from
logical Rust module paths due to re-exports.

- **NEVER guess** the `symbol_path` argument for `cargo_doc_get`.
- **ALWAYS** copy the `symbol_path` strictly verbatim from the output of
  `cargo_doc_index`.
- If a path like `model/struct.ServerInfo.html` fails, it means the symbol is
  documented elsewhere (e.g. `handler/server/struct.ServerInfo.html`). You must
  check the index.
```

## License

MIT. Use it for whatever.