MCP: exclude the same default dirs as the ruby gem#808
Open
bnferguson wants to merge 2 commits into
Open
Conversation
The MCP server walked the entire workspace root with an empty exclusion set, so directories like .claude, .git, and node_modules were indexed and surfaced in tool results. The Ruby gem already skips these via Graph::IGNORED_DIRECTORIES, but the MCP server bypasses the Ruby layer and calls collect_file_paths directly. Mirror that list in the MCP server and pass it to collect_file_paths so spawn_indexer skips the same directories.
Boots the MCP server against a workspace with a Ruby file under .claude/worktrees and asserts it is neither counted in codebase_stats nor returned by search_declarations, while a top-level file still is.
Author
|
I have signed the CLA! |
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.
Background
When testing out the MCP Claude brought up that it was getting declarations appearing in
search_declarationsfrom my worktrees in the.claudedir. Digging a bit further in it seems that while the Ruby gem skips things viaRubydex::Graph::IGNORED_DIRECTORIESthe MCP side had no such mechanism.It looks like PR #712 added the
excludedparameter tocollect_file_paths. Then PR #713 wired exclusions into the RubyGraphclass. But the MCP was never fully wired in.Approach
So that's what this PR is doing! Wire'n it in. Currently it mirrors/duplicates the
Rubydex::Graph::IGNORED_DIRECTORIESover in Rust. Considered having it respect.gitignorebut since that was already explored in the closed PR #205 (perhaps more to avoid the bringing in a new crate than the concept) and there was the existing concept in the Ruby gem, I decided to match that.Testing
There's an e2e test added that can be run with:
cargo test -p rubydex-mcp --test mcp mcp_server_skips_ignored_directoriesAnother approach is tossing a
.rbfile in your.claudeornode_modulesand seeing if the declaration comes up when invokingsearch_declarationsin the MCP.Environment
rubydex-mcp:0.1.00.2.3