-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Add Git Branch tool to mcp-server-git #1943
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
This commit introduces the `git branch` tool to the MCP Git server, allowing users to list branches with various filtering options. Changes include: - Implemented `git_branch` function in `src/git/src/mcp_server_git/server.py` to support listing local, remote, and all branches, as well as filtering by `contains` and `not_contains` SHA values. - Added comprehensive unit tests for the `git branch` functionality in `src/git/tests/test_server.py`, covering different branch types and commit filtering scenarios. - Updated `src/git/README.md`.
|
@dsp-ant This PR is ready, would u please help review and merge it? |
olaservo
left a comment
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.
Hi, thanks for the PR! Looks like there is one minor conflict to resolve after merging in some updates to deprecated Pydantic functions from another recent merge. Other than that LGTM. 👍
This commit introduces the `git branch` tool to the MCP Git server, allowing users to list branches with various filtering options. Changes include: - Implemented `git_branch` function in `src/git/src/mcp_server_git/server.py` to support listing local, remote, and all branches, as well as filtering by `contains` and `not_contains` SHA values. - Added comprehensive unit tests for the `git branch` functionality in `src/git/tests/test_server.py`, covering different branch types and commit filtering scenarios. - Updated `src/git/README.md`.
|
@olaservo Hi ola, all conflicts resolved! |
Add Git Branch tool to mcp-server-git
Description
This commit introduces the
git branchtool to the MCP Git server, allowing model to read branch info with various filtering options.git branchtool enable model to:This functionality enhances the server's capabilities by providing comprehensive branch management options.
Server Details
src/git/src/mcp_server_git/server.py(add newgit branchtool)src/git/tests/test_server.py(add corresponding unit test)src/git/README.md(addgit branchintroduction)Motivation and Context
Our team have benefit a lot from mcp-server-git when need models to interact with our private code hosting platform. Everything works perfectly except model cannot access git branch info using this server.
When giving prompt like
Check if commit 3339591a is already on branch A, if not, apply this commit to this branch manuallyorDo I have a branch with 'dev' in its name? If so, checkout to it., the agent will firstly try to check if specified branch exists. It will struggle to call this server multiple times, and fail each time, of course. and then attempt to use terminal to achieve this goal(Not every time will it use terminal as its last choice, sometimes it may try to call the tool for more than 10 times, which brings us a really bad experience).So we add this
git branchtool to solve this problem, everything works perfectly, and we hope to share this little new tool to those who meet same problems like we do :)How Has This Been Tested?
Comprehensive unit tests have been added for the git branch functionality in
test_server.py, covering different branch types and commit filtering scenarios. These tests ensure the correct behavior of the new git_branch tool.Plus, we've tested this new feature with mainstream models like Claude, GPT, Gemini, etc. Alongwith LLM clients like Cursor and Trae.
This new feature works properly with these models, clients, and can cooperate well with other tools within this server.
Breaking Changes
No, this change introduces new functionality and does not break existing configurations.
Types of changes
Checklist
Additional context
:)