Add rust-analyzer integration with find_rust_symbol MCP tool - #47
Open
hodgesds wants to merge 2 commits into
Open
Add rust-analyzer integration with find_rust_symbol MCP tool#47hodgesds wants to merge 2 commits into
hodgesds wants to merge 2 commits into
Conversation
Spawn rust-analyzer as a background child process (kill_on_drop, 30s request timeout) and attach it to DatabaseManager on Rust projects. Make WorkdirIndex::build[_incremental] and the workdir-refresh paths in query, lsp, and mcp binaries async.
Add the find_rust_symbol MCP tool backed by rust-analyzer's workspace/symbol lookup, including schema, category, dispatch, and an indexing-in-progress hint on empty results.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds rust-analyzer-backed symbol lookup to semcode. When the indexed repository
is a Rust project (has a
Cargo.toml), semcode spawnsrust-analyzeras abackground LSP process and exposes a new
find_rust_symbolMCP tool that answersworkspace/symbolqueries using rust-analyzer's exact type inference — moreprecise than the tree-sitter index for Rust code.
What's included
Async JSON-RPC rust-analyzer client (
src/rust_analyzer.rs)rust-analyzerover stdio with LSPContent-Lengthframing, dedicatedsender/reader tasks, and request routing via a oneshot map.
kill_on_dropand the handle retained, so the process isterminated with the client instead of being orphaned.
resultto callers.DatabaseManager integration (
src/database/connection.rs)attach_rust_analyzer()starts the client only when aCargo.tomlis present;the query, LSP, and MCP binaries attach on startup (MCP attaches in the
background to avoid blocking init).
find_rust_symbolMCP tool (src/bin/semcode-mcp.rs)code_lookupcategory with schema and dispatch.since
workspace/symbolreturns nothing until rust-analyzer finishes indexing.Async workdir index (
src/workdir.rs,query.rs,semcode-lsp.rs)WorkdirIndex::build[_incremental]and the workdir-refresh paths are now asyncto support the async client.
Testing
cargo fmt --check,cargo clippy --all-targets -- -D warnings: clean.cargo test: all passing, including new unit tests for JSON-RPC framing andrequest/notification serialization, and the updated MCP tool-count tests.