@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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +460 -328
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/config.d.ts +0 -1
  5. package/dist/config.js +0 -1
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.js +7 -35
  8. package/dist/prompts/gitPrompts.d.ts +20 -1
  9. package/dist/prompts/gitPrompts.d.ts.map +1 -1
  10. package/dist/prompts/gitPrompts.js +49 -9
  11. package/dist/prompts/gitPrompts.js.map +1 -1
  12. package/dist/providers/giteaProvider.d.ts +1 -18
  13. package/dist/providers/giteaProvider.js +1 -87
  14. package/dist/providers/githubProvider.d.ts +0 -1
  15. package/dist/providers/githubProvider.js +0 -1
  16. package/dist/providers/providerManager.d.ts +0 -15
  17. package/dist/providers/providerManager.js +0 -65
  18. package/dist/resources/toolsGuide.d.ts +0 -1
  19. package/dist/resources/toolsGuide.js +1701 -1702
  20. package/dist/server.d.ts +0 -1
  21. package/dist/server.js +0 -1
  22. package/dist/tools/gitAnalytics.d.ts +0 -29
  23. package/dist/tools/gitAnalytics.js +4 -39
  24. package/dist/tools/gitArchive.d.ts +0 -30
  25. package/dist/tools/gitArchive.d.ts.map +1 -1
  26. package/dist/tools/gitArchive.js +1 -32
  27. package/dist/tools/gitArchive.js.map +1 -1
  28. package/dist/tools/gitBackup.d.ts +2 -35
  29. package/dist/tools/gitBackup.d.ts.map +1 -1
  30. package/dist/tools/gitBackup.js +7 -41
  31. package/dist/tools/gitBackup.js.map +1 -1
  32. package/dist/tools/gitBranches.d.ts +0 -49
  33. package/dist/tools/gitBranches.js +28 -92
  34. package/dist/tools/gitChangelog.d.ts +37 -1
  35. package/dist/tools/gitChangelog.d.ts.map +1 -1
  36. package/dist/tools/gitChangelog.js +67 -2
  37. package/dist/tools/gitChangelog.js.map +1 -1
  38. package/dist/tools/gitConfig.d.ts +2 -31
  39. package/dist/tools/gitConfig.js +9 -38
  40. package/dist/tools/gitFiles.d.ts +0 -37
  41. package/dist/tools/gitFiles.js +1 -39
  42. package/dist/tools/gitFix.d.ts +1 -4
  43. package/dist/tools/gitFix.js +32 -62
  44. package/dist/tools/gitFix.tool.d.ts +2 -26
  45. package/dist/tools/gitFix.tool.js +61 -85
  46. package/dist/tools/gitHistory.d.ts +5 -18
  47. package/dist/tools/gitHistory.js +208 -193
  48. package/dist/tools/gitIgnore.d.ts +0 -24
  49. package/dist/tools/gitIgnore.js +113 -136
  50. package/dist/tools/gitIssues.d.ts +0 -79
  51. package/dist/tools/gitIssues.js +16 -123
  52. package/dist/tools/gitLog.d.ts +30 -1
  53. package/dist/tools/gitLog.d.ts.map +1 -1
  54. package/dist/tools/gitLog.js +46 -2
  55. package/dist/tools/gitLog.js.map +1 -1
  56. package/dist/tools/gitMonitor.d.ts +0 -29
  57. package/dist/tools/gitMonitor.js +18 -47
  58. package/dist/tools/gitPackages.d.ts +146 -34
  59. package/dist/tools/gitPackages.js +147 -280
  60. package/dist/tools/gitPulls.d.ts +0 -66
  61. package/dist/tools/gitPulls.d.ts.map +1 -1
  62. package/dist/tools/gitPulls.js +7 -93
  63. package/dist/tools/gitPulls.js.map +1 -1
  64. package/dist/tools/gitPush.d.ts +0 -1
  65. package/dist/tools/gitPush.js +0 -1
  66. package/dist/tools/gitRelease.d.ts +0 -49
  67. package/dist/tools/gitRelease.js +6 -122
  68. package/dist/tools/gitRemote.d.ts +1 -31
  69. package/dist/tools/gitRemote.js +17 -59
  70. package/dist/tools/gitReset.d.ts +0 -25
  71. package/dist/tools/gitReset.js +8 -33
  72. package/dist/tools/gitStash.d.ts +2 -35
  73. package/dist/tools/gitStash.js +26 -56
  74. package/dist/tools/gitSync.d.ts +0 -29
  75. package/dist/tools/gitSync.js +20 -65
  76. package/dist/tools/gitTags.d.ts +0 -37
  77. package/dist/tools/gitTags.d.ts.map +1 -1
  78. package/dist/tools/gitTags.js +26 -53
  79. package/dist/tools/gitTags.js.map +1 -1
  80. package/dist/tools/gitUpdate.d.ts +6 -11
  81. package/dist/tools/gitUpdate.js +304 -61
  82. package/dist/tools/gitUpload.d.ts +1 -24
  83. package/dist/tools/gitUpload.js +50 -45
  84. package/dist/tools/gitWorkflow.d.ts +0 -27
  85. package/dist/tools/gitWorkflow.js +55 -87
  86. package/dist/types.d.ts +0 -7
  87. package/dist/types.js +0 -1
  88. package/dist/utils/apiHelpers.d.ts +0 -1
  89. package/dist/utils/apiHelpers.js +0 -1
  90. package/dist/utils/errors.d.ts +0 -1
  91. package/dist/utils/errors.js +0 -1
  92. package/dist/utils/gitAdapter.d.ts +14 -13
  93. package/dist/utils/gitAdapter.d.ts.map +1 -1
  94. package/dist/utils/gitAdapter.js +47 -9
  95. package/dist/utils/gitAdapter.js.map +1 -1
  96. package/dist/utils/repoHelpers.d.ts +0 -2
  97. package/dist/utils/repoHelpers.js +3 -16
  98. package/dist/utils/safetyController.d.ts +0 -1
  99. package/dist/utils/safetyController.js +0 -1
  100. package/dist/utils/safetyController.js.map +1 -1
  101. package/package.json +87 -96
