Add Git Branch tool to mcp-server-git#1943
Merged
olaservo merged 8 commits intomodelcontextprotocol:mainfrom Jun 25, 2025
Merged
Add Git Branch tool to mcp-server-git#1943olaservo merged 8 commits intomodelcontextprotocol:mainfrom
olaservo merged 8 commits intomodelcontextprotocol:mainfrom
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`.
Contributor
Author
|
@dsp-ant This PR is ready, would u please help review and merge it? |
olaservo
requested changes
Jun 25, 2025
Member
olaservo
left a comment
There was a problem hiding this comment.
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`.
Contributor
Author
|
@olaservo Hi ola, all conflicts resolved! |
olaservo
approved these changes
Jun 25, 2025
PazerOP
referenced
this pull request
in PazerOP/mcp-template
Jul 15, 2025
Add Git Branch tool to mcp-server-git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
:)