mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-17 23:53:24 +02:00
feat: Add git branch functionality and unit tests
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`.
This commit is contained in:
@@ -16,14 +16,16 @@ Please note that mcp-server-git is currently in early development. The functiona
|
||||
|
||||
2. `git_diff_unstaged`
|
||||
- Shows changes in working directory not yet staged
|
||||
- Input:
|
||||
- Inputs:
|
||||
- `repo_path` (string): Path to Git repository
|
||||
- `context_lines` (number, optional): Number of context lines to show (default: 3)
|
||||
- Returns: Diff output of unstaged changes
|
||||
|
||||
3. `git_diff_staged`
|
||||
- Shows changes that are staged for commit
|
||||
- Input:
|
||||
- Inputs:
|
||||
- `repo_path` (string): Path to Git repository
|
||||
- `context_lines` (number, optional): Number of context lines to show (default: 3)
|
||||
- Returns: Diff output of staged changes
|
||||
|
||||
4. `git_diff`
|
||||
@@ -31,6 +33,7 @@ Please note that mcp-server-git is currently in early development. The functiona
|
||||
- Inputs:
|
||||
- `repo_path` (string): Path to Git repository
|
||||
- `target` (string): Target branch or commit to compare with
|
||||
- `context_lines` (number, optional): Number of context lines to show (default: 3)
|
||||
- Returns: Diff output comparing current state with target
|
||||
|
||||
5. `git_commit`
|
||||
@@ -297,12 +300,13 @@ If you are doing local development, there are two ways to test your changes:
|
||||
"mcpServers": {
|
||||
"git": {
|
||||
"command": "uv",
|
||||
"args": [
|
||||
"args": [
|
||||
"--directory",
|
||||
"/<path to mcp-servers>/mcp-servers/src/git",
|
||||
"run",
|
||||
"mcp-server-git"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user