Skip to content

fix(git): resolve Windows permission errors during test repository teardown - #4220

Closed
STiFLeR7 wants to merge 1 commit into
modelcontextprotocol:mainfrom
STiFLeR7:feat/git-server-test-teardown-win
Closed

STiFLeR7 wants to merge 1 commit into
modelcontextprotocol:mainfrom
STiFLeR7:feat/git-server-test-teardown-win

Conversation

@STiFLeR7

Copy link
Copy Markdown

Description

Fixes a Windows-specific test teardown failure in mcp-server-git tests due to:

  1. Active file handles to the index and packfiles remaining open in the git.Repo instance, causing shutil.rmtree to raise PermissionError: [WinError 32].
  2. Git object files having read-only attributes on Windows, causing shutil.rmtree to raise PermissionError: [WinError 5].

Server Details

  • Server: git
  • Changes to: tests

Motivation and Context

Developers attempting to run python tests for mcp-server-git on Windows using uv run pytest encounter permission errors during the teardown of the test_repository fixture, which halts test suite completion. This fix resolves these issues, enabling local developer testing on Windows.

How Has This Been Tested?

We verified the fix by running the test suite locally on a Windows host using:

uv run pytest

All 41 tests passed successfully with no errors (previously, 35 out of 41 tests failed during the teardown phase with PermissionError).

Breaking Changes

  • None

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 follows MCP security best practices
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling

Additional context

  • Used the standard Windows onerror pattern with shutil.rmtree to clear the read-only attribute via os.chmod prior to file removal.
  • Explicitly called test_repo.close() to release all locks and file handles held by GitPython on the repo directory.

@STiFLeR7
STiFLeR7 force-pushed the feat/git-server-test-teardown-win branch from 1e43479 to af53c65 Compare May 21, 2026 06:39

@LuuOW LuuOW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Technical audit: Verified MCP server implementation for consistency with current SDK patterns.

@STiFLeR7
STiFLeR7 force-pushed the feat/git-server-test-teardown-win branch from af53c65 to 4910146 Compare June 26, 2026 06:21
@STiFLeR7
STiFLeR7 force-pushed the feat/git-server-test-teardown-win branch from 4910146 to 8fa1014 Compare July 6, 2026 04:52
@STiFLeR7
STiFLeR7 force-pushed the feat/git-server-test-teardown-win branch from 8fa1014 to c70bca7 Compare September 8, 2026 03:22
Copilot AI balanced review requested due to automatic review settings September 8, 2026 03:22

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cliffhall cliffhall added the closed-superseded-v2 Closed: fixed or made obsolete by the v2 / 2026-07-28 refactor (#4875) label Oct 20, 2026
@cliffhall

Copy link
Copy Markdown
Member

Thank you for this pull request, and apologies for the long wait for a response.

Since it was opened, the reference servers have been rebuilt for the 2026-07-28 MCP specification (#4857) and released as v2 (2.0.0 on npm for the TypeScript servers, 2026.10.19 on PyPI for the Python servers). The code this PR changes has been replaced, and the behavior it addresses has either been fixed in v2 or no longer exists in the same form.

This is not a judgment on the change or on you; it's a consequence of the code it targets having been replaced. If the problem still happens on v2, please open a fresh issue with the version you're running and steps to reproduce. Note that this repository now accepts contributions as issues rather than pull requests from anyone but its maintainers; see CONTRIBUTING.md.

This is part of the backlog triage in #4875.

@cliffhall cliffhall closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closed-superseded-v2 Closed: fixed or made obsolete by the v2 / 2026-07-28 refactor (#4875)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants