MCP Server: resolve files against content roots for Bazel/IJwB projects#3483
Open
St0rmingBr4in wants to merge 2 commits intoJetBrains:masterfrom
Open
MCP Server: resolve files against content roots for Bazel/IJwB projects#3483St0rmingBr4in wants to merge 2 commits intoJetBrains:masterfrom
St0rmingBr4in wants to merge 2 commits intoJetBrains:masterfrom
Conversation
In Bazel projects using the IJwB plugin, `projectBasePath` points to the `.ijwb/` subdirectory, while all source files reside in the workspace root (the parent directory). This causes `resolveInProject()` to reject every source file as "outside of the project directory", breaking `get_symbol_info`, `get_file_problems`, and all other MCP tools that operate on files. Fix `resolveInProject()` to also try resolving paths against the project's content roots (via `ProjectRootManager`), and extend `findMostRelevantProject()` to match against content roots when looking up which project owns a given path. This unblocks MCP tool usage in large Bazel monorepos (e.g., via Claude Code, Cursor, or VS Code Copilot) where IJwB is the project type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5ea181f to
9ae51b0
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9ae51b0. Configure here.
…ting in findMostRelevantProject
- Normalize projectDirectory in allProjectRoots() so distinct() and
startsWith() work consistently with the already-normalized content roots
- Use the matched root path (not the input path) in findMostRelevantProject
pairs so sortedByDescending { nameCount } correctly prefers inner directories
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
Author
|
@nerzhulart @BartvHelvert I've addressed the issues Cursor Bugbot reported. I would appreciate a review. Thanks ! |
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.

In Bazel projects using the IJwB plugin,
projectBasePathpoints to the.ijwb/subdirectory, while all source files reside in the workspace root (the parent directory). This causesresolveInProject()to reject every source file as "outside of the project directory", breakingget_symbol_info,get_file_problems, and all other MCP tools that operate on files.Fix
resolveInProject()to also try resolving paths against the project's content roots (viaProjectRootManager), and extendfindMostRelevantProject()to match against content roots when looking up which project owns a given path.This unblocks MCP tool usage in large Bazel monorepos (e.g., via Claude Code, Cursor, or VS Code Copilot) where IJwB is the project type.
Note
Medium Risk
Changes project path resolution and ownership matching, which could affect which files are considered in-scope and how outside-project path checks behave. Main risk is inadvertently allowing or misresolving paths if content roots are misconfigured or unavailable at runtime.
Overview
MCP Server now treats IntelliJ content roots as additional in-project roots when resolving relative file paths, so Bazel/IJwB projects (where
projectBasePathis.ijwb/) can successfully access workspace source files.resolveInProject()will fall back to resolving against each content root (and validatesthrowWhenOutsideagainst all roots), andfindMostRelevantProject()can match an absolute path to an open project via eitherprojectBasePathor any content root.Reviewed by Cursor Bugbot for commit 9ae51b0. Bugbot is set up for automated code reviews on this repo. Configure here.