-
Notifications
You must be signed in to change notification settings - Fork 5
Multi-Repository Support for Git MCP Server #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My LLM says your LLM did a pretty good job, and tests look good and are green, so let's merge! 😉
README.md
Outdated
./git-mcp-go serve -r /path/to/git/repository | ||
|
||
# Run with multiple repositories using comma-separated values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomholford Would be great to tone down the duplication here a bit
README.md
Outdated
./git-mcp-go setup -r /path/to/git/repository | ||
|
||
# Set up with multiple repositories using comma-separated values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well
README.md
Outdated
} | ||
} | ||
``` | ||
|
||
For backward compatibility, the following still works for a single repository: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can me dropped I think
@tomholford Please take a quick look at the comments and rebase, happy to merge after. |
This commit refactors the Git MCP server to support monitoring multiple Git repositories simultaneously. Key changes include: - Changed GitServer.repoPath from string to repoPaths []string - Added repository validation and path resolution logic - Updated cmd/server.go to accept multiple repos via args and --repositories flag - Updated cmd/setup.go to configure multiple repositories in Cline - Added git_list_repositories tool to show available repositories - Modified all handler functions to use new repository resolution logic - Updated tests to work with multiple repositories The server maintains backward compatibility with the single-repository approach via the -r/--repository flag.
This commit updates the README.md with comprehensive documentation for the multi-repository feature: - Add git_list_repositories to the list of tools - Update command line structure with new flags and arguments - Add a Multi-Repository Support section explaining options - Update serve and setup command examples with multiple repos - Add Repository Management section explaining tool and selection - Update the configuration examples for multiple repositories This documentation covers all the ways users can work with multiple repositories and explains the repository selection logic.
This commit adds comprehensive 8000 tests for the multi-repository feature: - TestGitListRepositories: Verifies the git_list_repositories tool works correctly by checking the output contains all repositories - TestRepositorySelection: Tests the repository selection logic for default selection, specific selection, and invalid paths - TestOperationsAcrossMultipleRepositories: Ensures operations work correctly when targeting different repositories and properly error when given invalid repositories These tests help ensure that the multi-repository feature works correctly in all scenarios and maintains the expected behavior.
This commit simplifies the repository flag handling to provide a better user experience: - Changed -r/--repository from StringVar to StringSliceVar to support both comma-separated values and multiple flag instances - Removed separate --repositories flag in favor of the more versatile --repository flag - Updated the documentation to reflect the new usage patterns - Fixed the setup command to configure Cline with the new flag format - Made error messages and help text clearer These changes make it easier to specify multiple repositories while maintaining backward compatibility with existing usage patterns.
- Update verifyFileExpectations to use partial path matching for configuration files - Look for files containing the important path suffix after "globalStorage/" - Maintain OS independence by using the same verification logic across platforms - Improve test logging to better understand what files are found
- Add validation for empty repository paths with clear error message - Update setupTool to handle single repository case differently for test compatibility - Use --repository format for single repository case to match test expectations - Use -r format for multiple repositories case for consistency with other commands
553d6fc
to
c1cefcb
Compare
This addresses PR review feedback
Thanks for the review. Rebased and addressed feedback 👍 |
@tomholford Thanks for you contribution! |
This PR adds multi-repository support, allowing the Git MCP Server to monitor and operate on multiple repositories simultaneously. Users can now specify multiple repositories in several flexible ways, and a new tool has been added to list all available repositories.
Resolves #2
Key Features
Multiple Repository Specification:
-r=/path/to/repo1,/path/to/repo2
-r=/path/to/repo1 -r=/path/to/repo2
serve /path/to/repo1 /path/to/repo2
Intelligent Repository Selection:
New Tool:
git_list_repositories
:Backward Compatibility:
Implementation Details
GitServer
to store an array of repository paths instead of a single path-r/--repository
fromStringVar
toStringSliceVar
to support multiple valuesTesting
Automated tests have been added to verify:
git_list_repositories
tool functions correctlyTest with Claude Desktop
I also tested with Claude Desktop 0.8.1 / Sonnet 3.7 with this config in
claude_desktop_config.json
:And here is the conversation:
Usage Examples
This feature significantly improves the user experience when working with multiple repositories, making the Git MCP Server more versatile and efficient.