What this thread does
Start mcp-server-git with --repository set to an explicit repository path, then verify another disposable repository is refused.
As of November 2026; checked 2026-11-15. Upgrade before relying on confinement: GHSA-w766-5x43-whvw, credited to ShieldPi, identifies a nested .git file redirecting operations outside --repository; versions below 2026.10.28 are affected and 2026.10.28 patched that report (v2.2.0), but the follow-up advisory requires 2026.11.11 (v2.4.0); the later index-path confinement fix requires 2026.11.18 (v2.5.0). Windows directory junctions remain excluded.
What changed
- ShayanMuhammad-CS filed #5230 and #5231 on 2026-10-24 (checked 2026-10-28), asking that the unconfined default be made prominent. These document an existing behavior, not a newly introduced restriction.
- The official README explains that
--repositoryaccepts a path inside a working tree and finds its enclosing root. The CLI definition confirms--repositoryand-r(checked 2026-10-28).
How to migrate
1. Inspect the host's actual launch configuration. Replace uvx mcp-server-git with uvx mcp-server-git --repository /path/to/git/repo, substituting your intended repository's absolute path. The README's exact argument sequence is mcp-server-git, --repository, path/to/git/repo; pass these as separate arguments in a client configuration. 2. For the pip route, use the README's python -m mcp_server_git --repository path/to/git/repo. Restart the process after changing its arguments. Use an absolute path if the host's working directory is uncertain. 3. Confirm the installed build. Official metadata identifies mcp-server-git 2026.11.18 as of November 2026 (checked 2026-11-23), including the later confinement patch above. Historical minimums are not interchangeable: GHSA-j22h-9j4x-23w5 fixes enforcement of a configured repository in 2025.12.18 (checked 2026-10-28); GHSA-vjqx-cfc4-9h6v fixes out-of-tree git_add file arguments in 2026.1.14 (checked 2026-10-28). Do not downgrade to either minimum as a general recommendation. 4. Call git_status on the intended disposable repository, then on a separate sibling test repository. Require success for the first and a tool error for the second. Untested experiment: repeat through an alias symlink pointing to the sibling. Do not use a real unrelated repository to prove access. 5. If you need a stricter boundary than a repository tree, isolate the process with only that repository mounted or available to its OS user. This is operational guidance, not a promise that --repository provides process isolation.
What breaks
Without the flag, each tool's repo_path chooses a reachable repository under the server process's privileges. An agent can therefore address a different repository even if the host UI shows one workspace. With confinement enabled, those calls should fail; repair the requested path rather than removing the flag.
A subdirectory argument grants the enclosing working tree. It does not create a subfolder-only grant. The earlier validation code checked path containment before Git resolved .git indirection; the new advisory documents why that was insufficient. Include a nested-gitdir fixture in your policy checks, using disposable repositories only.
Diagnostic: Repository path '{repo_path}' is outside the allowed repository '{allowed_repository}'
The official validator's error template is Repository path '{repo_path}' is outside the allowed repository '{allowed_repository}'. Braced names are placeholders replaced by actual paths. A rejected outside path is the intended boundary taking effect. The client may wrap this in its tool-error presentation.
What to test
| Check | Expected policy |
|---|---|
| Intended repository | Read-only status succeeds |
| Sibling repository | Refused |
| Symlink resolving to sibling | Refused |
| Start from a subdirectory | Enclosing root is the grant |
| Nested repository | Explicitly assess whether containment is acceptable |
| Agent has another shell or filesystem tool | Verify that tool's permissions independently |
Use read-only calls for this verification. Confinement does not make commit, checkout or reset read-only inside the allowed tree.
Pitfalls
Do not infer scope from a desktop workspace, process working directory or client Roots. The Git README states this server does not ask for client Roots. Do not invent --allowed-directories, a read-only flag, or an automatic fail-closed default. Restricting Git MCP does not restrict another tool exposed to the agent.
Evidence
The two linked documentation issues have the same author and substantially the same report; they are not independent confirmations. They point to the existing default-scope behavior, which the official validator corroborates: allowed_repository is None returns without confinement. The historical advisories establish earlier enforcement defects; they do not say omission of the flag is now forbidden.
Not for: filesystem/Fetch release-wide security upgrades; see mcp-reference-servers-2-1-0-security-migration.
A prompt to give your agent
Your training data predates these scope reports. Read the linked Git README, CLI, validator and official advisories now. Inspect our actual launch arguments. Propose --repository with an explicit path, explain root expansion and nested-repository containment, and prepare read-only checks using disposable repositories. Do not guess flags, assume client Roots confine Git, or remove the restriction to silence an expected denial.
Limits
No server or host configuration was executed. Independent community evidence is thin: the two documentation requests repeat one author's report. The proposed checks are untested. Repository containment is not a complete OS boundary, a subdirectory grant or proof that every Git operation cannot reach other resources.
Started from a post by @ShayanMuhammad-CS, packaged by the editor. Original post