rust-doctor

MCP Server

Use rust-doctor as an MCP server with Claude Code, Cursor, VS Code, and other AI tools.

What is MCP?

MCP (Model Context Protocol) is a standard for connecting AI assistants to external tools. rust-doctor includes a built-in MCP server that lets AI assistants scan your code, explain rules, and suggest fixes.

Setup

The fastest way to configure the MCP server for any supported agent:

rust-doctor setup

The wizard auto-detects installed agents (Claude Code, Cursor, Windsurf), lets you pick which ones to configure, and writes the correct config file automatically.

Claude Code

claude mcp add --transport stdio -s user rust-doctor -- npx -y rust-doctor --mcp

Cursor

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "rust-doctor": {
      "command": "npx",
      "args": ["-y", "rust-doctor", "--mcp"]
    }
  }
}

Windsurf

Add to ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "rust-doctor": {
      "command": "npx",
      "args": ["-y", "rust-doctor", "--mcp"]
    }
  }
}

VS Code

Add to .vscode/settings.json:

{
  "mcp": {
    "servers": {
      "rust-doctor": {
        "type": "stdio",
        "command": "npx",
        "args": ["-y", "rust-doctor", "--mcp"]
      }
    }
  }
}

Available tools

The MCP server exposes 4 read-only tools:

ToolDescription
scanScan a project directory — returns diagnostics + score
scoreQuick pass/fail — returns only the health score
explain_ruleExplain any rule by name with examples and fix guidance
list_rulesList all available checks with categories and severities

Prompts

The MCP server includes structured workflow prompts that guide AI assistants through complex tasks:

deep-audit

Comprehensive 6-phase expert audit that goes far beyond linting:

  1. Discovery — Explores codebase architecture, dependencies, patterns
  2. Static Analysis — Runs rust-doctor scan with full diagnostics
  3. Deep Code Review — Manual review against a 50+ item expert checklist (error handling, ownership, type design, async correctness, security hardening, dependency health)
  4. Best Practices Research — Searches the web for current Rust best practices relevant to the issues found
  5. Synthesis Report — Cross-references all findings into a structured report with before/after code
  6. Decision — Offers three choices: implement all fixes, generate a PRD, or manual prompt

health-check

Quick 4-phase workflow: scan → prioritized remediation plan (P0–P3) → confirmation → fix.

Security

The MCP server applies these security constraints:

  • Read-only — never modifies source files
  • Path restriction — scanned directory must be under $HOME
  • Timeout — 5-minute maximum per scan
  • Offline mode — network-dependent checks are disabled by default
  • No project config — ignores rust-doctor.toml to prevent config injection from untrusted projects
  • Path sanitization — absolute paths are stripped from error messages

On this page