@andrebuzeli/git-mcp 9.2.0 → 10.0.0
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.
- package/LICENSE +21 -0
- package/README.md +460 -328
- package/dist/.tsbuildinfo +1 -1
- package/dist/config.d.ts +0 -1
- package/dist/config.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +7 -35
- package/dist/prompts/gitPrompts.d.ts +20 -1
- package/dist/prompts/gitPrompts.d.ts.map +1 -1
- package/dist/prompts/gitPrompts.js +49 -9
- package/dist/prompts/gitPrompts.js.map +1 -1
- package/dist/providers/giteaProvider.d.ts +1 -18
- package/dist/providers/giteaProvider.js +1 -87
- package/dist/providers/githubProvider.d.ts +0 -1
- package/dist/providers/githubProvider.js +0 -1
- package/dist/providers/providerManager.d.ts +0 -15
- package/dist/providers/providerManager.js +0 -65
- package/dist/resources/toolsGuide.d.ts +0 -1
- package/dist/resources/toolsGuide.js +1701 -1702
- package/dist/server.d.ts +0 -1
- package/dist/server.js +0 -1
- package/dist/tools/gitAnalytics.d.ts +0 -29
- package/dist/tools/gitAnalytics.js +4 -39
- package/dist/tools/gitArchive.d.ts +0 -30
- package/dist/tools/gitArchive.d.ts.map +1 -1
- package/dist/tools/gitArchive.js +1 -32
- package/dist/tools/gitArchive.js.map +1 -1
- package/dist/tools/gitBackup.d.ts +2 -35
- package/dist/tools/gitBackup.d.ts.map +1 -1
- package/dist/tools/gitBackup.js +7 -41
- package/dist/tools/gitBackup.js.map +1 -1
- package/dist/tools/gitBranches.d.ts +0 -49
- package/dist/tools/gitBranches.js +28 -92
- package/dist/tools/gitChangelog.d.ts +37 -1
- package/dist/tools/gitChangelog.d.ts.map +1 -1
- package/dist/tools/gitChangelog.js +67 -2
- package/dist/tools/gitChangelog.js.map +1 -1
- package/dist/tools/gitConfig.d.ts +2 -31
- package/dist/tools/gitConfig.js +9 -38
- package/dist/tools/gitFiles.d.ts +0 -37
- package/dist/tools/gitFiles.js +1 -39
- package/dist/tools/gitFix.d.ts +1 -4
- package/dist/tools/gitFix.js +32 -62
- package/dist/tools/gitFix.tool.d.ts +2 -26
- package/dist/tools/gitFix.tool.js +61 -85
- package/dist/tools/gitHistory.d.ts +5 -18
- package/dist/tools/gitHistory.js +208 -193
- package/dist/tools/gitIgnore.d.ts +0 -24
- package/dist/tools/gitIgnore.js +113 -136
- package/dist/tools/gitIssues.d.ts +0 -79
- package/dist/tools/gitIssues.js +16 -123
- package/dist/tools/gitLog.d.ts +30 -1
- package/dist/tools/gitLog.d.ts.map +1 -1
- package/dist/tools/gitLog.js +46 -2
- package/dist/tools/gitLog.js.map +1 -1
- package/dist/tools/gitMonitor.d.ts +0 -29
- package/dist/tools/gitMonitor.js +18 -47
- package/dist/tools/gitPackages.d.ts +146 -34
- package/dist/tools/gitPackages.js +147 -280
- package/dist/tools/gitPulls.d.ts +0 -66
- package/dist/tools/gitPulls.d.ts.map +1 -1
- package/dist/tools/gitPulls.js +7 -93
- package/dist/tools/gitPulls.js.map +1 -1
- package/dist/tools/gitPush.d.ts +0 -1
- package/dist/tools/gitPush.js +0 -1
- package/dist/tools/gitRelease.d.ts +0 -49
- package/dist/tools/gitRelease.js +6 -122
- package/dist/tools/gitRemote.d.ts +1 -31
- package/dist/tools/gitRemote.js +17 -59
- package/dist/tools/gitReset.d.ts +0 -25
- package/dist/tools/gitReset.js +8 -33
- package/dist/tools/gitStash.d.ts +2 -35
- package/dist/tools/gitStash.js +26 -56
- package/dist/tools/gitSync.d.ts +0 -29
- package/dist/tools/gitSync.js +20 -65
- package/dist/tools/gitTags.d.ts +0 -37
- package/dist/tools/gitTags.d.ts.map +1 -1
- package/dist/tools/gitTags.js +26 -53
- package/dist/tools/gitTags.js.map +1 -1
- package/dist/tools/gitUpdate.d.ts +6 -11
- package/dist/tools/gitUpdate.js +304 -61
- package/dist/tools/gitUpload.d.ts +1 -24
- package/dist/tools/gitUpload.js +50 -45
- package/dist/tools/gitWorkflow.d.ts +0 -27
- package/dist/tools/gitWorkflow.js +55 -87
- package/dist/types.d.ts +0 -7
- package/dist/types.js +0 -1
- package/dist/utils/apiHelpers.d.ts +0 -1
- package/dist/utils/apiHelpers.js +0 -1
- package/dist/utils/errors.d.ts +0 -1
- package/dist/utils/errors.js +0 -1
- package/dist/utils/gitAdapter.d.ts +14 -13
- package/dist/utils/gitAdapter.d.ts.map +1 -1
- package/dist/utils/gitAdapter.js +47 -9
- package/dist/utils/gitAdapter.js.map +1 -1
- package/dist/utils/repoHelpers.d.ts +0 -2
- package/dist/utils/repoHelpers.js +3 -16
- package/dist/utils/safetyController.d.ts +0 -1
- package/dist/utils/safetyController.js +0 -1
- package/dist/utils/safetyController.js.map +1 -1
- package/package.json +87 -96
package/README.md
CHANGED
|
@@ -1,328 +1,460 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
- **
|
|
34
|
-
- **
|
|
35
|
-
- **
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
####
|
|
53
|
-
- `git-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
###
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
1
|
+
# GIT MCP Server
|
|
2
|
+
|
|
3
|
+
Professional MCP (Model Context Protocol) server for Git operations with multi-provider support, enhanced security, comprehensive safety features, and **universal IDE compatibility**.
|
|
4
|
+
|
|
5
|
+
## ✨ NEW in v7.4.0 - Universal IDE Compatibility
|
|
6
|
+
|
|
7
|
+
**🎉 Now works with ALL IDEs and AI agents without parameter errors!**
|
|
8
|
+
|
|
9
|
+
- ✅ **VSCode** (all AI extensions)
|
|
10
|
+
- ✅ **Cursor AI**
|
|
11
|
+
- ✅ **Trae AI**
|
|
12
|
+
- ✅ **Kiro.dev**
|
|
13
|
+
- ✅ **Claude Desktop**
|
|
14
|
+
- ✅ **Any MCP-compatible client**
|
|
15
|
+
|
|
16
|
+
### Problem Solved
|
|
17
|
+
Previously, different IDEs sent parameters in different formats causing `Error: action is required`. Now Git-MCP **automatically normalizes** parameters from any source!
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
// ALL these formats work now! ✅
|
|
21
|
+
{ "command": "git status", "projectPath": "..." } // IDE format
|
|
22
|
+
{ "action": "status", "projectPath": "..." } // Standard format
|
|
23
|
+
{ "command": "status", "projectPath": "..." } // Simple format
|
|
24
|
+
{ "projectPath": "..." } // Auto-detect (defaults to status)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- 🌐 **NEW: Universal Parameter Normalization** - Accepts both 'action' and 'command' formats
|
|
30
|
+
- 🚀 **23 Specialized Git Tools** - Complete Git workflow coverage with 170+ actions
|
|
31
|
+
- 📚 **Self-Documenting Resources** - Complete documentation via MCP protocol
|
|
32
|
+
- ⚡ **3 Powerful Tools with Full Traceability**
|
|
33
|
+
- **git-upload** - Upload complete projects to GitHub + Gitea automatically
|
|
34
|
+
- **git-update** - Complete update workflow (add + commit + push) with tracking
|
|
35
|
+
- **git-history** - Detailed history tracking with remote issues
|
|
36
|
+
- 🔄 **Dual Provider Support** - GitHub and Gitea with automatic dual execution
|
|
37
|
+
- 🔒 **Security-First Design** - Read-only file operations, no content modification via API
|
|
38
|
+
- 🚨 **Safety Warnings** - Comprehensive warnings for destructive operations
|
|
39
|
+
- 🛡️ **Enhanced Error Handling** - Detailed diagnostics with actionable solutions
|
|
40
|
+
- 📋 **Comprehensive Validation** - Pre-execution validation with helpful guidance
|
|
41
|
+
- 🔧 **IDE/Client Compatibility** - Works seamlessly with ANY IDE or AI agent
|
|
42
|
+
- 📦 **NPM Distribution** - Easy installation via npx
|
|
43
|
+
- 🤖 **AI Agent Integration** - Designed for AI agent workflows with safety controls
|
|
44
|
+
- 📊 **Full Traceability** - Every operation tracked locally and remotely
|
|
45
|
+
|
|
46
|
+
## Resources System
|
|
47
|
+
|
|
48
|
+
Git-MCP v5.7.0 includes a comprehensive **Resources** system that provides detailed documentation directly through the MCP protocol:
|
|
49
|
+
|
|
50
|
+
### Available Resources
|
|
51
|
+
|
|
52
|
+
#### Tools Guide Resource
|
|
53
|
+
- **URI:** `git-mcp://tools/guide`
|
|
54
|
+
- **Format:** Markdown
|
|
55
|
+
- **Content:** Complete documentation for all 20 tools with 102 actions
|
|
56
|
+
- **Size:** 35,000+ characters
|
|
57
|
+
|
|
58
|
+
### Accessing Documentation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# List all available resources
|
|
62
|
+
curl http://localhost:3210/resources
|
|
63
|
+
|
|
64
|
+
# Get complete tools guide
|
|
65
|
+
curl "http://localhost:3210/resources/git-mcp://tools/guide"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### What's Included
|
|
69
|
+
|
|
70
|
+
- ✅ Quick start guide
|
|
71
|
+
- ✅ All 20 tools documented with examples
|
|
72
|
+
- ✅ 102 actions with parameters
|
|
73
|
+
- ✅ Provider types explained (LOCAL/DUAL/HYBRID)
|
|
74
|
+
- ✅ Best practices and workflows
|
|
75
|
+
- ✅ Troubleshooting guide
|
|
76
|
+
- ✅ Complete reference tables
|
|
77
|
+
|
|
78
|
+
**See [RESOURCES.md](RESOURCES.md) for detailed documentation on the resources system.**
|
|
79
|
+
|
|
80
|
+
## Provider Architecture
|
|
81
|
+
|
|
82
|
+
This MCP server supports **2 providers** (for remote API operations only):
|
|
83
|
+
- **`github`** - GitHub remote operations (issues, PRs, releases) via @octokit/rest
|
|
84
|
+
- **`gitea`** - Gitea remote operations (issues, PRs, releases) via axios to nas-ubuntu:3000
|
|
85
|
+
|
|
86
|
+
**Important**: Local Git operations (commit, branch, tag, stash, etc) use `simple-git` directly and do **NOT** require a `provider` parameter. The `provider` parameter is only needed for remote API operations (issues, PRs, releases, etc). Gitea as a provider is only for remote API calls, not for local Git operations.
|
|
87
|
+
|
|
88
|
+
## Quick Start
|
|
89
|
+
|
|
90
|
+
### Installation & Usage
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Option 1: Install globally (RECOMMENDED - faster startup)
|
|
94
|
+
npm install -g @andrebuzeli/git-mcp
|
|
95
|
+
git-mcp
|
|
96
|
+
|
|
97
|
+
# Option 2: Run with npx (slower first run, ~2-3min for dependency download)
|
|
98
|
+
npx @andrebuzeli/git-mcp@latest
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**⚡ Performance Note**: Global installation is **10x faster** on startup (~1s vs 2-3min). `npx` needs to download and install all dependencies on first run. For production use, install globally.
|
|
102
|
+
|
|
103
|
+
### Configuration
|
|
104
|
+
|
|
105
|
+
Set up your provider credentials via environment variables:
|
|
106
|
+
|
|
107
|
+
#### GitHub Configuration
|
|
108
|
+
```bash
|
|
109
|
+
export GITHUB_TOKEN="your_github_token"
|
|
110
|
+
export GITHUB_USERNAME="your_username"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### Gitea Configuration
|
|
114
|
+
```bash
|
|
115
|
+
export GITEA_URL="https://your-gitea-instance.com"
|
|
116
|
+
export GITEA_TOKEN="your_gitea_token"
|
|
117
|
+
export GITEA_USERNAME="your_username"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
PowerShell (Windows) example - session only:
|
|
121
|
+
```powershell
|
|
122
|
+
$env:GITEA_URL = 'https://your-gitea-instance.com'
|
|
123
|
+
$env:GITEA_TOKEN = 'your_gitea_token'
|
|
124
|
+
$env:GITEA_USERNAME = 'your_username'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Multi-Provider Support
|
|
128
|
+
You can configure both GitHub and Gitea simultaneously. Use `provider="github"` or `provider="gitea"` in tool calls to specify which provider to use for remote operations.
|
|
129
|
+
|
|
130
|
+
## Available Tools
|
|
131
|
+
|
|
132
|
+
| Tool | Description | Operations | Safety Features |
|
|
133
|
+
|------|-------------|------------|-----------------|
|
|
134
|
+
| `git-workflow` | Core Git operations | init, status, commit, sync, backup, create, list, get, update, delete, fork, search | Repository deletion warnings |
|
|
135
|
+
| `git-files` | **Read-only** file operations | read, list, search, backup | File modification blocked |
|
|
136
|
+
| `git-branches` | Branch management | create, list, get, delete, merge, compare | Branch deletion warnings |
|
|
137
|
+
| `git-issues` | Issue management | create, list, get, update, close, comment, search | - |
|
|
138
|
+
| `git-pulls` | Pull request management | create, list, get, update, merge, close, review, search | - |
|
|
139
|
+
| `git-tags` | Tag management | create, list, get, delete, search | - |
|
|
140
|
+
| `git-release` | Release management | create, list, get, update, delete, publish, download | - |
|
|
141
|
+
| `git-remote` | Remote repository management | add, remove, rename, show, set-url, prune | - |
|
|
142
|
+
| `git-reset` | **⚠️ Repository reset** | soft, mixed, hard, reset-to-commit, reset-branch | **Hard reset warnings** |
|
|
143
|
+
| `git-stash` | Stash management | stash, pop, apply, list, show, drop, clear | - |
|
|
144
|
+
| `git-config` | Git configuration | get, set, unset, list, edit, show | - |
|
|
145
|
+
| `git-monitor` | Repository monitoring | status, changes, health | - |
|
|
146
|
+
| `git-backup` | Repository backup | create, restore, list, verify | - |
|
|
147
|
+
| `git-archive` | Repository archiving | create, extract, list, verify | - |
|
|
148
|
+
| `git-sync` | Repository synchronization | sync, status | - |
|
|
149
|
+
| `git-packages` | Package management | list, get, create, update, delete, publish, download | - |
|
|
150
|
+
| `git-analytics` | Repository analytics | stats, insights, reports | - |
|
|
151
|
+
|
|
152
|
+
## Security Features
|
|
153
|
+
|
|
154
|
+
### 🔒 File Operations Restriction
|
|
155
|
+
|
|
156
|
+
The `git-files` tool is **read-only only** for security reasons:
|
|
157
|
+
|
|
158
|
+
**✅ Allowed Operations:**
|
|
159
|
+
- `read` - Read file content
|
|
160
|
+
- `list` - List directory contents
|
|
161
|
+
- `search` - Search file content
|
|
162
|
+
- `backup` - Create local backups
|
|
163
|
+
|
|
164
|
+
**❌ Blocked Operations:**
|
|
165
|
+
- `create` - Create new files (blocked)
|
|
166
|
+
- `update` - Modify existing files (blocked)
|
|
167
|
+
- `delete` - Delete files (blocked)
|
|
168
|
+
|
|
169
|
+
**Why?** File content modification should be done through your local development environment, not via remote API calls.
|
|
170
|
+
|
|
171
|
+
### 🚨 Safety Warnings
|
|
172
|
+
|
|
173
|
+
Destructive operations include comprehensive safety warnings:
|
|
174
|
+
|
|
175
|
+
#### Git Reset Warnings
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"tool": "git-reset",
|
|
179
|
+
"params": {
|
|
180
|
+
"action": "hard",
|
|
181
|
+
"projectPath": "/path/to/project"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Result:** Detailed warning about data loss with alternatives:
|
|
187
|
+
- `git reset --soft` (keeps changes staged)
|
|
188
|
+
- `git reset --mixed` (keeps changes unstaged)
|
|
189
|
+
- `git stash` (saves changes temporarily)
|
|
190
|
+
|
|
191
|
+
#### Branch Deletion Warnings
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"tool": "git-branches",
|
|
195
|
+
"params": {
|
|
196
|
+
"action": "delete",
|
|
197
|
+
"branchName": "feature-branch"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Result:** Warning about permanent branch deletion with suggestions:
|
|
203
|
+
- Ensure branch is merged first
|
|
204
|
+
- Create backup branch before deletion
|
|
205
|
+
- Check for unmerged commits
|
|
206
|
+
|
|
207
|
+
### 🔍 Enhanced Error Handling
|
|
208
|
+
|
|
209
|
+
All tools provide detailed error messages with actionable solutions:
|
|
210
|
+
|
|
211
|
+
**Example Error Response:**
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"success": false,
|
|
215
|
+
"error": {
|
|
216
|
+
"code": "BRANCH_NOT_FOUND",
|
|
217
|
+
"message": "Branch not found",
|
|
218
|
+
"suggestions": [
|
|
219
|
+
"Check if the branch name is correct",
|
|
220
|
+
"Use git branch -a to see all available branches",
|
|
221
|
+
"Ensure the branch exists on the remote repository"
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Usage Examples
|
|
228
|
+
|
|
229
|
+
### Local Git Operations
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"tool": "git-workflow",
|
|
234
|
+
"params": {
|
|
235
|
+
"action": "status",
|
|
236
|
+
"projectPath": "/path/to/project"
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"tool": "git-workflow",
|
|
244
|
+
"params": {
|
|
245
|
+
"action": "commit",
|
|
246
|
+
"projectPath": "/path/to/project",
|
|
247
|
+
"message": "Add new feature"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Remote Repository Operations (GitHub Example)
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"tool": "git-workflow",
|
|
257
|
+
"params": {
|
|
258
|
+
"action": "create",
|
|
259
|
+
"provider": "github",
|
|
260
|
+
"name": "my-new-repo",
|
|
261
|
+
"description": "My new repository",
|
|
262
|
+
"private": true
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Remote Repository Operations (Gitea Example)
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"tool": "git-issues",
|
|
272
|
+
"params": {
|
|
273
|
+
"action": "create",
|
|
274
|
+
"provider": "gitea",
|
|
275
|
+
"owner": "your-username",
|
|
276
|
+
"repo": "your-repo",
|
|
277
|
+
"title": "Bug report",
|
|
278
|
+
"body": "Description of the issue"
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Safe File Operations (Read-Only)
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
{
|
|
287
|
+
"tool": "git-files",
|
|
288
|
+
"params": {
|
|
289
|
+
"action": "read",
|
|
290
|
+
"projectPath": "/path/to/project",
|
|
291
|
+
"filePath": "README.md"
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Destructive Operations (With Warnings)
|
|
297
|
+
|
|
298
|
+
```json
|
|
299
|
+
{
|
|
300
|
+
"tool": "git-reset",
|
|
301
|
+
"params": {
|
|
302
|
+
"action": "hard",
|
|
303
|
+
"projectPath": "/path/to/project",
|
|
304
|
+
"confirmDestructive": true
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Error Codes Reference
|
|
310
|
+
|
|
311
|
+
### Common Error Codes
|
|
312
|
+
|
|
313
|
+
| Code | Description | Solution |
|
|
314
|
+
|------|-------------|----------|
|
|
315
|
+
| `VALIDATION_ERROR` | Parameter validation failed | Check required parameters and format |
|
|
316
|
+
| `NOT_A_GIT_REPOSITORY` | Directory is not a Git repository | Use `git init` first |
|
|
317
|
+
| `NOTHING_TO_COMMIT` | No changes to commit | Make changes first |
|
|
318
|
+
| `MERGE_CONFLICT` | Merge conflicts detected | Resolve conflicts before proceeding |
|
|
319
|
+
| `PERMISSION_DENIED` | Permission denied | Check credentials and access rights |
|
|
320
|
+
| `PROVIDER_NOT_CONFIGURED` | Provider not configured | Set up GitHub or Gitea credentials |
|
|
321
|
+
| `NETWORK_ERROR` | Network connectivity issue | Check internet connection |
|
|
322
|
+
| `OPERATION_RESTRICTED` | File modification blocked | Use read-only operations only |
|
|
323
|
+
| `SAFETY_WARNING` | Destructive operation detected | Review warning and confirm if needed |
|
|
324
|
+
|
|
325
|
+
### Git-Specific Error Codes
|
|
326
|
+
|
|
327
|
+
| Code | Description | Solution |
|
|
328
|
+
|------|-------------|----------|
|
|
329
|
+
| `BRANCH_EXISTS` | Branch already exists | Use different name or delete existing |
|
|
330
|
+
| `BRANCH_NOT_FOUND` | Branch not found | Check branch name and remote config |
|
|
331
|
+
| `DIRTY_WORKING_TREE` | Uncommitted changes | Commit or stash changes first |
|
|
332
|
+
| `DETACHED_HEAD` | Repository in detached HEAD state | Create branch or checkout existing |
|
|
333
|
+
| `REF_LOCK_ERROR` | Cannot lock Git reference | Wait for other operations to complete |
|
|
334
|
+
|
|
335
|
+
## Configuration Guide
|
|
336
|
+
|
|
337
|
+
### Environment Variables
|
|
338
|
+
|
|
339
|
+
**Required for GitHub:**
|
|
340
|
+
- `GITHUB_TOKEN` - Personal access token with repo permissions
|
|
341
|
+
- `GITHUB_USERNAME` - Your GitHub username
|
|
342
|
+
|
|
343
|
+
**Required for Gitea:**
|
|
344
|
+
- `GITEA_URL` - Your Gitea instance URL (e.g., `https://git.example.com`)
|
|
345
|
+
- `GITEA_TOKEN` - Personal access token
|
|
346
|
+
- `GITEA_USERNAME` - Your Gitea username
|
|
347
|
+
|
|
348
|
+
### Credential Validation
|
|
349
|
+
|
|
350
|
+
The server automatically validates credentials on startup:
|
|
351
|
+
|
|
352
|
+
- ✅ **Valid credentials** - API connectivity confirmed
|
|
353
|
+
- ❌ **Invalid token** - Authentication failed
|
|
354
|
+
- 🌐 **Network error** - Cannot reach provider API
|
|
355
|
+
- ⚠️ **Partial failure** - Some providers failed validation
|
|
356
|
+
|
|
357
|
+
### Setup Instructions
|
|
358
|
+
|
|
359
|
+
1. **Generate GitHub Token:**
|
|
360
|
+
- Go to GitHub Settings → Developer settings → Personal access tokens
|
|
361
|
+
- Create token with `repo` scope
|
|
362
|
+
- Copy token to `GITHUB_TOKEN` environment variable
|
|
363
|
+
|
|
364
|
+
2. **Generate Gitea Token:**
|
|
365
|
+
- Go to your Gitea instance → Settings → Applications
|
|
366
|
+
- Generate new token with appropriate permissions
|
|
367
|
+
- Copy token to `GITEA_TOKEN` environment variable
|
|
368
|
+
|
|
369
|
+
3. **Test Configuration:**
|
|
370
|
+
```bash
|
|
371
|
+
# Start the server to see validation results
|
|
372
|
+
npx @andrebuzeli/git-mcp@latest
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Optional: use a local `mcp.json` (NOT committed) to keep credentials for local testing.
|
|
376
|
+
|
|
377
|
+
1. Create `mcp.json` next to package.json with this shape (use the `.example` as a starting point):
|
|
378
|
+
|
|
379
|
+
```json
|
|
380
|
+
{
|
|
381
|
+
"env": {
|
|
382
|
+
"GITEA_URL": "http://nas-ubuntu:3000",
|
|
383
|
+
"GITEA_TOKEN": "<GITEA_TOKEN>",
|
|
384
|
+
"GITEA_USERNAME": "<GITEA_USERNAME>",
|
|
385
|
+
"GITHUB_TOKEN": "<GITHUB_TOKEN>",
|
|
386
|
+
"GITHUB_USERNAME": "<GITHUB_USERNAME>"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Security note: do NOT commit `mcp.json` with real tokens. The repository's `.gitignore` includes `mcp.json` to help avoid leaks.
|
|
392
|
+
|
|
393
|
+
## Troubleshooting
|
|
394
|
+
|
|
395
|
+
### Common Issues
|
|
396
|
+
|
|
397
|
+
**"Provider not configured" error:**
|
|
398
|
+
- Check environment variables are set correctly
|
|
399
|
+
- Verify token has required permissions
|
|
400
|
+
- Test API connectivity manually
|
|
401
|
+
|
|
402
|
+
**"Operation restricted" error:**
|
|
403
|
+
- File modification operations are blocked for security
|
|
404
|
+
- Use read-only operations: `read`, `list`, `search`, `backup`
|
|
405
|
+
- Make file changes through your local development environment
|
|
406
|
+
|
|
407
|
+
**"Safety warning" error:**
|
|
408
|
+
- Review the detailed warning message
|
|
409
|
+
- Consider safer alternatives suggested
|
|
410
|
+
- Use `confirmDestructive: true` only if absolutely necessary
|
|
411
|
+
|
|
412
|
+
**"Network error" errors:**
|
|
413
|
+
- Check internet connectivity
|
|
414
|
+
- Verify provider URLs are correct
|
|
415
|
+
- Check firewall/proxy settings
|
|
416
|
+
|
|
417
|
+
### Getting Help
|
|
418
|
+
|
|
419
|
+
1. **Check error messages** - They include specific suggestions
|
|
420
|
+
2. **Review safety warnings** - They explain risks and alternatives
|
|
421
|
+
3. **Validate credentials** - Server validates on startup
|
|
422
|
+
4. **Use read-only operations** - Safe file operations are always available
|
|
423
|
+
|
|
424
|
+
## Development
|
|
425
|
+
|
|
426
|
+
### Building from Source
|
|
427
|
+
|
|
428
|
+
```bash
|
|
429
|
+
git clone https://github.com/your-repo/git-mcp.git
|
|
430
|
+
cd git-mcp
|
|
431
|
+
npm install
|
|
432
|
+
npm run build
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### Testing
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
npm test
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## License
|
|
442
|
+
|
|
443
|
+
MIT License - see LICENSE file for details.
|
|
444
|
+
|
|
445
|
+
## Contributing
|
|
446
|
+
|
|
447
|
+
1. Fork the repository
|
|
448
|
+
2. Create a feature branch
|
|
449
|
+
3. Make your changes
|
|
450
|
+
4. Add tests for new functionality
|
|
451
|
+
5. Submit a pull request
|
|
452
|
+
|
|
453
|
+
---
|
|
454
|
+
|
|
455
|
+
**⚠️ Important Security Notes:**
|
|
456
|
+
|
|
457
|
+
- File content modification is intentionally restricted for security
|
|
458
|
+
- Always review safety warnings before destructive operations
|
|
459
|
+
- Keep your API tokens secure and rotate them regularly
|
|
460
|
+
- Use `confirmDestructive: true` only when absolutely necessary
|