Skip to content

Commit e07a11e

Browse files
cliffhallclaude
andcommitted
docs(git): state --repository confinement in --help and validate_repo_path
The --repository option's help text read only "Git repository path", so --help never said that omitting it leaves every reachable repository in scope. The help now says the option confines operations to the repository (any path inside it selects the whole repository) and that without it every repository the server process can reach is in scope. validate_repo_path's docstring documents the allowed_repository=None behavior, and test_main_help asserts the new text. The README warning already shipped in #5225. Closes #5230 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 281b167 commit e07a11e

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎src/git/src/mcp_server_git/__init__.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66

77

88
@click.command()
9-
@click.option("--repository", "-r", type=Path, help="Git repository path")
9+
@click.option(
10+
"--repository",
11+
"-r",
12+
type=Path,
13+
help=(
14+
"Git repository to confine operations to (a path inside it selects the"
15+
" whole repository). Without this option, every repository the server"
16+
" process can reach is in scope."
17+
),
18+
)
1019
@click.option("-v", "--verbose", count=True)
1120
def main(repository: Path | None, verbose: bool) -> None:
1221
"""MCP Git Server - Git functionality for MCP"""

‎src/git/src/mcp_server_git/server.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,13 @@ def git_show(repo: git.Repo, revision: str) -> str:
549549

550550

551551
def validate_repo_path(repo_path: Path, allowed_repository: Path | None) -> None:
552-
"""Validate that repo_path is within the allowed repository path."""
552+
"""Validate that repo_path is within the allowed repository path.
553+
554+
`allowed_repository` is the repository root `--repository` resolved to at
555+
startup. When it is None (the server was started without `--repository`),
556+
no restriction is configured and this check passes for every path, so a
557+
tool call may reach any repository the server process can reach.
558+
"""
553559
if allowed_repository is None:
554560
return # No restriction configured
555561

‎src/git/tests/test_entrypoints.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ def test_main_help():
173173
assert "MCP Git Server - Git functionality for MCP" in result.output
174174
assert "-r, --repository PATH" in result.output
175175
assert "-v, --verbose" in result.output
176+
# Click wraps option help to the terminal width, so compare with the
177+
# whitespace collapsed rather than against one rendered line.
178+
help_text = " ".join(result.output.split())
179+
assert "Git repository to confine operations to" in help_text
180+
assert (
181+
"Without this option, every repository the server process can reach is in scope."
182+
in help_text
183+
)
176184

177185

178186
# --------------------------------------------------------------------------

0 commit comments

Comments
 (0)