Skip to content

MCP: exclude the same default dirs as the ruby gem#808

Open
bnferguson wants to merge 2 commits into
Shopify:mainfrom
bnferguson:mcp-exclude-default-dirs
Open

MCP: exclude the same default dirs as the ruby gem#808
bnferguson wants to merge 2 commits into
Shopify:mainfrom
bnferguson:mcp-exclude-default-dirs

Conversation

@bnferguson
Copy link
Copy Markdown

Background

When testing out the MCP Claude brought up that it was getting declarations appearing in search_declarations from my worktrees in the .claude dir. Digging a bit further in it seems that while the Ruby gem skips things via Rubydex::Graph::IGNORED_DIRECTORIES the MCP side had no such mechanism.

It looks like PR #712 added the excluded parameter to collect_file_paths. Then PR #713 wired exclusions into the Ruby Graph class. 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_DIRECTORIES over in Rust. Considered having it respect .gitignore but 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_directories

Another approach is tossing a .rb file in your .claude or node_modules and seeing if the declaration comes up when invoking search_declarations in the MCP.

Environment

  • rubydex-mcp: 0.1.0
  • rubydex gem: 0.2.3
  • OS: macOS (Darwin 25.x, Apple Silicon)

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.
@bnferguson bnferguson requested a review from a team as a code owner May 15, 2026 12:13
@bnferguson
Copy link
Copy Markdown
Author

I have signed the CLA!

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