Skip to content

Add cargo build and rename preview MCP tools#3

Merged
qkal merged 6 commits into
mainfrom
feat/rename-preview-build
May 24, 2026
Merged

Add cargo build and rename preview MCP tools#3
qkal merged 6 commits into
mainfrom
feat/rename-preview-build

Conversation

@qkal
Copy link
Copy Markdown
Owner

@qkal qkal commented May 23, 2026

Summary

  • add fixed cargo_build support with structured args, including release builds
  • add rust-analyzer rename preview plumbing and ra_rename_preview MCP tool
  • document cargo_build and ra_rename_preview in the root README

Test Plan

  • cargo fmt --check
  • git diff --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all
  • cargo test --test integration_basic mcp_tools_list_smoke_has_mvp_tools_and_protocol_stdout -- --nocapture
  • cargo test --test cargo_tests argument_construction -- --nocapture

Notes

  • docs/ remains gitignored and untracked.

Open in Devin Review

Summary by CodeRabbit

  • New Features

    • Added ra_rename_preview tool to preview rename edits before applying them
    • Added cargo_build tool for building Rust projects
    • Added --release flag support for cargo commands
  • Documentation

    • Updated documentation for all available tools with expanded parameter descriptions
    • Enhanced safety model to clarify that preview tools return edits only and never write to disk
    • Added troubleshooting guidance for rename preview and cargo tool issues

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Warning

Review limit reached

@qkal, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 36 minutes and 20 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e776993e-fce0-4765-aed7-9267090e333b

📥 Commits

Reviewing files that changed from the base of the PR and between 1e7634a and 799f4a7.

📒 Files selected for processing (1)
  • README.md
📝 Walkthrough

Walkthrough

The PR adds two new MCP tools to the Rust Analyzer MCP server: ra_rename_preview for previewing symbol renames without applying changes, and cargo_build for invoking cargo build with optional release mode. Changes include parameter types, LSP client rename support, workspace edit summarization, server tool implementations, integration tests, and updated documentation.

Changes

Rename Preview and Cargo Build Tools

Layer / File(s) Summary
Cargo build parameters and arguments
src/cargo/args.rs, src/cargo/params.rs
CargoCommandKind::Build variant added; CargoBuildParams gains release: Option<bool> field with corresponding argument generation for --release flag.
Cargo build tool and tests
src/server/mod.rs, tests/cargo_tests.rs
cargo_build tool implementation uses workspace-root resolution and shared cargo execution gating; tests updated to assert --release presence and new workspace-root behavior test added.
Rename preview parameters and validation
src/ra/params.rs
RenamePreviewParams struct defined with file location and rename-target fields; validate_rename_name rejects empty/whitespace-only and dash-prefixed names with comprehensive schema and validation tests.
Workspace edit summarization
src/ra/edits.rs
WorkspaceEditSummary struct and summarize_workspace_edit helper compute counts for affected documents, text changes, and resource operations across changes and DocumentChanges variants; unit tests cover all variants.
LSP rename capability
src/lsp/client.rs
RustAnalyzerClient::rename method sends textDocument/rename requests; LSP initialization advertises workspaceEdit.documentChanges and textDocument.rename capabilities.
Rename preview tool implementation
src/server/mod.rs
ra_rename_preview tool validates input, calls LSP rename, summarizes the workspace edit, and returns structured JSON with edit payload and operation counts; records "No rename edits returned" note when summary is empty.
Rename preview integration tests
tests/integration_basic.rs
Integration tests for LSP rename behavior, MCP ra_rename_preview tool invocation with retry logic, and input validation; verify workspace edit payload structure and renamed text content.
Documentation and re-exports
README.md, src/tools.rs
Tool descriptions, parameter schemas with release parameter, safety guarantees for preview-only tools, troubleshooting guidance for missing edits, and updated re-export formatting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • qkal/rustmcp#1: Establishes the cargo tool runner and MCP server plumbing that this PR extends by adding CargoCommandKind::Build and the cargo_build tool.

Poem

🐰 Hop, hop! The tools now dance—
Rename without a glance,
Build with polish, tests aligned,
Previews help the dev to find.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.59% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main changes: adding two new MCP tools (cargo_build and rename_preview) with clear, specific language.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rename-preview-build

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Line 5: The README currently says all `ra_*` tools are readonly but includes
`ra_set_workspace` which mutates server state; update the sentence to split into
two parts: list readonly analysis/edit-preview tools (e.g., `ra_hover`,
`ra_definitions`, `ra_references`, `ra_document_symbols`, `ra_completions`,
formatting edits, code actions, `ra_rename_preview`, diagnostics, workspace
diagnostics) and separately call out state-changing workspace control like
`ra_set_workspace` as a mutating operation that switches server workspace;
ensure `ra_rename_preview`, formatting and code action tools are explicitly
described as preview-only and do not mutate files, while `ra_set_workspace` is
described as performing state changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ce951627-330f-4a34-b2b3-0a7d14656039

📥 Commits

Reviewing files that changed from the base of the PR and between c277a04 and 1e7634a.

📒 Files selected for processing (10)
  • README.md
  • src/cargo/args.rs
  • src/cargo/params.rs
  • src/lsp/client.rs
  • src/ra/edits.rs
  • src/ra/params.rs
  • src/server/mod.rs
  • src/tools.rs
  • tests/cargo_tests.rs
  • tests/integration_basic.rs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test (windows-latest)
🔇 Additional comments (20)
README.md (1)

7-7: LGTM!

Also applies to: 217-230, 252-277, 283-283, 296-296, 347-347, 405-405, 430-433, 449-449

src/tools.rs (1)

11-12: LGTM!

src/cargo/args.rs (1)

11-11: LGTM!

Also applies to: 94-95, 117-117

src/cargo/params.rs (1)

20-20: LGTM!

Also applies to: 81-81

tests/cargo_tests.rs (1)

27-27: LGTM!

Also applies to: 53-60, 63-85, 92-92, 100-101, 328-340

src/server/mod.rs (1)

25-25: LGTM!

Also applies to: 30-30, 592-679, 814-830

src/ra/params.rs (3)

72-78: LGTM!


93-102: LGTM!


108-144: LGTM!

src/ra/edits.rs (4)

1-33: LGTM!


35-74: LGTM!


76-90: LGTM!


92-168: LGTM!

src/lsp/client.rs (3)

17-20: LGTM!


227-241: LGTM!


329-361: LGTM!

tests/integration_basic.rs (4)

86-138: LGTM!


176-194: LGTM!


204-319: LGTM!


321-382: LGTM!

Comment thread README.md Outdated
@qkal qkal merged commit 33a0394 into main May 24, 2026
4 checks passed
@qkal qkal deleted the feat/rename-preview-build branch May 24, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant