Skip to content

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

Closed

Description

@ShayanMuhammad-CS

Server:

git (mcp-server-git)

Server Version / Environment:

  • Version: 2026.10.19 (Python SDK >=2.3,<3)
  • Transport: stdio
  • OS: Linux / macOS / Windows

Description & Motivation:

In mcp-server-git, tools accept repo_path (e.g., git_status, git_diff, git_commit, etc.).
When --repository <path> is passed at startup, validate_repo_path() rejects any tool calls outside the allowed repository root.

However, when launched without --repository (such as in standard client configurations like uvx mcp-server-git), allowed_repository defaults to None. In this mode, validate_repo_path() is a no-op, allowing any tool call to access and mutate any reachable Git repository across the host filesystem under the running user's process privileges (as pinned by test_without_repository_any_repository_is_reachable under #4550).

While this multi-repository reach is an intentional architectural capability, it is not prominently communicated to users in either the CLI --help or README.md. Users configuring the server may assume it is scoped only to the workspace or current directory.

Prompt Used to Generate the Change:

In src/git, clarify that omitting --repository leaves the server in unconfined mode where all reachable repositories on the filesystem are accessible to tool calls. 

1. In src/git/README.md, add an official GitHub alert (> [!WARNING]) under Configuration explaining that without --repository, every reachable Git repository is in scope, and describe how to confine operations via --repository <path>.
2. In src/git/src/mcp_server_git/__init__.py, update the Click option help text for --repository to: 'Git repository path to confine operations to. Without this option, every reachable repository is in scope.'
3. In src/git/src/mcp_server_git/server.py, update validate_repo_path's docstring to document the None behavior.
4. In src/git/tests/test_entrypoints.py, update test_main_help to assert that the confinement message is present in --help output.

Behavior Before vs. After:

Surface Before After
mcp-server-git --help -r, --repository PATH Git repository path -r, --repository PATH Git repository path to confine operations to. Without this option, every reachable repository is in scope.
src/git/README.md Generic text mentioning --repository resolves to top-level High-visibility GitHub alert > [!WARNING] detailing unconfined vs confined modes
server.py docstring Did not mention allowed_repository=None Explicitly states: "When allowed_repository is None, no restriction is configured and any reachable repository on the filesystem is permitted."
test_entrypoints.py Tested presence of -r, --repository Asserts confine operations to in output

Verification Steps:

  1. Ran python -m pytest tests/test_entrypoints.py -k test_main_help ➡️ PASSED
  2. Verified mcp_server_git --help output renders formatted lines cleanly.
  3. Verified test_main_without_repository_serves_none and test_python_dash_m_calls_main ➡️ PASSED.

Activity

  1. added
    documentationImprovements or additions to documentation
    server-gitReference implementation for the Git MCP server - src/git
    on Oct 29, 2026
  2. cliffhall commented on Oct 29, 2026

    @cliffhall
    Member

    Triage: Priority Low (total 3)

    Board: Servers V2 (#43), Status Incoming, awaiting maintainer review (no milestone yet).

  3. added this to the v2.4.0 milestone on Oct 29, 2026
  4. self-assigned this
    on Nov 5, 2026
  5. cliffhall commented on Nov 5, 2026

    @cliffhall
    Member

    Shipped in #5454 (merged to v2/main).

  6. added a commit that references this issue on Nov 11, 2026
    e07a11e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationserver-gitReference implementation for the Git MCP server - src/gitv2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions