Skip to content

docs(git): state --repository confinement in --help and validate_repo_path - #5454

Merged
cliffhall merged 1 commit into
v2/mainfrom
v2/docs/5230-git-repository-confinement-help
Nov 5, 2026
Merged

cliffhall merged 1 commit into
v2/mainfrom
v2/docs/5230-git-repository-confinement-help

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #5230

Description

mcp-server-git --help described --repository only as "Git repository path", so nothing in the CLI said that leaving it out puts every reachable repository in scope. This PR:

  • rewrites the --repository option's help (src/git/src/mcp_server_git/__init__.py) to say it confines operations to the repository (a path inside it selects the whole repository, matching the startup walk-up to the root) and that without it every repository the server process can reach is in scope;
  • documents the allowed_repository is None behavior in validate_repo_path's docstring (server.py; that docstring only);
  • extends test_main_help (tests/test_entrypoints.py) to assert both sentences appear in --help, comparing with whitespace collapsed because Click wraps option help to the terminal width.

The README half of the issue already shipped in #5225: src/git/README.md → Configuration carries the bolded "Without --repository, the server reads and writes any Git repository the server process can reach" paragraph, so the README is unchanged here rather than duplicating it.

Server Details

  • Server: git (mcp-server-git, Python)
  • Changes to: the --repository CLI help text, one docstring, one test. No tool, prompt, schema or behavior change.

Motivation and Context

#5230: users launching uvx mcp-server-git without --repository may assume the server is scoped to the workspace. The README now says otherwise (#5225); this brings --help in line.

How Has This Been Tested?

uv run --frozen mcp-server-git --help on this branch:

Usage: mcp-server-git [OPTIONS]

  MCP Git Server - Git functionality for MCP

Options:
  -r, --repository PATH  Git repository to confine operations to (a path
                         inside it selects the whole repository). Without this
                         option, every repository the server process can reach
                         is in scope.
  -v, --verbose
  --help                 Show this message and exit.

On v2/main the same line reads -r, --repository PATH Git repository path.

  • uv run --frozen pytest tests/test_entrypoints.py: 15 passed, including the extended test_main_help.
  • npm run local:gate: exit 0 (every stage, both languages, including the git server's coverage gate and the boot smoke).

No LLM client run: the change is the CLI help text and a docstring, neither of which an MCP client ever sees; the server's protocol surface is byte-for-byte unchanged.

Breaking Changes

None. The option's name, short form and behavior are unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follow MCP security best practices
  • I have updated the server's README accordingly (not applicable: the README warning already shipped in git: README should state plainly that without --repository every reachable repository is in scope #5225; nothing in it is inaccurate after this change)
  • I have added a changeset (npm run changeset) if this changes what a TypeScript server publishes (not applicable: Python server)
  • I have tested this with an LLM client (not applicable: help text and a docstring only, invisible to an MCP client)
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling (not applicable: no new code paths)
  • I have documented all environment variables and configuration options

🤖 Generated with Claude Code

…_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 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall cliffhall added the v2 label Nov 5, 2026
@changeset-bot

changeset-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e07a11e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the CLI help and documentation updates clarifying repository access scope.

No open issues 🎉

What changed in this PR

Clarifies the Git server’s repository access scope in CLI help and internal documentation, complementing the README warning from #5225 and addressing the remaining work in #5230. Runtime behavior and the MCP interface are unchanged.

Changes:

  • Explains that --repository confines operations to the whole enclosing repository, while omitting it permits access to any repository the process can reach.
  • Documents the unrestricted allowed_repository=None behavior.
  • Extends the help-output test with whitespace-normalized assertions.
File Description
src/​git/​tests/​test_entrypoints.py Verifies confinement and unrestricted-scope wording in CLI help.
src/​git/​src/​mcp_server_git/​server.py Documents unrestricted path validation when no repository is configured.
src/​git/​src/​mcp_server_git/​__init__.py Expands --repository help to explain access scope.

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1: clean (no comments, no suppressed findings). Loop converged on the first clean round; no further round requested. CI on e07a11e is green.

@cliffhall
cliffhall merged commit c77bff9 into v2/main Nov 5, 2026
41 checks passed
@cliffhall
cliffhall deleted the v2/docs/5230-git-repository-confinement-help branch November 5, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(git): clarify unconfined default scope and repository confinement options in README and CLI

2 participants