mcp-server-git 2025.1.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ __pycache__
2
+ .venv
@@ -0,0 +1 @@
1
+ 3.10
@@ -0,0 +1,38 @@
1
+ # Use a Python image with uv pre-installed
2
+ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS uv
3
+
4
+ # Install the project into `/app`
5
+ WORKDIR /app
6
+
7
+ # Enable bytecode compilation
8
+ ENV UV_COMPILE_BYTECODE=1
9
+
10
+ # Copy from the cache instead of linking since it's a mounted volume
11
+ ENV UV_LINK_MODE=copy
12
+
13
+ # Install the project's dependencies using the lockfile and settings
14
+ RUN --mount=type=cache,target=/root/.cache/uv \
15
+ --mount=type=bind,source=uv.lock,target=uv.lock \
16
+ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
17
+ uv sync --frozen --no-install-project --no-dev --no-editable
18
+
19
+ # Then, add the rest of the project source code and install it
20
+ # Installing separately from its dependencies allows optimal layer caching
21
+ ADD . /app
22
+ RUN --mount=type=cache,target=/root/.cache/uv \
23
+ uv sync --frozen --no-dev --no-editable
24
+
25
+ FROM python:3.12-slim-bookworm
26
+
27
+ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
28
+
29
+ WORKDIR /app
30
+
31
+ COPY --from=uv /root/.local /root/.local
32
+ COPY --from=uv --chown=app:app /app/.venv /app/.venv
33
+
34
+ # Place executables in the environment at the front of the path
35
+ ENV PATH="/app/.venv/bin:$PATH"
36
+
37
+ # when running the container, add --db-path and a bind mount to the host's db file
38
+ ENTRYPOINT ["mcp-server-git"]
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2024 Anthropic, PBC.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,280 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-server-git
3
+ Version: 2025.1.14
4
+ Summary: A Model Context Protocol server providing tools to read, search, and manipulate Git repositories programmatically via LLMs
5
+ Author: Anthropic, PBC.
6
+ Maintainer-email: David Soria Parra <davidsp@anthropic.com>
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: automation,git,llm,mcp
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: click>=8.1.7
17
+ Requires-Dist: gitpython>=3.1.43
18
+ Requires-Dist: mcp>=1.0.0
19
+ Requires-Dist: pydantic>=2.0.0
20
+ Description-Content-Type: text/markdown
21
+
22
+ # mcp-server-git: A git MCP server
23
+
24
+ ## Overview
25
+
26
+ A Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.
27
+
28
+ Please note that mcp-server-git is currently in early development. The functionality and available tools are subject to change and expansion as we continue to develop and improve the server.
29
+
30
+ ### Tools
31
+
32
+ 1. `git_status`
33
+ - Shows the working tree status
34
+ - Input:
35
+ - `repo_path` (string): Path to Git repository
36
+ - Returns: Current status of working directory as text output
37
+
38
+ 2. `git_diff_unstaged`
39
+ - Shows changes in working directory not yet staged
40
+ - Input:
41
+ - `repo_path` (string): Path to Git repository
42
+ - Returns: Diff output of unstaged changes
43
+
44
+ 3. `git_diff_staged`
45
+ - Shows changes that are staged for commit
46
+ - Input:
47
+ - `repo_path` (string): Path to Git repository
48
+ - Returns: Diff output of staged changes
49
+
50
+ 4. `git_diff`
51
+ - Shows differences between branches or commits
52
+ - Inputs:
53
+ - `repo_path` (string): Path to Git repository
54
+ - `target` (string): Target branch or commit to compare with
55
+ - Returns: Diff output comparing current state with target
56
+
57
+ 5. `git_commit`
58
+ - Records changes to the repository
59
+ - Inputs:
60
+ - `repo_path` (string): Path to Git repository
61
+ - `message` (string): Commit message
62
+ - Returns: Confirmation with new commit hash
63
+
64
+ 6. `git_add`
65
+ - Adds file contents to the staging area
66
+ - Inputs:
67
+ - `repo_path` (string): Path to Git repository
68
+ - `files` (string[]): Array of file paths to stage
69
+ - Returns: Confirmation of staged files
70
+
71
+ 7. `git_reset`
72
+ - Unstages all staged changes
73
+ - Input:
74
+ - `repo_path` (string): Path to Git repository
75
+ - Returns: Confirmation of reset operation
76
+
77
+ 8. `git_log`
78
+ - Shows the commit logs
79
+ - Inputs:
80
+ - `repo_path` (string): Path to Git repository
81
+ - `max_count` (number, optional): Maximum number of commits to show (default: 10)
82
+ - Returns: Array of commit entries with hash, author, date, and message
83
+
84
+ 9. `git_create_branch`
85
+ - Creates a new branch
86
+ - Inputs:
87
+ - `repo_path` (string): Path to Git repository
88
+ - `branch_name` (string): Name of the new branch
89
+ - `start_point` (string, optional): Starting point for the new branch
90
+ - Returns: Confirmation of branch creation
91
+ 8. `git_checkout`
92
+ - Switches branches
93
+ - Inputs:
94
+ - `repo_path` (string): Path to Git repository
95
+ - `branch_name` (string): Name of branch to checkout
96
+ - Returns: Confirmation of branch switch
97
+ 9. `git_show`
98
+ - Shows the contents of a commit
99
+ - Inputs:
100
+ - `repo_path` (string): Path to Git repository
101
+ - `revision` (string): The revision (commit hash, branch name, tag) to show
102
+ - Returns: Contents of the specified commit
103
+
104
+ ## Installation
105
+
106
+ ### Using uv (recommended)
107
+
108
+ When using [`uv`](https://docs.astral.sh/uv/) no specific installation is needed. We will
109
+ use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *mcp-server-git*.
110
+
111
+ ### Using PIP
112
+
113
+ Alternatively you can install `mcp-server-git` via pip:
114
+
115
+ ```
116
+ pip install mcp-server-git
117
+ ```
118
+
119
+ After installation, you can run it as a script using:
120
+
121
+ ```
122
+ python -m mcp_server_git
123
+ ```
124
+
125
+ ## Configuration
126
+
127
+ ### Usage with Claude Desktop
128
+
129
+ Add this to your `claude_desktop_config.json`:
130
+
131
+ <details>
132
+ <summary>Using uvx</summary>
133
+
134
+ ```json
135
+ "mcpServers": {
136
+ "git": {
137
+ "command": "uvx",
138
+ "args": ["mcp-server-git", "--repository", "path/to/git/repo"]
139
+ }
140
+ }
141
+ ```
142
+ </details>
143
+
144
+ <details>
145
+ <summary>Using docker</summary>
146
+
147
+ * Note: replace '/Users/username' with the a path that you want to be accessible by this tool
148
+
149
+ ```json
150
+ "mcpServers": {
151
+ "git": {
152
+ "command": "docker",
153
+ "args": ["run", "--rm", "-i", "--mount", "type=bind,src=/Users/username,dst=/Users/username", "mcp/git"]
154
+ }
155
+ }
156
+ ```
157
+ </details>
158
+
159
+ <details>
160
+ <summary>Using pip installation</summary>
161
+
162
+ ```json
163
+ "mcpServers": {
164
+ "git": {
165
+ "command": "python",
166
+ "args": ["-m", "mcp_server_git", "--repository", "path/to/git/repo"]
167
+ }
168
+ }
169
+ ```
170
+ </details>
171
+
172
+ ### Usage with [Zed](https://github.com/zed-industries/zed)
173
+
174
+ Add to your Zed settings.json:
175
+
176
+ <details>
177
+ <summary>Using uvx</summary>
178
+
179
+ ```json
180
+ "context_servers": [
181
+ "mcp-server-git": {
182
+ "command": {
183
+ "path": "uvx",
184
+ "args": ["mcp-server-git"]
185
+ }
186
+ }
187
+ ],
188
+ ```
189
+ </details>
190
+
191
+ <details>
192
+ <summary>Using pip installation</summary>
193
+
194
+ ```json
195
+ "context_servers": {
196
+ "mcp-server-git": {
197
+ "command": {
198
+ "path": "python",
199
+ "args": ["-m", "mcp_server_git"]
200
+ }
201
+ }
202
+ },
203
+ ```
204
+ </details>
205
+
206
+ ## Debugging
207
+
208
+ You can use the MCP inspector to debug the server. For uvx installations:
209
+
210
+ ```
211
+ npx @modelcontextprotocol/inspector uvx mcp-server-git
212
+ ```
213
+
214
+ Or if you've installed the package in a specific directory or are developing on it:
215
+
216
+ ```
217
+ cd path/to/servers/src/git
218
+ npx @modelcontextprotocol/inspector uv run mcp-server-git
219
+ ```
220
+
221
+ Running `tail -n 20 -f ~/Library/Logs/Claude/mcp*.log` will show the logs from the server and may
222
+ help you debug any issues.
223
+
224
+ ## Development
225
+
226
+ If you are doing local development, there are two ways to test your changes:
227
+
228
+ 1. Run the MCP inspector to test your changes. See [Debugging](#debugging) for run instructions.
229
+
230
+ 2. Test using the Claude desktop app. Add the following to your `claude_desktop_config.json`:
231
+
232
+ ### Docker
233
+
234
+ ```json
235
+ {
236
+ "mcpServers": {
237
+ "git": {
238
+ "command": "docker",
239
+ "args": [
240
+ "run",
241
+ "--rm",
242
+ "-i",
243
+ "--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
244
+ "--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
245
+ "--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
246
+ "mcp/git"
247
+ ]
248
+ }
249
+ }
250
+ }
251
+ ```
252
+
253
+ ### UVX
254
+ ```json
255
+ {
256
+ "mcpServers": {
257
+ "git": {
258
+ "command": "uv",
259
+ "args": [
260
+ "--directory",
261
+ "/<path to mcp-servers>/mcp-servers/src/git",
262
+ "run",
263
+ "mcp-server-git"
264
+ ]
265
+ }
266
+ }
267
+ ```
268
+
269
+ ## Build
270
+
271
+ Docker build:
272
+
273
+ ```bash
274
+ cd src/git
275
+ docker build -t mcp/git .
276
+ ```
277
+
278
+ ## License
279
+
280
+ This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
@@ -0,0 +1,259 @@
1
+ # mcp-server-git: A git MCP server
2
+
3
+ ## Overview
4
+
5
+ A Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.
6
+
7
+ Please note that mcp-server-git is currently in early development. The functionality and available tools are subject to change and expansion as we continue to develop and improve the server.
8
+
9
+ ### Tools
10
+
11
+ 1. `git_status`
12
+ - Shows the working tree status
13
+ - Input:
14
+ - `repo_path` (string): Path to Git repository
15
+ - Returns: Current status of working directory as text output
16
+
17
+ 2. `git_diff_unstaged`
18
+ - Shows changes in working directory not yet staged
19
+ - Input:
20
+ - `repo_path` (string): Path to Git repository
21
+ - Returns: Diff output of unstaged changes
22
+
23
+ 3. `git_diff_staged`
24
+ - Shows changes that are staged for commit
25
+ - Input:
26
+ - `repo_path` (string): Path to Git repository
27
+ - Returns: Diff output of staged changes
28
+
29
+ 4. `git_diff`
30
+ - Shows differences between branches or commits
31
+ - Inputs:
32
+ - `repo_path` (string): Path to Git repository
33
+ - `target` (string): Target branch or commit to compare with
34
+ - Returns: Diff output comparing current state with target
35
+
36
+ 5. `git_commit`
37
+ - Records changes to the repository
38
+ - Inputs:
39
+ - `repo_path` (string): Path to Git repository
40
+ - `message` (string): Commit message
41
+ - Returns: Confirmation with new commit hash
42
+
43
+ 6. `git_add`
44
+ - Adds file contents to the staging area
45
+ - Inputs:
46
+ - `repo_path` (string): Path to Git repository
47
+ - `files` (string[]): Array of file paths to stage
48
+ - Returns: Confirmation of staged files
49
+
50
+ 7. `git_reset`
51
+ - Unstages all staged changes
52
+ - Input:
53
+ - `repo_path` (string): Path to Git repository
54
+ - Returns: Confirmation of reset operation
55
+
56
+ 8. `git_log`
57
+ - Shows the commit logs
58
+ - Inputs:
59
+ - `repo_path` (string): Path to Git repository
60
+ - `max_count` (number, optional): Maximum number of commits to show (default: 10)
61
+ - Returns: Array of commit entries with hash, author, date, and message
62
+
63
+ 9. `git_create_branch`
64
+ - Creates a new branch
65
+ - Inputs:
66
+ - `repo_path` (string): Path to Git repository
67
+ - `branch_name` (string): Name of the new branch
68
+ - `start_point` (string, optional): Starting point for the new branch
69
+ - Returns: Confirmation of branch creation
70
+ 8. `git_checkout`
71
+ - Switches branches
72
+ - Inputs:
73
+ - `repo_path` (string): Path to Git repository
74
+ - `branch_name` (string): Name of branch to checkout
75
+ - Returns: Confirmation of branch switch
76
+ 9. `git_show`
77
+ - Shows the contents of a commit
78
+ - Inputs:
79
+ - `repo_path` (string): Path to Git repository
80
+ - `revision` (string): The revision (commit hash, branch name, tag) to show
81
+ - Returns: Contents of the specified commit
82
+
83
+ ## Installation
84
+
85
+ ### Using uv (recommended)
86
+
87
+ When using [`uv`](https://docs.astral.sh/uv/) no specific installation is needed. We will
88
+ use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *mcp-server-git*.
89
+
90
+ ### Using PIP
91
+
92
+ Alternatively you can install `mcp-server-git` via pip:
93
+
94
+ ```
95
+ pip install mcp-server-git
96
+ ```
97
+
98
+ After installation, you can run it as a script using:
99
+
100
+ ```
101
+ python -m mcp_server_git
102
+ ```
103
+
104
+ ## Configuration
105
+
106
+ ### Usage with Claude Desktop
107
+
108
+ Add this to your `claude_desktop_config.json`:
109
+
110
+ <details>
111
+ <summary>Using uvx</summary>
112
+
113
+ ```json
114
+ "mcpServers": {
115
+ "git": {
116
+ "command": "uvx",
117
+ "args": ["mcp-server-git", "--repository", "path/to/git/repo"]
118
+ }
119
+ }
120
+ ```
121
+ </details>
122
+
123
+ <details>
124
+ <summary>Using docker</summary>
125
+
126
+ * Note: replace '/Users/username' with the a path that you want to be accessible by this tool
127
+
128
+ ```json
129
+ "mcpServers": {
130
+ "git": {
131
+ "command": "docker",
132
+ "args": ["run", "--rm", "-i", "--mount", "type=bind,src=/Users/username,dst=/Users/username", "mcp/git"]
133
+ }
134
+ }
135
+ ```
136
+ </details>
137
+
138
+ <details>
139
+ <summary>Using pip installation</summary>
140
+
141
+ ```json
142
+ "mcpServers": {
143
+ "git": {
144
+ "command": "python",
145
+ "args": ["-m", "mcp_server_git", "--repository", "path/to/git/repo"]
146
+ }
147
+ }
148
+ ```
149
+ </details>
150
+
151
+ ### Usage with [Zed](https://github.com/zed-industries/zed)
152
+
153
+ Add to your Zed settings.json:
154
+
155
+ <details>
156
+ <summary>Using uvx</summary>
157
+
158
+ ```json
159
+ "context_servers": [
160
+ "mcp-server-git": {
161
+ "command": {
162
+ "path": "uvx",
163
+ "args": ["mcp-server-git"]
164
+ }
165
+ }
166
+ ],
167
+ ```
168
+ </details>
169
+
170
+ <details>
171
+ <summary>Using pip installation</summary>
172
+
173
+ ```json
174
+ "context_servers": {
175
+ "mcp-server-git": {
176
+ "command": {
177
+ "path": "python",
178
+ "args": ["-m", "mcp_server_git"]
179
+ }
180
+ }
181
+ },
182
+ ```
183
+ </details>
184
+
185
+ ## Debugging
186
+
187
+ You can use the MCP inspector to debug the server. For uvx installations:
188
+
189
+ ```
190
+ npx @modelcontextprotocol/inspector uvx mcp-server-git
191
+ ```
192
+
193
+ Or if you've installed the package in a specific directory or are developing on it:
194
+
195
+ ```
196
+ cd path/to/servers/src/git
197
+ npx @modelcontextprotocol/inspector uv run mcp-server-git
198
+ ```
199
+
200
+ Running `tail -n 20 -f ~/Library/Logs/Claude/mcp*.log` will show the logs from the server and may
201
+ help you debug any issues.
202
+
203
+ ## Development
204
+
205
+ If you are doing local development, there are two ways to test your changes:
206
+
207
+ 1. Run the MCP inspector to test your changes. See [Debugging](#debugging) for run instructions.
208
+
209
+ 2. Test using the Claude desktop app. Add the following to your `claude_desktop_config.json`:
210
+
211
+ ### Docker
212
+
213
+ ```json
214
+ {
215
+ "mcpServers": {
216
+ "git": {
217
+ "command": "docker",
218
+ "args": [
219
+ "run",
220
+ "--rm",
221
+ "-i",
222
+ "--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
223
+ "--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
224
+ "--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
225
+ "mcp/git"
226
+ ]
227
+ }
228
+ }
229
+ }
230
+ ```
231
+
232
+ ### UVX
233
+ ```json
234
+ {
235
+ "mcpServers": {
236
+ "git": {
237
+ "command": "uv",
238
+ "args": [
239
+ "--directory",
240
+ "/<path to mcp-servers>/mcp-servers/src/git",
241
+ "run",
242
+ "mcp-server-git"
243
+ ]
244
+ }
245
+ }
246
+ ```
247
+
248
+ ## Build
249
+
250
+ Docker build:
251
+
252
+ ```bash
253
+ cd src/git
254
+ docker build -t mcp/git .
255
+ ```
256
+
257
+ ## License
258
+
259
+ This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
@@ -0,0 +1,39 @@
1
+ [project]
2
+ name = "mcp-server-git"
3
+ version = "2025.1.14"
4
+ description = "A Model Context Protocol server providing tools to read, search, and manipulate Git repositories programmatically via LLMs"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ authors = [{ name = "Anthropic, PBC." }]
8
+ maintainers = [{ name = "David Soria Parra", email = "davidsp@anthropic.com" }]
9
+ keywords = ["git", "mcp", "llm", "automation"]
10
+ license = { text = "MIT" }
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Intended Audience :: Developers",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.10",
17
+ ]
18
+ dependencies = [
19
+ "click>=8.1.7",
20
+ "gitpython>=3.1.43",
21
+ "mcp>=1.0.0",
22
+ "pydantic>=2.0.0",
23
+ ]
24
+
25
+ [project.scripts]
26
+ mcp-server-git = "mcp_server_git:main"
27
+
28
+ [build-system]
29
+ requires = ["hatchling"]
30
+ build-backend = "hatchling.build"
31
+
32
+ [tool.uv]
33
+ dev-dependencies = ["pyright>=1.1.389", "ruff>=0.7.3", "pytest>=8.0.0"]
34
+
35
+ [tool.pytest.ini_options]
36
+ testpaths = ["tests"]
37
+ python_files = "test_*.py"
38
+ python_classes = "Test*"
39
+ python_functions = "test_*"
@@ -0,0 +1,24 @@
1
+ import click
2
+ from pathlib import Path
3
+ import logging
4
+ import sys
5
+ from .server import serve
6
+
7
+ @click.command()
8
+ @click.option("--repository", "-r", type=Path, help="Git repository path")
9
+ @click.option("-v", "--verbose", count=True)
10
+ def main(repository: Path | None, verbose: bool) -> None:
11
+ """MCP Git Server - Git functionality for MCP"""
12
+ import asyncio
13
+
14
+ logging_level = logging.WARN
15
+ if verbose == 1:
16
+ logging_level = logging.INFO
17
+ elif verbose >= 2:
18
+ logging_level = logging.DEBUG
19
+
20
+ logging.basicConfig(level=logging_level, stream=sys.stderr)
21
+ asyncio.run(serve(repository))
22
+
23
+ if __name__ == "__main__":
24
+ main()
@@ -0,0 +1,5 @@
1
+ # __main__.py
2
+
3
+ from mcp_server_git import main
4
+
5
+ main()