Skip to content

Commit 48edde6

Browse files
committed
docs(git): add MCP usage instructions for git_commit_signed
- Document how to call git_commit_signed via MCP and examples
1 parent 1d6eeea commit 48edde6

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

src/git/README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,29 @@ Please note that mcp-server-git is currently in early development. The functiona
4545
- `message` (string): Commit message
4646
- Returns: Confirmation with new commit hash
4747

48-
6. `git_add`
48+
6. `git_commit_signed`
49+
- Records changes to the repository and signs the commit with GPG
50+
- Inputs:
51+
- `repo_path` (string): Path to Git repository
52+
- `message` (string): Commit message
53+
- `key_id` (string, optional): GPG key ID to use for signing. If omitted, the default signing key configured in Git will be used.
54+
- Behavior: Uses the Git CLI `-S`/`--gpg-sign` flag to create a GPG-signed commit. This passes through to the system's `git` and `gpg` configuration, so GPG must be available and configured on the host.
55+
- Returns: Confirmation with new commit hash. If signing fails (for example, no GPG key is configured), the underlying Git command will raise an error.
56+
57+
7. `git_add`
4958
- Adds file contents to the staging area
5059
- Inputs:
5160
- `repo_path` (string): Path to Git repository
5261
- `files` (string[]): Array of file paths to stage
5362
- Returns: Confirmation of staged files
5463

55-
7. `git_reset`
64+
8. `git_reset`
5665
- Unstages all staged changes
5766
- Input:
5867
- `repo_path` (string): Path to Git repository
5968
- Returns: Confirmation of reset operation
6069

61-
8. `git_log`
70+
9. `git_log`
6271
- Shows the commit logs with optional date filtering
6372
- Inputs:
6473
- `repo_path` (string): Path to Git repository
@@ -67,34 +76,36 @@ Please note that mcp-server-git is currently in early development. The functiona
6776
- `end_timestamp` (string, optional): End timestamp for filtering commits. Accepts ISO 8601 format (e.g., '2024-01-15T14:30:25'), relative dates (e.g., '2 weeks ago', 'yesterday'), or absolute dates (e.g., '2024-01-15', 'Jan 15 2024')
6877
- Returns: Array of commit entries with hash, author, date, and message
6978

70-
9. `git_create_branch`
79+
10. `git_create_branch`
7180
- Creates a new branch
7281
- Inputs:
7382
- `repo_path` (string): Path to Git repository
7483
- `branch_name` (string): Name of the new branch
7584
- `base_branch` (string, optional): Base branch to create from (defaults to current branch)
7685
- Returns: Confirmation of branch creation
77-
10. `git_checkout`
86+
87+
11. `git_checkout`
7888
- Switches branches
7989
- Inputs:
8090
- `repo_path` (string): Path to Git repository
8191
- `branch_name` (string): Name of branch to checkout
8292
- Returns: Confirmation of branch switch
83-
11. `git_show`
93+
94+
12. `git_show`
8495
- Shows the contents of a commit
8596
- Inputs:
8697
- `repo_path` (string): Path to Git repository
8798
- `revision` (string): The revision (commit hash, branch name, tag) to show
8899
- Returns: Contents of the specified commit
89100

90-
12. `git_branch`
91-
- List Git branches
92-
- Inputs:
93-
- `repo_path` (string): Path to the Git repository.
94-
- `branch_type` (string): Whether to list local branches ('local'), remote branches ('remote') or all branches('all').
95-
- `contains` (string, optional): The commit sha that branch should contain. Do not pass anything to this param if no commit sha is specified
96-
- `not_contains` (string, optional): The commit sha that branch should NOT contain. Do not pass anything to this param if no commit sha is specified
97-
- Returns: List of branches
101+
13. `git_branch`
102+
- List Git branches
103+
- Inputs:
104+
- `repo_path` (string): Path to the Git repository.
105+
- `branch_type` (string): Whether to list local branches ('local'), remote branches ('remote') or all branches('all').
106+
- `contains` (string, optional): The commit sha that branch should contain. Do not pass anything to this param if no commit sha is specified
107+
- `not_contains` (string, optional): The commit sha that branch should NOT contain. Do not pass anything to this param if no commit sha is specified
108+
- Returns: List of branches
98109

99110
## Installation
100111

src/git/src/mcp_server_git/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ def git_commit_signed(repo: git.Repo, message: str, key_id: str | None = None) -
137137
repo.git.commit("-S" + key_id, "-m", message)
138138
else:
139139
repo.git.commit("-S", "-m", message)
140-
141140
# Get the commit hash of HEAD
142141
commit_hash = repo.head.commit.hexsha
143142
return f"Changes committed and signed successfully with hash {commit_hash}"
@@ -415,7 +414,7 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
415414

416415
case GitTools.COMMIT_SIGNED:
417416
result = git_commit_signed(
418-
repo,
417+
repo,
419418
arguments["message"],
420419
arguments.get("key_id")
421420
)

0 commit comments

Comments
 (0)