package/README.md CHANGED
@@ -1,328 +1,460 @@
1
- # 🚀 Git MCP - 100% Native JavaScript Git Implementation
2
-
3
- [![npm version](https://badge.fury.io/js/@andrebuzeli%2Fgit-mcp.svg)](https://www.npmjs.com/package/@andrebuzeli/git-mcp)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
6
-
7
- **Model Context Protocol (MCP) server for Git operations with ZERO dependencies on installed Git!**
8
-
9
- 🌍 **Universal IDE Support:** Claude Desktop • Cursor AI • VSCode Windsurf • Trae AI • Kiro.dev • Any MCP-compatible IDE
10
-
11
- 📖 **[Complete Setup Guide for All IDEs →](./UNIVERSAL-IDE-SETUP.md)**
12
-
13
- ## Key Features
14
-
15
- ### 🎯 **100% Git Independent**
16
- - **No Git installation required** - Pure JavaScript implementation using [isomorphic-git](https://isomorphic-git.org/)
17
- - **Works anywhere** - Browser, Node.js, Electron, VS Code, or any JavaScript runtime
18
- - **Cross-platform** - Windows, macOS, Linux with identical behavior
19
- - **Portable** - Bundle everything in your app, no external dependencies
20
-
21
- ### 🔄 **Dual-Provider Support**
22
- - **GitHub + Gitea** - Automatic dual-push to both platforms
23
- - **Unified API** - Single command pushes to both providers
24
- - **Fallback support** - Works with either provider independently
25
- - **Environment-based auth** - Uses `GITHUB_TOKEN` and `GITEA_TOKEN`
26
-
27
- ### 🧠 **Smart Commit Authors**
28
- - **Automatic detection** - Extracts username from GitHub/Gitea APIs
29
- - **Provider-aware** - Uses authenticated provider username
30
- - **Fallback chain** - Provider Local .git/config Default "MCP User"
31
-
32
- ### 📊 **Complete Traceability**
33
- - **Full history tracking** - Every change logged with timestamps
34
- - **Issue integration** - Links commits to GitHub/Gitea issues
35
- - **Detailed metadata** - Files changed, authors, providers, and more
36
-
37
- ### 🛠️ **22 Comprehensive Tools**
38
-
39
- #### Core Operations
40
- - `git-workflow` - Initialize, status, commit, sync, backup
41
- - `git-update` - Complete update workflow (add + commit + push)
42
- - `git-upload` - Upload entire project to GitHub/Gitea
43
- - `git-fix` - Auto-configure dual-provider system
44
-
45
- #### Branch Management
46
- - `git-branches` - List, create, delete, checkout, merge branches
47
-
48
- #### Remote Operations
49
- - `git-remote` - Manage remotes (add, remove, list)
50
- - `git-sync` - Fetch, pull, push operations
51
-
52
- #### Version Control
53
- - `git-tags` - Create, list, delete tags
54
- - `git-stash` - Save, list, apply, pop, drop stash (standard Git format)
55
- - `git-reset` - Soft, mixed, hard reset operations
56
-
57
- #### Configuration
58
- - `git-config` - Local, global, and system Git configuration
59
- - `git-ignore` - Manage .gitignore patterns
60
-
61
- #### Collaboration
62
- - `git-issues` - Create, list, update GitHub/Gitea issues
63
- - `git-pulls` - Create, list, merge pull requests
64
- - `git-release` - Create and manage releases
65
-
66
- #### Advanced
67
- - `git-history` - Complete change history with remote tracking
68
- - `git-monitor` - Repository monitoring and analytics
69
- - `git-analytics` - Detailed repository statistics
70
- - `git-backup` - Backup and restore operations
71
- - `git-archive` - Archive repository state
72
- - `git-packages` - Package management
73
-
74
- ## 🏗️ Architecture
75
-
76
- ### GitAdapter Pattern
77
- ```typescript
78
- interface GitAdapter {
79
- // Core operations
80
- init(projectPath: string): Promise<void>;
81
- status(projectPath: string): Promise<StatusResult>;
82
- add(projectPath: string, files: string[]): Promise<void>;
83
- commit(projectPath: string, message: string): Promise<string>;
84
-
85
- // Remote operations (HTTP-based, no SSH)
86
- push(projectPath: string, remote: string, branch: string): Promise<void>;
87
- pull(projectPath: string, remote: string, branch: string): Promise<void>;
88
- fetch(projectPath: string, remote: string): Promise<void>;
89
-
90
- // Advanced operations
91
- merge(projectPath: string, branch: string): Promise<void>;
92
- log(projectPath: string, options?: any): Promise<LogEntry[]>;
93
- diff(projectPath: string, ref1?: string, ref2?: string): Promise<DiffResult>;
94
- reset(projectPath: string, ref: string, mode: 'soft'|'mixed'|'hard'): Promise<void>;
95
-
96
- // Hybrid implementations
97
- stashSave/List/Apply/Pop/Drop/Clear() // Uses refs/stash + reflog
98
- getConfig/setConfig/listConfig() // isomorphic-git + fs for global/system
99
- }
100
- ```
101
-
102
- ### IsomorphicGitAdapter Implementation
103
- - **100% isomorphic-git** - No simple-git dependency
104
- - **HTTP authentication** - Token-based via `onAuth` callbacks
105
- - **Standard Git formats** - Compatible with native Git
106
- - **Hybrid features** - Combines isomorphic-git with Node.js fs for full functionality
107
-
108
- ## 📦 Installation
109
-
110
- ```bash
111
- npm install @andrebuzeli/git-mcp
112
- ```
113
-
114
- ### Environment Variables
115
- ```bash
116
- # GitHub authentication
117
- GITHUB_TOKEN=ghp_xxxxxxxxxxxx
118
- GITHUB_USERNAME=your-username
119
-
120
- # Gitea authentication
121
- GITEA_TOKEN=xxxxxxxxxx
122
- GITEA_USERNAME=your-username
123
- GITEA_URL=https://gitea.example.com # or http://localhost:3000
124
- ```
125
-
126
- ### 🌍 Universal IDE Configuration
127
-
128
- **Works in:** Claude Desktop, Cursor AI, VSCode, Windsurf, Trae AI, Kiro.dev, and any MCP-compatible IDE!
129
-
130
- #### Quick Setup (Recommended)
131
-
132
- ```json
133
- {
134
- "mcpServers": {
135
- "git-mcp": {
136
- "command": "npx",
137
- "args": ["-y", "@andrebuzeli/git-mcp"],
138
- "env": {
139
- "GITHUB_TOKEN": "ghp_xxxxxxxxxxxx",
140
- "GITHUB_USERNAME": "your-username",
141
- "GITEA_TOKEN": "xxxxxxxxxx",
142
- "GITEA_USERNAME": "your-username",
143
- "GITEA_URL": "https://gitea.example.com"
144
- }
145
- }
146
- }
147
- }
148
- ```
149
-
150
- #### Configuration Locations
151
-
152
- - **Claude Desktop (Windows):** `%APPDATA%\Claude\claude_desktop_config.json`
153
- - **Claude Desktop (macOS):** `~/Library/Application Support/Claude/claude_desktop_config.json`
154
- - **Cursor AI:** `%APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json`
155
- - **VSCode:** Via MCP extension settings or `settings.json`
156
-
157
- 📖 **[Complete Universal Setup Guide](./UNIVERSAL-IDE-SETUP.md)** - Detailed instructions for all IDEs
158
-
159
- ## 🚀 Quick Start
160
-
161
- ### 1. Fix Existing Repository
162
- ```typescript
163
- {
164
- "projectPath": "/path/to/repo",
165
- "autoDetect": true // Auto-detects GitHub/Gitea from existing remotes
166
- }
167
- ```
168
-
169
- ### 2. Initialize New Repository
170
- ```typescript
171
- {
172
- "action": "init",
173
- "projectPath": "/path/to/new-project"
174
- }
175
- ```
176
-
177
- ### 3. Complete Update Workflow
178
- ```typescript
179
- {
180
- "projectPath": "/path/to/project",
181
- "commitMessage": "feat: add new feature",
182
- "repoName": "my-project",
183
- "description": "My awesome project",
184
- "private": true
185
- }
186
- ```
187
-
188
- ## 🔧 How It Works
189
-
190
- ### No Git Installation Needed
191
-
192
- Traditional Git tools require Git CLI to be installed:
193
- ```bash
194
- # ❌ OLD WAY - Requires Git installation
195
- git add .
196
- git commit -m "message"
197
- git push origin main
198
- ```
199
-
200
- **Git MCP uses isomorphic-git - pure JavaScript:**
201
- ```typescript
202
- // NEW WAY - No Git installation required
203
- await git.add(projectPath, '.');
204
- await git.commit(projectPath, 'message');
205
- await git.push(projectPath, 'origin', 'main');
206
- ```
207
-
208
- ### HTTP-Based Authentication
209
-
210
- **No SSH keys needed** - Uses HTTP tokens:
211
-
212
- ```typescript
213
- // Automatic authentication via environment tokens
214
- const auth = {
215
- username: process.env.GITHUB_USERNAME,
216
- password: process.env.GITHUB_TOKEN
217
- };
218
-
219
- await git.push({
220
- fs,
221
- http,
222
- dir: projectPath,
223
- remote: 'github',
224
- ref: 'main',
225
- onAuth: () => auth
226
- });
227
- ```
228
-
229
- ### Hybrid Implementations
230
-
231
- Some Git features not natively supported by isomorphic-git are implemented using hybrid approaches:
232
-
233
- #### Stash (refs/stash + reflog)
234
- ```typescript
235
- // Creates standard Git stash using commits + refs/stash
236
- await git.stashSave(projectPath, 'WIP: feature');
237
-
238
- // Reflog stored in .git/logs/refs/stash
239
- // Compatible with native Git stash commands
240
- ```
241
-
242
- #### Global Config (fs + isomorphic-git)
243
- ```typescript
244
- // Local config via isomorphic-git
245
- await git.setConfig(projectPath, 'user.name', 'John', 'local');
246
-
247
- // Global config via direct fs access to ~/.gitconfig
248
- await git.setConfig(projectPath, 'user.email', 'john@example.com', 'global');
249
- ```
250
-
251
- ## 🎯 Use Cases
252
-
253
- ### ✅ Perfect For:
254
- - **CI/CD pipelines** - No Git installation needed
255
- - **Electron apps** - Embedded Git functionality
256
- - **VS Code extensions** - Native Git operations
257
- - **Web applications** - Git in the browser
258
- - **Docker containers** - Smaller images without Git
259
- - **Cross-platform tools** - Consistent behavior everywhere
260
-
261
- ### ⚠️ Limitations:
262
- - **SSH not supported** - Use HTTPS with tokens
263
- - **Large repos** - May be slower than native Git
264
- - **Complex operations** - Some advanced features limited
265
-
266
- ## 📊 Performance
267
-
268
- - **Startup time**: ~100ms (no Git CLI spawning)
269
- - **Small repos (<100MB)**: Comparable to native Git
270
- - **Large repos (>1GB)**: 2-3x slower than native Git
271
- - **Memory usage**: Higher than native Git (pure JavaScript)
272
-
273
- ## 🔒 Security
274
-
275
- - **Token-based auth** - No passwords or SSH keys stored
276
- - **Environment variables** - Credentials from secure sources
277
- - **No shell execution** - Pure JavaScript, no command injection
278
- - **Sandboxed operations** - All operations in Node.js runtime
279
-
280
- ## 🛠️ Development
281
-
282
- ### Build
283
- ```bash
284
- npm run build
285
- ```
286
-
287
- ### Test
288
- ```bash
289
- npm test
290
- ```
291
-
292
- ### Lint
293
- ```bash
294
- npm run lint
295
- ```
296
-
297
- ## 📚 Documentation
298
-
299
- - [isomorphic-git Documentation](https://isomorphic-git.org/)
300
- - [Model Context Protocol](https://modelcontextprotocol.io/)
301
- - [API Reference](./docs/api.md) *(coming soon)*
302
-
303
- ## 🤝 Contributing
304
-
305
- Contributions welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
306
-
307
- ## 📄 License
308
-
309
- MIT License - see [LICENSE](./LICENSE) for details.
310
-
311
- ## 🙏 Credits
312
-
313
- Built with:
314
- - [isomorphic-git](https://isomorphic-git.org/) - Pure JavaScript Git implementation
315
- - [@modelcontextprotocol/sdk](https://modelcontextprotocol.io/) - MCP protocol
316
- - [@octokit/rest](https://octokit.github.io/rest.js/) - GitHub API client
317
- - [axios](https://axios-http.com/) - HTTP client for Gitea API
318
-
319
- ## 📞 Support
320
-
321
- - **Issues**: [GitHub Issues](https://github.com/Andre-Buzeli/git-mcp/issues)
322
- - **Discussions**: [GitHub Discussions](https://github.com/Andre-Buzeli/git-mcp/discussions)
323
-
324
- ---
325
-
326
- **Made with ❤️ by Andre Buzeli**
327
-
328
- *Git operations without Git - powered by isomorphic-git and MCP*
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