@andrebuzeli/git-mcp 10.0.8 → 11.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/README.md +34 -428
- package/bin/git-mcp.js +21 -0
- package/docs/TOOLS.md +110 -0
- package/mcp.json.template +12 -0
- package/package.json +9 -76
- package/src/local/git.js +14 -0
- package/src/providers/gitea.js +13 -0
- package/src/providers/github.js +13 -0
- package/src/server.js +63 -0
- package/src/tools/git-actions.js +19 -0
- package/src/tools/git-activity.js +28 -0
- package/src/tools/git-admin.js +20 -0
- package/src/tools/git-checks.js +14 -0
- package/src/tools/git-commits.js +34 -0
- package/src/tools/git-contents.js +30 -0
- package/src/tools/git-deployments.js +21 -0
- package/src/tools/git-gists.js +15 -0
- package/src/tools/git-gitdata.js +19 -0
- package/src/tools/git-issues-prs.js +44 -0
- package/src/tools/git-issues.js +12 -0
- package/src/tools/git-local.js +66 -0
- package/src/tools/git-meta.js +19 -0
- package/src/tools/git-misc.js +21 -0
- package/src/tools/git-orgs.js +26 -0
- package/src/tools/git-packages.js +12 -0
- package/src/tools/git-raw.js +14 -0
- package/src/tools/git-releases.js +17 -0
- package/src/tools/git-remote.js +29 -0
- package/src/tools/git-repos.js +60 -0
- package/src/tools/git-search.js +18 -0
- package/src/tools/git-sync.js +40 -0
- package/src/tools/git-user.js +26 -0
- package/src/tools/schema.js +3 -0
- package/src/utils/fs.js +29 -0
- package/src/utils/project.js +7 -0
- package/tests/errors.js +26 -0
- package/tests/full_suite.js +98 -0
- package/tests/run.js +50 -0
- package/LICENSE +0 -21
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -224
- package/dist/prompts/gitPrompts.d.ts +0 -93
- package/dist/prompts/gitPrompts.js +0 -177
- package/dist/providers/giteaProvider.d.ts +0 -3
- package/dist/providers/giteaProvider.js +0 -6
- package/dist/providers/githubProvider.d.ts +0 -2
- package/dist/providers/githubProvider.js +0 -4
- package/dist/providers/providerManager.d.ts +0 -11
- package/dist/providers/providerManager.js +0 -49
- package/dist/resources/toolsGuide.d.ts +0 -12
- package/dist/resources/toolsGuide.js +0 -1713
- package/dist/scripts/test_e2e.d.ts +0 -1
- package/dist/scripts/test_e2e.js +0 -199
- package/dist/scripts/test_exhaustive.d.ts +0 -1
- package/dist/scripts/test_exhaustive.js +0 -275
- package/dist/scripts/verify_setup.d.ts +0 -1
- package/dist/scripts/verify_setup.js +0 -61
- package/dist/server.d.ts +0 -9
- package/dist/server.js +0 -73
- package/dist/tools/gitAnalytics.d.ts +0 -35
- package/dist/tools/gitAnalytics.js +0 -220
- package/dist/tools/gitArchive.d.ts +0 -119
- package/dist/tools/gitArchive.js +0 -150
- package/dist/tools/gitBackup.d.ts +0 -116
- package/dist/tools/gitBackup.js +0 -156
- package/dist/tools/gitBranches.d.ts +0 -54
- package/dist/tools/gitBranches.js +0 -282
- package/dist/tools/gitChangelog.d.ts +0 -37
- package/dist/tools/gitChangelog.js +0 -67
- package/dist/tools/gitConfig.d.ts +0 -97
- package/dist/tools/gitConfig.js +0 -125
- package/dist/tools/gitFiles.d.ts +0 -129
- package/dist/tools/gitFiles.js +0 -213
- package/dist/tools/gitFix.d.ts +0 -4
- package/dist/tools/gitFix.js +0 -159
- package/dist/tools/gitFix.tool.d.ts +0 -31
- package/dist/tools/gitFix.tool.js +0 -92
- package/dist/tools/gitHistory.d.ts +0 -41
- package/dist/tools/gitHistory.js +0 -349
- package/dist/tools/gitIgnore.d.ts +0 -214
- package/dist/tools/gitIgnore.js +0 -338
- package/dist/tools/gitIssues.d.ts +0 -80
- package/dist/tools/gitIssues.js +0 -363
- package/dist/tools/gitLog.d.ts +0 -30
- package/dist/tools/gitLog.js +0 -46
- package/dist/tools/gitMonitor.d.ts +0 -30
- package/dist/tools/gitMonitor.js +0 -284
- package/dist/tools/gitPackages.d.ts +0 -180
- package/dist/tools/gitPackages.js +0 -214
- package/dist/tools/gitPulls.d.ts +0 -66
- package/dist/tools/gitPulls.js +0 -347
- package/dist/tools/gitPush.d.ts +0 -40
- package/dist/tools/gitPush.js +0 -59
- package/dist/tools/gitRelease.d.ts +0 -49
- package/dist/tools/gitRelease.js +0 -359
- package/dist/tools/gitRemote.d.ts +0 -47
- package/dist/tools/gitRemote.js +0 -111
- package/dist/tools/gitReset.d.ts +0 -57
- package/dist/tools/gitReset.js +0 -79
- package/dist/tools/gitStash.d.ts +0 -61
- package/dist/tools/gitStash.js +0 -80
- package/dist/tools/gitSync.d.ts +0 -34
- package/dist/tools/gitSync.js +0 -182
- package/dist/tools/gitTags.d.ts +0 -45
- package/dist/tools/gitTags.js +0 -251
- package/dist/tools/gitUpdate.d.ts +0 -60
- package/dist/tools/gitUpdate.js +0 -474
- package/dist/tools/gitUpload.d.ts +0 -35
- package/dist/tools/gitUpload.js +0 -385
- package/dist/tools/gitWorkflow.d.ts +0 -117
- package/dist/tools/gitWorkflow.js +0 -472
- package/dist/types.d.ts +0 -20
- package/dist/types.js +0 -1
- package/dist/utils/agentHelpers.d.ts +0 -11
- package/dist/utils/agentHelpers.js +0 -41
- package/dist/utils/apiHelpers.d.ts +0 -29
- package/dist/utils/apiHelpers.js +0 -125
- package/dist/utils/cache.d.ts +0 -96
- package/dist/utils/cache.js +0 -208
- package/dist/utils/contextDetector.d.ts +0 -0
- package/dist/utils/contextDetector.js +0 -1
- package/dist/utils/errors.d.ts +0 -13
- package/dist/utils/errors.js +0 -17
- package/dist/utils/gitAdapter.d.ts +0 -224
- package/dist/utils/gitAdapter.js +0 -1152
- package/dist/utils/logger.d.ts +0 -45
- package/dist/utils/logger.js +0 -140
- package/dist/utils/rateLimiter.d.ts +0 -113
- package/dist/utils/rateLimiter.js +0 -257
- package/dist/utils/repoHelpers.d.ts +0 -44
- package/dist/utils/repoHelpers.js +0 -122
- package/dist/utils/safetyController.d.ts +0 -1
- package/dist/utils/safetyController.js +0 -12
- package/dist/utils/validation.d.ts +0 -115
- package/dist/utils/validation.js +0 -270
package/README.md
CHANGED
|
@@ -1,441 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @andrebuzeli/git-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
- Pacote MCP para manipulação Git com Gitea e GitHub em paralelo
|
|
4
|
+
- Configuração via NPX gerando `mcp.json` com `GITEA_URL`, `GITEA_TOKEN`, `GITHUB_TOKEN`
|
|
5
|
+
- Independente de Git instalado: usa `isomorphic-git` puro em Node
|
|
4
6
|
|
|
5
|
-
##
|
|
7
|
+
## Instalação
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
- `npm i -g @andrebuzeli/git-mcp@11.0.0` ou use via npx
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
- ✅ **Cursor AI**
|
|
11
|
-
- ✅ **Trae AI**
|
|
12
|
-
- ✅ **Kiro.dev**
|
|
13
|
-
- ✅ **Claude Desktop**
|
|
14
|
-
- ✅ **Any MCP-compatible client**
|
|
11
|
+
## Configuração
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
- `npx @andrebuzeli/git-mcp@11.0.0 init --path .`
|
|
14
|
+
- Edite `mcp.json` preenchendo os valores de ambiente
|
|
15
|
+
- Garanta que o processo/IDE exporte as variáveis de ambiente
|
|
18
16
|
|
|
19
|
-
|
|
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
|
-
```
|
|
17
|
+
## Uso rápido
|
|
26
18
|
|
|
27
|
-
|
|
19
|
+
- Criar repositórios remotos em ambos provedores
|
|
20
|
+
- `npx @andrebuzeli/git-mcp@11.0.0 call --tool git-remote --action createRepo --projectPath "C:\\Projetos\\Meu Projeto"`
|
|
21
|
+
- Inicializar e enviar para ambos remotos
|
|
22
|
+
- `npx @andrebuzeli/git-mcp@11.0.0 call --tool git-local --action init --projectPath "..."`
|
|
23
|
+
- `npx @andrebuzeli/git-mcp@11.0.0 call --tool git-remote --action ensureRemotes --projectPath "..."`
|
|
24
|
+
- `npx @andrebuzeli/git-mcp@11.0.0 call --tool git-local --action add --projectPath "..." --args '{"patterns":["."]}'`
|
|
25
|
+
- `npx @andrebuzeli/git-mcp@11.0.0 call --tool git-local --action commit --projectPath "..." --args '{"message":"Initial commit"}'`
|
|
26
|
+
- `npx @andrebuzeli/git-mcp@11.0.0 call --tool git-local --action push --projectPath "..." --args '{"remote":"origin-gitea","branch":"main"}'`
|
|
27
|
+
- `npx @andrebuzeli/git-mcp@11.0.0 call --tool git-local --action push --projectPath "..." --args '{"remote":"origin-github","branch":"main"}'`
|
|
28
28
|
|
|
29
|
-
|
|
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
|
|
29
|
+
## Integração em IDEs
|
|
45
30
|
|
|
46
|
-
|
|
31
|
+
- VSCode/Cursor/Trae: apontar o executor MCP para `npx @andrebuzeli/git-mcp@11.0.0 start` e usar `mcp.json` para descoberta das tools
|
|
32
|
+
- Todas as tools exigem `projectPath` e derivam o nome do projeto do último segmento, substituindo espaços por underscore
|
|
33
|
+
- Consulte `docs/TOOLS.md` para descrições, schema e exemplos de uso por tool/action
|
|
47
34
|
|
|
48
|
-
|
|
35
|
+
## Tools
|
|
49
36
|
|
|
50
|
-
|
|
37
|
+
- `git-local`: status, init, add, commit, push, pull, branch, tag
|
|
38
|
+
- Implementado com `isomorphic-git` (sem binário git)
|
|
39
|
+
- `git-remote`: createRepo, deleteRepo, ensureRemotes
|
|
40
|
+
- `git-sync`: mirror (push simultâneo para Gitea e GitHub)
|
|
41
|
+
- `git-issues`: create
|
|
42
|
+
- `git-releases`: create
|
|
51
43
|
|
|
52
|
-
|
|
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
|
|
44
|
+
## Notas
|
|
57
45
|
|
|
58
|
-
|
|
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 `isomorphic-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
|
-
Configure the git-mcp server in your MCP client's configuration file (e.g., Cursor's mcp.json, Claude Desktop's config, etc.):
|
|
106
|
-
|
|
107
|
-
```json
|
|
108
|
-
{
|
|
109
|
-
"mcpServers": {
|
|
110
|
-
"git-mcp": {
|
|
111
|
-
"command": "npx",
|
|
112
|
-
"args": ["@andrebuzeli/git-mcp@latest"],
|
|
113
|
-
"env": {
|
|
114
|
-
"GITHUB_USERNAME": "your-github-username",
|
|
115
|
-
"GITHUB_TOKEN": "ghp_your_github_token_here",
|
|
116
|
-
"GITEA_USERNAME": "your-gitea-username",
|
|
117
|
-
"GITEA_TOKEN": "your_gitea_token_here",
|
|
118
|
-
"GITEA_URL": "https://your-gitea-instance.com/",
|
|
119
|
-
"DEBUG": "false"
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**The MCP client automatically passes these environment variables to the git-mcp server - no additional configuration files needed!**
|
|
127
|
-
|
|
128
|
-
#### Alternative: Direct Environment Variables
|
|
129
|
-
If running the server directly (not through MCP client):
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
export GITHUB_TOKEN="your_github_token"
|
|
133
|
-
export GITHUB_USERNAME="your_username"
|
|
134
|
-
export GITEA_URL="https://your-gitea-instance.com"
|
|
135
|
-
export GITEA_TOKEN="your_gitea_token"
|
|
136
|
-
export GITEA_USERNAME="your_username"
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
#### PowerShell (Windows)
|
|
140
|
-
```powershell
|
|
141
|
-
$env:GITEA_URL = 'https://your-gitea-instance.com'
|
|
142
|
-
$env:GITEA_TOKEN = 'your_gitea_token'
|
|
143
|
-
$env:GITEA_USERNAME = 'your_username'
|
|
144
|
-
$env:GITHUB_TOKEN = 'your_github_token'
|
|
145
|
-
$env:GITHUB_USERNAME = 'your_username'
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
#### Multi-Provider Support
|
|
149
|
-
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.
|
|
150
|
-
|
|
151
|
-
## Available Tools
|
|
152
|
-
|
|
153
|
-
| Tool | Description | Operations | Safety Features |
|
|
154
|
-
|------|-------------|------------|-----------------|
|
|
155
|
-
| `git-workflow` | Core Git operations | init, status, commit, sync, backup, create, list, get, update, delete, fork, search | Repository deletion warnings |
|
|
156
|
-
| `git-files` | **Read-only** file operations | read, list, search, backup | File modification blocked |
|
|
157
|
-
| `git-branches` | Branch management | create, list, get, delete, merge, compare | Branch deletion warnings |
|
|
158
|
-
| `git-issues` | Issue management | create, list, get, update, close, comment, search | - |
|
|
159
|
-
| `git-pulls` | Pull request management | create, list, get, update, merge, close, review, search | - |
|
|
160
|
-
| `git-tags` | Tag management | create, list, get, delete, search | - |
|
|
161
|
-
| `git-release` | Release management | create, list, get, update, delete, publish, download | - |
|
|
162
|
-
| `git-remote` | Remote repository management | add, remove, rename, show, set-url, prune | - |
|
|
163
|
-
| `git-reset` | **⚠️ Repository reset** | soft, mixed, hard, reset-to-commit, reset-branch | **Hard reset warnings** |
|
|
164
|
-
| `git-stash` | Stash management | stash, pop, apply, list, show, drop, clear | - |
|
|
165
|
-
| `git-config` | Git configuration | get, set, unset, list, edit, show | - |
|
|
166
|
-
| `git-monitor` | Repository monitoring | status, changes, health | - |
|
|
167
|
-
| `git-backup` | Repository backup | create, restore, list, verify | - |
|
|
168
|
-
| `git-archive` | Repository archiving | create, extract, list, verify | - |
|
|
169
|
-
| `git-sync` | Repository synchronization | sync, status | - |
|
|
170
|
-
| `git-packages` | Package management | list, get, create, update, delete, publish, download | - |
|
|
171
|
-
| `git-analytics` | Repository analytics | stats, insights, reports | - |
|
|
172
|
-
|
|
173
|
-
## Security Features
|
|
174
|
-
|
|
175
|
-
### 🔒 File Operations Restriction
|
|
176
|
-
|
|
177
|
-
The `git-files` tool is **read-only only** for security reasons:
|
|
178
|
-
|
|
179
|
-
**✅ Allowed Operations:**
|
|
180
|
-
- `read` - Read file content
|
|
181
|
-
- `list` - List directory contents
|
|
182
|
-
- `search` - Search file content
|
|
183
|
-
- `backup` - Create local backups
|
|
184
|
-
|
|
185
|
-
**❌ Blocked Operations:**
|
|
186
|
-
- `create` - Create new files (blocked)
|
|
187
|
-
- `update` - Modify existing files (blocked)
|
|
188
|
-
- `delete` - Delete files (blocked)
|
|
189
|
-
|
|
190
|
-
**Why?** File content modification should be done through your local development environment, not via remote API calls.
|
|
191
|
-
|
|
192
|
-
### 🚨 Safety Warnings
|
|
193
|
-
|
|
194
|
-
Destructive operations include comprehensive safety warnings:
|
|
195
|
-
|
|
196
|
-
#### Git Reset Warnings
|
|
197
|
-
```json
|
|
198
|
-
{
|
|
199
|
-
"tool": "git-reset",
|
|
200
|
-
"params": {
|
|
201
|
-
"action": "hard",
|
|
202
|
-
"projectPath": "/path/to/project"
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
**Result:** Detailed warning about data loss with alternatives:
|
|
208
|
-
- `git reset --soft` (keeps changes staged)
|
|
209
|
-
- `git reset --mixed` (keeps changes unstaged)
|
|
210
|
-
- `git stash` (saves changes temporarily)
|
|
211
|
-
|
|
212
|
-
#### Branch Deletion Warnings
|
|
213
|
-
```json
|
|
214
|
-
{
|
|
215
|
-
"tool": "git-branches",
|
|
216
|
-
"params": {
|
|
217
|
-
"action": "delete",
|
|
218
|
-
"branchName": "feature-branch"
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
**Result:** Warning about permanent branch deletion with suggestions:
|
|
224
|
-
- Ensure branch is merged first
|
|
225
|
-
- Create backup branch before deletion
|
|
226
|
-
- Check for unmerged commits
|
|
227
|
-
|
|
228
|
-
### 🔍 Enhanced Error Handling
|
|
229
|
-
|
|
230
|
-
All tools provide detailed error messages with actionable solutions:
|
|
231
|
-
|
|
232
|
-
**Example Error Response:**
|
|
233
|
-
```json
|
|
234
|
-
{
|
|
235
|
-
"success": false,
|
|
236
|
-
"error": {
|
|
237
|
-
"code": "BRANCH_NOT_FOUND",
|
|
238
|
-
"message": "Branch not found",
|
|
239
|
-
"suggestions": [
|
|
240
|
-
"Check if the branch name is correct",
|
|
241
|
-
"Use git branch -a to see all available branches",
|
|
242
|
-
"Ensure the branch exists on the remote repository"
|
|
243
|
-
]
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## Usage Examples
|
|
249
|
-
|
|
250
|
-
### Local Git Operations
|
|
251
|
-
|
|
252
|
-
```json
|
|
253
|
-
{
|
|
254
|
-
"tool": "git-workflow",
|
|
255
|
-
"params": {
|
|
256
|
-
"action": "status",
|
|
257
|
-
"projectPath": "/path/to/project"
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
```json
|
|
263
|
-
{
|
|
264
|
-
"tool": "git-workflow",
|
|
265
|
-
"params": {
|
|
266
|
-
"action": "commit",
|
|
267
|
-
"projectPath": "/path/to/project",
|
|
268
|
-
"message": "Add new feature"
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### Remote Repository Operations (GitHub Example)
|
|
274
|
-
|
|
275
|
-
```json
|
|
276
|
-
{
|
|
277
|
-
"tool": "git-workflow",
|
|
278
|
-
"params": {
|
|
279
|
-
"action": "create",
|
|
280
|
-
"provider": "github",
|
|
281
|
-
"name": "my-new-repo",
|
|
282
|
-
"description": "My new repository",
|
|
283
|
-
"private": true
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
### Remote Repository Operations (Gitea Example)
|
|
289
|
-
|
|
290
|
-
```json
|
|
291
|
-
{
|
|
292
|
-
"tool": "git-issues",
|
|
293
|
-
"params": {
|
|
294
|
-
"action": "create",
|
|
295
|
-
"provider": "gitea",
|
|
296
|
-
"owner": "your-username",
|
|
297
|
-
"repo": "your-repo",
|
|
298
|
-
"title": "Bug report",
|
|
299
|
-
"body": "Description of the issue"
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
### Safe File Operations (Read-Only)
|
|
305
|
-
|
|
306
|
-
```json
|
|
307
|
-
{
|
|
308
|
-
"tool": "git-files",
|
|
309
|
-
"params": {
|
|
310
|
-
"action": "read",
|
|
311
|
-
"projectPath": "/path/to/project",
|
|
312
|
-
"filePath": "README.md"
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
### Destructive Operations (With Warnings)
|
|
318
|
-
|
|
319
|
-
```json
|
|
320
|
-
{
|
|
321
|
-
"tool": "git-reset",
|
|
322
|
-
"params": {
|
|
323
|
-
"action": "hard",
|
|
324
|
-
"projectPath": "/path/to/project",
|
|
325
|
-
"confirmDestructive": true
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
## Error Codes Reference
|
|
331
|
-
|
|
332
|
-
### Common Error Codes
|
|
333
|
-
|
|
334
|
-
| Code | Description | Solution |
|
|
335
|
-
|------|-------------|----------|
|
|
336
|
-
| `VALIDATION_ERROR` | Parameter validation failed | Check required parameters and format |
|
|
337
|
-
| `NOT_A_GIT_REPOSITORY` | Directory is not a Git repository | Use `git init` first |
|
|
338
|
-
| `NOTHING_TO_COMMIT` | No changes to commit | Make changes first |
|
|
339
|
-
| `MERGE_CONFLICT` | Merge conflicts detected | Resolve conflicts before proceeding |
|
|
340
|
-
| `PERMISSION_DENIED` | Permission denied | Check credentials and access rights |
|
|
341
|
-
| `PROVIDER_NOT_CONFIGURED` | Provider not configured | Set up GitHub or Gitea credentials |
|
|
342
|
-
| `NETWORK_ERROR` | Network connectivity issue | Check internet connection |
|
|
343
|
-
| `OPERATION_RESTRICTED` | File modification blocked | Use read-only operations only |
|
|
344
|
-
| `SAFETY_WARNING` | Destructive operation detected | Review warning and confirm if needed |
|
|
345
|
-
|
|
346
|
-
### Git-Specific Error Codes
|
|
347
|
-
|
|
348
|
-
| Code | Description | Solution |
|
|
349
|
-
|------|-------------|----------|
|
|
350
|
-
| `BRANCH_EXISTS` | Branch already exists | Use different name or delete existing |
|
|
351
|
-
| `BRANCH_NOT_FOUND` | Branch not found | Check branch name and remote config |
|
|
352
|
-
| `DIRTY_WORKING_TREE` | Uncommitted changes | Commit or stash changes first |
|
|
353
|
-
| `DETACHED_HEAD` | Repository in detached HEAD state | Create branch or checkout existing |
|
|
354
|
-
| `REF_LOCK_ERROR` | Cannot lock Git reference | Wait for other operations to complete |
|
|
355
|
-
|
|
356
|
-
## Setup Instructions
|
|
357
|
-
|
|
358
|
-
1. **Configure your MCP client** with the git-mcp server and your credentials (see Configuration section above)
|
|
359
|
-
|
|
360
|
-
2. **Generate GitHub Token:**
|
|
361
|
-
- Go to GitHub Settings → Developer settings → Personal access tokens
|
|
362
|
-
- Create token with `repo` scope
|
|
363
|
-
- Add to your MCP client configuration
|
|
364
|
-
|
|
365
|
-
3. **Generate Gitea Token:**
|
|
366
|
-
- Go to your Gitea instance → Settings → Applications
|
|
367
|
-
- Generate new token with appropriate permissions
|
|
368
|
-
- Add to your MCP client configuration
|
|
369
|
-
|
|
370
|
-
4. **Test Configuration:**
|
|
371
|
-
- Restart your MCP client
|
|
372
|
-
- Try using git-mcp tools in your IDE
|
|
373
|
-
|
|
374
|
-
## Troubleshooting
|
|
375
|
-
|
|
376
|
-
### Common Issues
|
|
377
|
-
|
|
378
|
-
**"Provider not configured" error:**
|
|
379
|
-
- Check environment variables are set correctly
|
|
380
|
-
- Verify token has required permissions
|
|
381
|
-
- Test API connectivity manually
|
|
382
|
-
|
|
383
|
-
**"Operation restricted" error:**
|
|
384
|
-
- File modification operations are blocked for security
|
|
385
|
-
- Use read-only operations: `read`, `list`, `search`, `backup`
|
|
386
|
-
- Make file changes through your local development environment
|
|
387
|
-
|
|
388
|
-
**"Safety warning" error:**
|
|
389
|
-
- Review the detailed warning message
|
|
390
|
-
- Consider safer alternatives suggested
|
|
391
|
-
- Use `confirmDestructive: true` only if absolutely necessary
|
|
392
|
-
|
|
393
|
-
**"Network error" errors:**
|
|
394
|
-
- Check internet connectivity
|
|
395
|
-
- Verify provider URLs are correct
|
|
396
|
-
- Check firewall/proxy settings
|
|
397
|
-
|
|
398
|
-
### Getting Help
|
|
399
|
-
|
|
400
|
-
1. **Check error messages** - They include specific suggestions
|
|
401
|
-
2. **Review safety warnings** - They explain risks and alternatives
|
|
402
|
-
3. **Validate credentials** - Server validates on startup
|
|
403
|
-
4. **Use read-only operations** - Safe file operations are always available
|
|
404
|
-
|
|
405
|
-
## Development
|
|
406
|
-
|
|
407
|
-
### Building from Source
|
|
408
|
-
|
|
409
|
-
```bash
|
|
410
|
-
git clone https://github.com/your-repo/git-mcp.git
|
|
411
|
-
cd git-mcp
|
|
412
|
-
npm install
|
|
413
|
-
npm run build
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
### Testing
|
|
417
|
-
|
|
418
|
-
```bash
|
|
419
|
-
npm test
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
## License
|
|
423
|
-
|
|
424
|
-
MIT License - see LICENSE file for details.
|
|
425
|
-
|
|
426
|
-
## Contributing
|
|
427
|
-
|
|
428
|
-
1. Fork the repository
|
|
429
|
-
2. Create a feature branch
|
|
430
|
-
3. Make your changes
|
|
431
|
-
4. Add tests for new functionality
|
|
432
|
-
5. Submit a pull request
|
|
433
|
-
|
|
434
|
-
---
|
|
435
|
-
|
|
436
|
-
**⚠️ Important Security Notes:**
|
|
437
|
-
|
|
438
|
-
- File content modification is intentionally restricted for security
|
|
439
|
-
- Always review safety warnings before destructive operations
|
|
440
|
-
- Keep your API tokens secure and rotate them regularly
|
|
441
|
-
- Use `confirmDestructive: true` only when absolutely necessary
|
|
46
|
+
- Tokens nunca são persistidos, somente lidos de variáveis de ambiente
|
|
47
|
+
- Operações remotas usam chamadas paralelas com relatório agregado
|
package/bin/git-mcp.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { initMcpJson, startServer, callOnce } from '../src/server.js'
|
|
3
|
+
|
|
4
|
+
const argv = process.argv.slice(2)
|
|
5
|
+
const cmd = argv[0] || 'start'
|
|
6
|
+
|
|
7
|
+
function getFlag(name) {
|
|
8
|
+
const idx = argv.findIndex(a => a === `--${name}`)
|
|
9
|
+
if (idx >= 0) return argv[idx + 1]
|
|
10
|
+
return undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function main() {
|
|
14
|
+
if (cmd === 'init') { const pathArg = getFlag('path'); const force = !!getFlag('force'); await initMcpJson(pathArg, force); return }
|
|
15
|
+
if (cmd === 'start') { await startServer(); return }
|
|
16
|
+
if (cmd === 'call') { const tool = getFlag('tool'); const action = getFlag('action'); const projectPath = getFlag('projectPath'); const argsStr = getFlag('args'); const args = argsStr ? JSON.parse(argsStr) : undefined; const res = await callOnce({ tool, action, projectPath, args }); console.log(JSON.stringify(res)); return }
|
|
17
|
+
console.error('Comando inválido')
|
|
18
|
+
process.exit(1)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main()
|
package/docs/TOOLS.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Tools e Actions — @andrebuzeli/git-mcp
|
|
2
|
+
|
|
3
|
+
Todas as tools operam com chamadas no formato padrão via stdio:
|
|
4
|
+
|
|
5
|
+
Entrada:
|
|
6
|
+
```
|
|
7
|
+
{ "tool": "<nome>", "action": "<acao>", "projectPath": "<caminho>", "args": { ... } }
|
|
8
|
+
```
|
|
9
|
+
Saída:
|
|
10
|
+
```
|
|
11
|
+
{ "ok": true, "res": <resultado> }
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Parâmetros
|
|
15
|
+
- `projectPath` (string): caminho completo do projeto no IDE
|
|
16
|
+
- `action` (string): ação dentro da tool
|
|
17
|
+
- `args` (objeto, opcional): parâmetros da ação
|
|
18
|
+
- Nome do projeto é derivado do último segmento de `projectPath` com espaços substituídos por underline
|
|
19
|
+
|
|
20
|
+
## Tools
|
|
21
|
+
|
|
22
|
+
### git-local
|
|
23
|
+
- Ações: `status`, `init`, `add`, `commit`, `push`, `pull`, `branch`, `tag`, `clone`
|
|
24
|
+
- Observações:
|
|
25
|
+
- Independente de Git instalado (usa `isomorphic-git`)
|
|
26
|
+
- `branch`: subactions `list|create|switch` via `args.subaction`
|
|
27
|
+
- `push`/`pull`: aceita `args.remote` ou `args.url` e faz fallback por Contents API
|
|
28
|
+
- Exemplos:
|
|
29
|
+
```
|
|
30
|
+
call --tool git-local --action init --projectPath "C:\Projetos\X"
|
|
31
|
+
call --tool git-local --action add --projectPath "..." --args '{"patterns":["README.md"]}'
|
|
32
|
+
call --tool git-local --action commit --projectPath "..." --args '{"message":"init"}'
|
|
33
|
+
call --tool git-local --action push --projectPath "..." --args '{"branch":"master"}'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### git-remote
|
|
37
|
+
- Ações: `createRepo`, `deleteRepo`, `ensureRemotes`
|
|
38
|
+
- Cria/garante repositórios/remotes em Gitea e GitHub simultaneamente
|
|
39
|
+
|
|
40
|
+
### git-sync
|
|
41
|
+
- Ações: `mirror`
|
|
42
|
+
- Sincroniza conteúdo para ambos provedores; tenta push e, se necessário, sobe todos arquivos via Contents API
|
|
43
|
+
|
|
44
|
+
### git-repos
|
|
45
|
+
- Ações: `get`, `patch`, `languages`, `tags`, `topics-get`, `topics-put`, `collaborators`, `subscribers`, `subscription-get`, `subscription-put`, `subscription-delete`, `stargazers`, `forks-get`, `forks-post`, `activities`, `hooks`, `keys`
|
|
46
|
+
|
|
47
|
+
### git-contents
|
|
48
|
+
- Ações: `list`, `create`, `get`
|
|
49
|
+
- `create`: `args.path`, `args.content` (base64), `args.message`, opcional `args.branch`
|
|
50
|
+
|
|
51
|
+
### git-commits
|
|
52
|
+
- Ações: `branches`, `create-branch`, `branch-protections`, `commits`, `refs`
|
|
53
|
+
|
|
54
|
+
### git-issues-prs
|
|
55
|
+
- Ações: `issue-create`, `issue-comment`, `issue-labels`, `labels-list`, `labels-create`, `milestones-list`, `milestones-create`, `pr-create`, `pr-get`
|
|
56
|
+
- Auto-correções: cria labels/branches quando necessário
|
|
57
|
+
|
|
58
|
+
### git-releases
|
|
59
|
+
- Ações: `create`
|
|
60
|
+
- `args`: `tag`, `title`, `body`
|
|
61
|
+
|
|
62
|
+
### git-actions (GitHub)
|
|
63
|
+
- Ações: `workflows`, `runs`, `artifacts`, `runners`, `secrets`
|
|
64
|
+
|
|
65
|
+
### git-activity
|
|
66
|
+
- Ações: `notifications-get`, `notifications-put`, `events`, `feeds`, `starring-put`, `starring-get`, `starring-delete`, `subscription-put`, `subscription-delete`
|
|
67
|
+
|
|
68
|
+
### git-search
|
|
69
|
+
- Ações: `repos`, `users`, `issues`, `repos-gitea`
|
|
70
|
+
|
|
71
|
+
### git-gitdata (GitHub)
|
|
72
|
+
- Ações: `blob-create`, `blob-get`, `tree-create`, `refs-get`
|
|
73
|
+
|
|
74
|
+
### git-checks (GitHub)
|
|
75
|
+
- Ações: `status`
|
|
76
|
+
- `args`: `sha`, `state`, `context`
|
|
77
|
+
|
|
78
|
+
### git-deployments (GitHub)
|
|
79
|
+
- Ações: `create`, `status`
|
|
80
|
+
- `create` detecta automaticamente `ref` (`main`/`master`)
|
|
81
|
+
|
|
82
|
+
### git-misc
|
|
83
|
+
- Ações: `version`, `markdown`, `markdown-raw`, `licenses`, `gitignore-templates`, `label-templates`, `emojis`, `rate_limit`, `zen`
|
|
84
|
+
|
|
85
|
+
### git-gists (GitHub)
|
|
86
|
+
- Ações: `create`, `get`, `star`, `delete`
|
|
87
|
+
|
|
88
|
+
### git-packages (Gitea)
|
|
89
|
+
- Ações: `list`
|
|
90
|
+
|
|
91
|
+
### git-raw (Gitea)
|
|
92
|
+
- Ações: `get`
|
|
93
|
+
|
|
94
|
+
## Integração IDE
|
|
95
|
+
- Configure `mcp.json` com:
|
|
96
|
+
```
|
|
97
|
+
{
|
|
98
|
+
"git-mcp": {
|
|
99
|
+
"command": "npx",
|
|
100
|
+
"type": "stdio",
|
|
101
|
+
"args": ["@andrebuzeli/git-mcp@latest"],
|
|
102
|
+
"env": {
|
|
103
|
+
"GITEA_URL": "",
|
|
104
|
+
"GITEA_TOKEN": "",
|
|
105
|
+
"GITHUB_TOKEN": ""
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
- IDEs (VSCode, Cursor, Trae) podem invocar via stdio enviando o JSON de chamada descrito acima
|