fix(git): validate repo_path against current roots on every tool call#3631
Open
ctonneslan wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
fix(git): validate repo_path against current roots on every tool call#3631ctonneslan wants to merge 1 commit intomodelcontextprotocol:mainfrom
ctonneslan wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
Previously, call_tool only validated repo_path against the CLI --repository argument. When roots changed at runtime (e.g. client removes a root), a repo that was previously reachable could still be accessed in subsequent tool calls. Now validates repo_path against the full list of allowed repos (both roots and CLI) on every tool call, ensuring root changes revoke access immediately without requiring a restart. Fixes modelcontextprotocol#3613
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.
Problem
call_tool()validatesrepo_pathonly against the CLI--repositoryargument. When no CLI restriction is set (repository is None), all paths are allowed regardless of the current roots.If roots change at runtime (client removes a root), a repo that was previously reachable can still be accessed because
validate_repo_pathreturns immediately whenallowed_repository is None.Fix
Validate
repo_pathagainst the full list of allowed repos (both roots + CLI) on every tool call by callinglist_repos():This ensures:
Fixes #3613