@andrebuzeli/git-mcp 5.0.9 → 5.2.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 +239 -80
- package/dist/__tests__/setup.d.ts +10 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +105 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/config.d.ts +43 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +168 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/providers/gitea-provider.d.ts.map +1 -1
- package/dist/providers/gitea-provider.js +3 -18
- package/dist/providers/gitea-provider.js.map +1 -1
- package/dist/providers/github-provider.d.ts.map +1 -1
- package/dist/providers/github-provider.js +3 -27
- package/dist/providers/github-provider.js.map +1 -1
- package/dist/server.d.ts +8 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +102 -6
- package/dist/server.js.map +1 -1
- package/dist/tools/git-archive.d.ts.map +1 -1
- package/dist/tools/git-archive.js +1 -3
- package/dist/tools/git-archive.js.map +1 -1
- package/dist/tools/git-automations.d.ts +257 -0
- package/dist/tools/git-automations.d.ts.map +1 -0
- package/dist/tools/git-automations.js +878 -0
- package/dist/tools/git-automations.js.map +1 -0
- package/dist/tools/git-bisect.d.ts +158 -0
- package/dist/tools/git-bisect.d.ts.map +1 -0
- package/dist/tools/git-bisect.js +571 -0
- package/dist/tools/git-bisect.js.map +1 -0
- package/dist/tools/git-branches.d.ts +48 -0
- package/dist/tools/git-branches.d.ts.map +1 -1
- package/dist/tools/git-branches.js +46 -4
- package/dist/tools/git-branches.js.map +1 -1
- package/dist/tools/git-changelog.d.ts +253 -0
- package/dist/tools/git-changelog.d.ts.map +1 -0
- package/dist/tools/git-changelog.js +728 -0
- package/dist/tools/git-changelog.js.map +1 -0
- package/dist/tools/git-cherry-pick.d.ts +150 -0
- package/dist/tools/git-cherry-pick.d.ts.map +1 -0
- package/dist/tools/git-cherry-pick.js +455 -0
- package/dist/tools/git-cherry-pick.js.map +1 -0
- package/dist/tools/git-dependencies.d.ts +233 -0
- package/dist/tools/git-dependencies.d.ts.map +1 -0
- package/dist/tools/git-dependencies.js +761 -0
- package/dist/tools/git-dependencies.js.map +1 -0
- package/dist/tools/git-files.d.ts +3 -26
- package/dist/tools/git-files.d.ts.map +1 -1
- package/dist/tools/git-files.js +26 -201
- package/dist/tools/git-files.js.map +1 -1
- package/dist/tools/git-hooks.d.ts +146 -0
- package/dist/tools/git-hooks.d.ts.map +1 -0
- package/dist/tools/git-hooks.js +634 -0
- package/dist/tools/git-hooks.js.map +1 -0
- package/dist/tools/git-reset.d.ts +17 -1
- package/dist/tools/git-reset.d.ts.map +1 -1
- package/dist/tools/git-reset.js +69 -2
- package/dist/tools/git-reset.js.map +1 -1
- package/dist/tools/git-stats-personal.d.ts +210 -0
- package/dist/tools/git-stats-personal.d.ts.map +1 -0
- package/dist/tools/git-stats-personal.js +718 -0
- package/dist/tools/git-stats-personal.js.map +1 -0
- package/dist/tools/git-tags.d.ts.map +1 -1
- package/dist/tools/git-tags.js +11 -3
- package/dist/tools/git-tags.js.map +1 -1
- package/dist/tools/git-workflow.d.ts +45 -0
- package/dist/tools/git-workflow.d.ts.map +1 -1
- package/dist/tools/git-workflow.js +43 -4
- package/dist/tools/git-workflow.js.map +1 -1
- package/dist/utils/operation-error-handler.d.ts.map +1 -1
- package/dist/utils/operation-error-handler.js +55 -0
- package/dist/utils/operation-error-handler.js.map +1 -1
- package/dist/utils/parameter-validator.d.ts +9 -0
- package/dist/utils/parameter-validator.d.ts.map +1 -1
- package/dist/utils/parameter-validator.js +430 -7
- package/dist/utils/parameter-validator.js.map +1 -1
- package/dist/utils/safety-warnings.d.ts +56 -0
- package/dist/utils/safety-warnings.d.ts.map +1 -0
- package/dist/utils/safety-warnings.js +330 -0
- package/dist/utils/safety-warnings.js.map +1 -0
- package/package.json +81 -78
package/README.md
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
# GIT MCP Server
|
|
2
2
|
|
|
3
|
-
Professional MCP (Model Context Protocol) server for Git operations with multi-provider support.
|
|
3
|
+
Professional MCP (Model Context Protocol) server for Git operations with multi-provider support, enhanced security, and comprehensive safety features.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- 🚀 **17 Specialized Git Tools** - Complete Git workflow coverage
|
|
8
|
-
- 🔄 **Multi-Provider Support** - GitHub and Gitea simultaneously
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
- 🚀 **17 Specialized Git Tools** - Complete Git workflow coverage with safety warnings
|
|
8
|
+
- 🔄 **Multi-Provider Support** - GitHub and Gitea simultaneously with credential validation
|
|
9
|
+
- 🔒 **Security-First Design** - Read-only file operations, no content modification via API
|
|
10
|
+
- 🚨 **Safety Warnings** - Comprehensive warnings for destructive operations
|
|
11
|
+
- 🛡️ **Enhanced Error Handling** - Detailed diagnostics with actionable solutions
|
|
12
|
+
- 📋 **Comprehensive Validation** - Pre-execution validation with helpful guidance
|
|
13
|
+
- 🔧 **IDE/Client Compatibility** - Universal aliases for different MCP client expectations
|
|
11
14
|
- 📦 **NPM Distribution** - Easy installation via npx
|
|
12
|
-
- 🤖 **AI Agent Integration** - Designed for AI agent workflows
|
|
15
|
+
- 🤖 **AI Agent Integration** - Designed for AI agent workflows with safety controls
|
|
13
16
|
|
|
14
17
|
## Quick Start
|
|
15
18
|
|
|
@@ -46,143 +49,299 @@ Configure both GitHub and Gitea to use `provider="both"` in tool calls.
|
|
|
46
49
|
|
|
47
50
|
## Available Tools
|
|
48
51
|
|
|
49
|
-
| Tool | Description | Operations |
|
|
50
|
-
|
|
51
|
-
| `git-workflow` | Core Git
|
|
52
|
-
| `git-files` |
|
|
53
|
-
| `git-branches` | Branch management | create, list, get, delete, merge, compare |
|
|
54
|
-
| `git-issues` | Issue management | create, list, get, update, close, comment, search |
|
|
55
|
-
| `git-pulls` | Pull request management | create, list, get, update, merge, close, review, search |
|
|
56
|
-
| `git-tags` | Tag
|
|
57
|
-
| `git-release` | Release management | create, list, get, update, delete, publish, download |
|
|
58
|
-
| `git-remote` | Remote
|
|
59
|
-
| `git-reset` |
|
|
60
|
-
| `git-stash` | Stash management | stash, pop, apply, list, show, drop, clear |
|
|
61
|
-
| `git-config` | Git configuration | get, set, unset, list, edit, show |
|
|
62
|
-
| `git-monitor` |
|
|
63
|
-
| `git-backup` |
|
|
64
|
-
| `git-archive` |
|
|
65
|
-
| `git-
|
|
66
|
-
| `git-
|
|
67
|
-
| `git-
|
|
52
|
+
| Tool | Description | Operations | Safety Features |
|
|
53
|
+
|------|-------------|------------|-----------------|
|
|
54
|
+
| `git-workflow` | Core Git operations | init, status, commit, sync, backup, create, list, get, update, delete, fork, search | Repository deletion warnings |
|
|
55
|
+
| `git-files` | **Read-only** file operations | read, list, search, backup | File modification blocked |
|
|
56
|
+
| `git-branches` | Branch management | create, list, get, delete, merge, compare | Branch deletion warnings |
|
|
57
|
+
| `git-issues` | Issue management | create, list, get, update, close, comment, search | - |
|
|
58
|
+
| `git-pulls` | Pull request management | create, list, get, update, merge, close, review, search | - |
|
|
59
|
+
| `git-tags` | Tag management | create, list, get, delete, search | - |
|
|
60
|
+
| `git-release` | Release management | create, list, get, update, delete, publish, download | - |
|
|
61
|
+
| `git-remote` | Remote repository management | add, remove, rename, show, set-url, prune | - |
|
|
62
|
+
| `git-reset` | **⚠️ Repository reset** | soft, mixed, hard, reset-to-commit, reset-branch | **Hard reset warnings** |
|
|
63
|
+
| `git-stash` | Stash management | stash, pop, apply, list, show, drop, clear | - |
|
|
64
|
+
| `git-config` | Git configuration | get, set, unset, list, edit, show | - |
|
|
65
|
+
| `git-monitor` | Repository monitoring | status, changes, health | - |
|
|
66
|
+
| `git-backup` | Repository backup | create, restore, list, verify | - |
|
|
67
|
+
| `git-archive` | Repository archiving | create, extract, list, verify | - |
|
|
68
|
+
| `git-sync` | Repository synchronization | sync, status | - |
|
|
69
|
+
| `git-packages` | Package management | list, get, create, update, delete, publish, download | - |
|
|
70
|
+
| `git-analytics` | Repository analytics | stats, insights, reports | - |
|
|
71
|
+
|
|
72
|
+
## Security Features
|
|
73
|
+
|
|
74
|
+
### 🔒 File Operations Restriction
|
|
75
|
+
|
|
76
|
+
The `git-files` tool is **read-only only** for security reasons:
|
|
77
|
+
|
|
78
|
+
**✅ Allowed Operations:**
|
|
79
|
+
- `read` - Read file content
|
|
80
|
+
- `list` - List directory contents
|
|
81
|
+
- `search` - Search file content
|
|
82
|
+
- `backup` - Create local backups
|
|
83
|
+
|
|
84
|
+
**❌ Blocked Operations:**
|
|
85
|
+
- `create` - Create new files (blocked)
|
|
86
|
+
- `update` - Modify existing files (blocked)
|
|
87
|
+
- `delete` - Delete files (blocked)
|
|
88
|
+
|
|
89
|
+
**Why?** File content modification should be done through your local development environment, not via remote API calls.
|
|
90
|
+
|
|
91
|
+
### 🚨 Safety Warnings
|
|
92
|
+
|
|
93
|
+
Destructive operations include comprehensive safety warnings:
|
|
94
|
+
|
|
95
|
+
#### Git Reset Warnings
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"tool": "git-reset",
|
|
99
|
+
"params": {
|
|
100
|
+
"action": "hard",
|
|
101
|
+
"projectPath": "/path/to/project"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Result:** Detailed warning about data loss with alternatives:
|
|
107
|
+
- `git reset --soft` (keeps changes staged)
|
|
108
|
+
- `git reset --mixed` (keeps changes unstaged)
|
|
109
|
+
- `git stash` (saves changes temporarily)
|
|
110
|
+
|
|
111
|
+
#### Branch Deletion Warnings
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"tool": "git-branches",
|
|
115
|
+
"params": {
|
|
116
|
+
"action": "delete",
|
|
117
|
+
"branchName": "feature-branch"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Result:** Warning about permanent branch deletion with suggestions:
|
|
123
|
+
- Ensure branch is merged first
|
|
124
|
+
- Create backup branch before deletion
|
|
125
|
+
- Check for unmerged commits
|
|
126
|
+
|
|
127
|
+
### 🔍 Enhanced Error Handling
|
|
128
|
+
|
|
129
|
+
All tools provide detailed error messages with actionable solutions:
|
|
130
|
+
|
|
131
|
+
**Example Error Response:**
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"success": false,
|
|
135
|
+
"error": {
|
|
136
|
+
"code": "BRANCH_NOT_FOUND",
|
|
137
|
+
"message": "Branch not found",
|
|
138
|
+
"suggestions": [
|
|
139
|
+
"Check if the branch name is correct",
|
|
140
|
+
"Use git branch -a to see all available branches",
|
|
141
|
+
"Ensure the branch exists on the remote repository"
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
68
146
|
|
|
69
147
|
## Usage Examples
|
|
70
148
|
|
|
71
|
-
###
|
|
149
|
+
### Local Git Operations
|
|
72
150
|
|
|
73
151
|
```json
|
|
74
152
|
{
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"action": "
|
|
153
|
+
"tool": "git-workflow",
|
|
154
|
+
"params": {
|
|
155
|
+
"action": "status",
|
|
78
156
|
"projectPath": "/path/to/project"
|
|
79
157
|
}
|
|
80
158
|
}
|
|
81
159
|
```
|
|
82
160
|
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"tool": "git-workflow",
|
|
164
|
+
"params": {
|
|
165
|
+
"action": "commit",
|
|
166
|
+
"projectPath": "/path/to/project",
|
|
167
|
+
"message": "Add new feature"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
83
172
|
### Remote Repository Operations
|
|
84
173
|
|
|
85
174
|
```json
|
|
86
175
|
{
|
|
87
|
-
"
|
|
88
|
-
"
|
|
176
|
+
"tool": "git-workflow",
|
|
177
|
+
"params": {
|
|
89
178
|
"action": "create",
|
|
90
|
-
"projectPath": "/path/to/project",
|
|
179
|
+
"projectPath": "/path/to/project",
|
|
91
180
|
"provider": "github",
|
|
92
181
|
"name": "my-new-repo",
|
|
93
182
|
"description": "My new repository",
|
|
94
|
-
"private":
|
|
183
|
+
"private": true
|
|
95
184
|
}
|
|
96
185
|
}
|
|
97
186
|
```
|
|
98
187
|
|
|
99
|
-
###
|
|
188
|
+
### Safe File Operations (Read-Only)
|
|
100
189
|
|
|
101
190
|
```json
|
|
102
191
|
{
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"action": "
|
|
192
|
+
"tool": "git-files",
|
|
193
|
+
"params": {
|
|
194
|
+
"action": "read",
|
|
106
195
|
"projectPath": "/path/to/project",
|
|
107
|
-
"
|
|
108
|
-
"title": "Bug Report",
|
|
109
|
-
"body": "Description of the issue"
|
|
196
|
+
"filePath": "README.md"
|
|
110
197
|
}
|
|
111
198
|
}
|
|
112
199
|
```
|
|
113
200
|
|
|
114
|
-
###
|
|
201
|
+
### Destructive Operations (With Warnings)
|
|
115
202
|
|
|
116
203
|
```json
|
|
117
204
|
{
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"action": "
|
|
205
|
+
"tool": "git-reset",
|
|
206
|
+
"params": {
|
|
207
|
+
"action": "hard",
|
|
121
208
|
"projectPath": "/path/to/project",
|
|
122
|
-
"
|
|
123
|
-
"path": "src/new-file.js",
|
|
124
|
-
"content": "console.log('Hello World');",
|
|
125
|
-
"message": "Add new file"
|
|
209
|
+
"confirmDestructive": true
|
|
126
210
|
}
|
|
127
211
|
}
|
|
128
212
|
```
|
|
129
213
|
|
|
130
|
-
##
|
|
214
|
+
## Error Codes Reference
|
|
215
|
+
|
|
216
|
+
### Common Error Codes
|
|
217
|
+
|
|
218
|
+
| Code | Description | Solution |
|
|
219
|
+
|------|-------------|----------|
|
|
220
|
+
| `VALIDATION_ERROR` | Parameter validation failed | Check required parameters and format |
|
|
221
|
+
| `NOT_A_GIT_REPOSITORY` | Directory is not a Git repository | Use `git init` first |
|
|
222
|
+
| `NOTHING_TO_COMMIT` | No changes to commit | Make changes first |
|
|
223
|
+
| `MERGE_CONFLICT` | Merge conflicts detected | Resolve conflicts before proceeding |
|
|
224
|
+
| `PERMISSION_DENIED` | Permission denied | Check credentials and access rights |
|
|
225
|
+
| `PROVIDER_NOT_CONFIGURED` | Provider not configured | Set up GitHub or Gitea credentials |
|
|
226
|
+
| `NETWORK_ERROR` | Network connectivity issue | Check internet connection |
|
|
227
|
+
| `OPERATION_RESTRICTED` | File modification blocked | Use read-only operations only |
|
|
228
|
+
| `SAFETY_WARNING` | Destructive operation detected | Review warning and confirm if needed |
|
|
229
|
+
|
|
230
|
+
### Git-Specific Error Codes
|
|
231
|
+
|
|
232
|
+
| Code | Description | Solution |
|
|
233
|
+
|------|-------------|----------|
|
|
234
|
+
| `BRANCH_EXISTS` | Branch already exists | Use different name or delete existing |
|
|
235
|
+
| `BRANCH_NOT_FOUND` | Branch not found | Check branch name and remote config |
|
|
236
|
+
| `DIRTY_WORKING_TREE` | Uncommitted changes | Commit or stash changes first |
|
|
237
|
+
| `DETACHED_HEAD` | Repository in detached HEAD state | Create branch or checkout existing |
|
|
238
|
+
| `REF_LOCK_ERROR` | Cannot lock Git reference | Wait for other operations to complete |
|
|
239
|
+
|
|
240
|
+
## Configuration Guide
|
|
241
|
+
|
|
242
|
+
### Environment Variables
|
|
243
|
+
|
|
244
|
+
**Required for GitHub:**
|
|
245
|
+
- `GITHUB_TOKEN` - Personal access token with repo permissions
|
|
246
|
+
- `GITHUB_USERNAME` - Your GitHub username
|
|
247
|
+
|
|
248
|
+
**Required for Gitea:**
|
|
249
|
+
- `GITEA_URL` - Your Gitea instance URL (e.g., `https://git.example.com`)
|
|
250
|
+
- `GITEA_TOKEN` - Personal access token
|
|
251
|
+
- `GITEA_USERNAME` - Your Gitea username
|
|
252
|
+
|
|
253
|
+
### Credential Validation
|
|
254
|
+
|
|
255
|
+
The server automatically validates credentials on startup:
|
|
256
|
+
|
|
257
|
+
- ✅ **Valid credentials** - API connectivity confirmed
|
|
258
|
+
- ❌ **Invalid token** - Authentication failed
|
|
259
|
+
- 🌐 **Network error** - Cannot reach provider API
|
|
260
|
+
- ⚠️ **Partial failure** - Some providers failed validation
|
|
131
261
|
|
|
132
|
-
|
|
133
|
-
- `mcp-git://tools` - List of available tools with detailed information
|
|
262
|
+
### Setup Instructions
|
|
134
263
|
|
|
135
|
-
|
|
264
|
+
1. **Generate GitHub Token:**
|
|
265
|
+
- Go to GitHub Settings → Developer settings → Personal access tokens
|
|
266
|
+
- Create token with `repo` scope
|
|
267
|
+
- Copy token to `GITHUB_TOKEN` environment variable
|
|
136
268
|
|
|
137
|
-
|
|
269
|
+
2. **Generate Gitea Token:**
|
|
270
|
+
- Go to your Gitea instance → Settings → Applications
|
|
271
|
+
- Generate new token with appropriate permissions
|
|
272
|
+
- Copy token to `GITEA_TOKEN` environment variable
|
|
138
273
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
274
|
+
3. **Test Configuration:**
|
|
275
|
+
```bash
|
|
276
|
+
# Start the server to see validation results
|
|
277
|
+
npx @andrebuzeli/git-mcp@latest
|
|
278
|
+
```
|
|
143
279
|
|
|
144
|
-
##
|
|
280
|
+
## Troubleshooting
|
|
145
281
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
282
|
+
### Common Issues
|
|
283
|
+
|
|
284
|
+
**"Provider not configured" error:**
|
|
285
|
+
- Check environment variables are set correctly
|
|
286
|
+
- Verify token has required permissions
|
|
287
|
+
- Test API connectivity manually
|
|
288
|
+
|
|
289
|
+
**"Operation restricted" error:**
|
|
290
|
+
- File modification operations are blocked for security
|
|
291
|
+
- Use read-only operations: `read`, `list`, `search`, `backup`
|
|
292
|
+
- Make file changes through your local development environment
|
|
293
|
+
|
|
294
|
+
**"Safety warning" error:**
|
|
295
|
+
- Review the detailed warning message
|
|
296
|
+
- Consider safer alternatives suggested
|
|
297
|
+
- Use `confirmDestructive: true` only if absolutely necessary
|
|
298
|
+
|
|
299
|
+
**"Network error" errors:**
|
|
300
|
+
- Check internet connectivity
|
|
301
|
+
- Verify provider URLs are correct
|
|
302
|
+
- Check firewall/proxy settings
|
|
303
|
+
|
|
304
|
+
### Getting Help
|
|
305
|
+
|
|
306
|
+
1. **Check error messages** - They include specific suggestions
|
|
307
|
+
2. **Review safety warnings** - They explain risks and alternatives
|
|
308
|
+
3. **Validate credentials** - Server validates on startup
|
|
309
|
+
4. **Use read-only operations** - Safe file operations are always available
|
|
149
310
|
|
|
150
311
|
## Development
|
|
151
312
|
|
|
152
|
-
###
|
|
313
|
+
### Building from Source
|
|
153
314
|
|
|
154
315
|
```bash
|
|
155
|
-
|
|
156
|
-
git clone https://github.com/andrebuzeli/git-mcp.git
|
|
316
|
+
git clone https://github.com/your-repo/git-mcp.git
|
|
157
317
|
cd git-mcp
|
|
158
|
-
|
|
159
|
-
# Install dependencies
|
|
160
318
|
npm install
|
|
161
|
-
|
|
162
|
-
# Build the project
|
|
163
319
|
npm run build
|
|
164
|
-
|
|
165
|
-
# Run locally
|
|
166
|
-
npm start
|
|
167
|
-
|
|
168
|
-
# Development mode with auto-reload
|
|
169
|
-
npm run dev
|
|
170
320
|
```
|
|
171
321
|
|
|
172
322
|
### Testing
|
|
173
323
|
|
|
174
324
|
```bash
|
|
175
|
-
# Run tests
|
|
176
325
|
npm test
|
|
177
|
-
|
|
178
|
-
# Run tests in watch mode
|
|
179
|
-
npm run test:watch
|
|
180
326
|
```
|
|
181
327
|
|
|
182
328
|
## License
|
|
183
329
|
|
|
184
|
-
MIT License - see
|
|
330
|
+
MIT License - see LICENSE file for details.
|
|
185
331
|
|
|
186
332
|
## Contributing
|
|
187
333
|
|
|
188
|
-
|
|
334
|
+
1. Fork the repository
|
|
335
|
+
2. Create a feature branch
|
|
336
|
+
3. Make your changes
|
|
337
|
+
4. Add tests for new functionality
|
|
338
|
+
5. Submit a pull request
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
**⚠️ Important Security Notes:**
|
|
343
|
+
|
|
344
|
+
- File content modification is intentionally restricted for security
|
|
345
|
+
- Always review safety warnings before destructive operations
|
|
346
|
+
- Keep your API tokens secure and rotate them regularly
|
|
347
|
+
- Use `confirmDestructive: true` only when absolutely necessary
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkFH,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,YAAY,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Setup de Testes - Git MCP
|
|
4
|
+
*
|
|
5
|
+
* Configurações globais para melhorar performance e confiabilidade dos testes
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
const child_process_1 = require("child_process");
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
// Configurar timeout global para operações Git
|
|
45
|
+
jest.setTimeout(30000);
|
|
46
|
+
// Setup global antes de todos os testes
|
|
47
|
+
beforeAll(async () => {
|
|
48
|
+
console.log('🚀 Iniciando setup de testes Git MCP...');
|
|
49
|
+
// Configurar variáveis de ambiente
|
|
50
|
+
process.env.GITHUB_TOKEN = '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';
|
|
51
|
+
process.env.GITHUB_USERNAME = 'andrebuzeli';
|
|
52
|
+
process.env.GITEA_URL = 'http://nas-ubuntu:3000';
|
|
53
|
+
process.env.GITEA_TOKEN = 'e9e5c441d5e8559004a9efd0614487bc5d7b0f23';
|
|
54
|
+
process.env.GITEA_USERNAME = 'admin';
|
|
55
|
+
// Criar repositório de teste em diretório local (evitar caminhos UNC)
|
|
56
|
+
const testRepoPath = path.join(process.cwd(), 'temp-test-repo');
|
|
57
|
+
try {
|
|
58
|
+
// Limpar repositório anterior se existir
|
|
59
|
+
if (fs.existsSync(testRepoPath)) {
|
|
60
|
+
fs.rmSync(testRepoPath, { recursive: true, force: true });
|
|
61
|
+
}
|
|
62
|
+
// Criar diretório
|
|
63
|
+
fs.mkdirSync(testRepoPath, { recursive: true });
|
|
64
|
+
// Inicializar repositório Git
|
|
65
|
+
(0, child_process_1.execSync)('git init', { cwd: testRepoPath, stdio: 'pipe' });
|
|
66
|
+
// Configurar Git user
|
|
67
|
+
(0, child_process_1.execSync)('git config user.email "test@git-mcp.com"', { cwd: testRepoPath, stdio: 'pipe' });
|
|
68
|
+
(0, child_process_1.execSync)('git config user.name "Test User"', { cwd: testRepoPath, stdio: 'pipe' });
|
|
69
|
+
// Criar arquivos de teste
|
|
70
|
+
fs.writeFileSync(path.join(testRepoPath, 'README.md'), '# Test Repository\n\nThis is a test repository for Git MCP testing.\n');
|
|
71
|
+
fs.writeFileSync(path.join(testRepoPath, 'package.json'), JSON.stringify({
|
|
72
|
+
name: 'test-repo',
|
|
73
|
+
version: '1.0.0',
|
|
74
|
+
description: 'Test repository'
|
|
75
|
+
}, null, 2));
|
|
76
|
+
// Criar estrutura de diretórios
|
|
77
|
+
fs.mkdirSync(path.join(testRepoPath, 'src'), { recursive: true });
|
|
78
|
+
fs.mkdirSync(path.join(testRepoPath, 'tests'), { recursive: true });
|
|
79
|
+
fs.writeFileSync(path.join(testRepoPath, 'src/main.js'), 'console.log("Hello, Git MCP!");\n');
|
|
80
|
+
fs.writeFileSync(path.join(testRepoPath, 'tests/sample.test.js'), 'test("sample", () => expect(1).toBe(1));\n');
|
|
81
|
+
// Fazer commit inicial
|
|
82
|
+
(0, child_process_1.execSync)('git add .', { cwd: testRepoPath, stdio: 'pipe' });
|
|
83
|
+
(0, child_process_1.execSync)('git commit -m "Initial commit - Test repository for Git MCP"', { cwd: testRepoPath, stdio: 'pipe' });
|
|
84
|
+
console.log('✅ Repositório de teste configurado com sucesso');
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.warn('⚠️ Erro ao configurar repositório de teste:', error);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
// Cleanup global após todos os testes
|
|
91
|
+
afterAll(async () => {
|
|
92
|
+
console.log('🧹 Limpando arquivos de teste...');
|
|
93
|
+
const testRepoPath = path.join(process.cwd(), 'temp-test-repo');
|
|
94
|
+
try {
|
|
95
|
+
if (fs.existsSync(testRepoPath)) {
|
|
96
|
+
fs.rmSync(testRepoPath, { recursive: true, force: true });
|
|
97
|
+
console.log('✅ Arquivos de teste removidos');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.warn('⚠️ Erro ao limpar arquivos de teste:', error);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
global.testRepoPath = path.join(process.cwd(), 'temp-test-repo');
|
|
105
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAyC;AACzC,uCAAyB;AACzB,2CAA6B;AAE7B,+CAA+C;AAC/C,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAEvB,wCAAwC;AACxC,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IAEvD,mCAAmC;IACnC,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,0CAA0C,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,aAAa,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,wBAAwB,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,0CAA0C,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC;IAErC,sEAAsE;IACtE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAEhE,IAAI,CAAC;QACH,yC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H,CAAC,CAAC,CAAC;AAOH,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -33,6 +33,37 @@ export interface ConfigValidationResult {
|
|
|
33
33
|
exampleConfig: Record<string, string>;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
export interface DetailedValidationResult {
|
|
37
|
+
isValid: boolean;
|
|
38
|
+
providerResults: {
|
|
39
|
+
github?: ProviderValidationResult;
|
|
40
|
+
gitea?: ProviderValidationResult;
|
|
41
|
+
};
|
|
42
|
+
summary: {
|
|
43
|
+
totalProviders: number;
|
|
44
|
+
validProviders: number;
|
|
45
|
+
errors: string[];
|
|
46
|
+
warnings: string[];
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface ProviderValidationResult {
|
|
50
|
+
provider: 'github' | 'gitea';
|
|
51
|
+
isValid: boolean;
|
|
52
|
+
isConfigured: boolean;
|
|
53
|
+
credentialStatus: 'valid' | 'invalid' | 'missing' | 'network_error';
|
|
54
|
+
errorDetails?: string;
|
|
55
|
+
userInfo?: {
|
|
56
|
+
username: string;
|
|
57
|
+
displayName?: string;
|
|
58
|
+
email?: string;
|
|
59
|
+
};
|
|
60
|
+
permissions?: string[];
|
|
61
|
+
rateLimit?: {
|
|
62
|
+
limit: number;
|
|
63
|
+
remaining: number;
|
|
64
|
+
reset: Date;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
36
67
|
export declare class ConfigManager {
|
|
37
68
|
private config;
|
|
38
69
|
constructor();
|
|
@@ -64,6 +95,18 @@ export declare class ConfigManager {
|
|
|
64
95
|
* Checks if a provider is supported for operations
|
|
65
96
|
*/
|
|
66
97
|
isProviderSupported(provider: 'github' | 'gitea' | 'both'): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Validates credentials with detailed testing of API connectivity
|
|
100
|
+
*/
|
|
101
|
+
validateCredentialsDetailed(): Promise<DetailedValidationResult>;
|
|
102
|
+
/**
|
|
103
|
+
* Validates GitHub credentials with API test
|
|
104
|
+
*/
|
|
105
|
+
private validateGitHubCredentials;
|
|
106
|
+
/**
|
|
107
|
+
* Validates Gitea credentials with API test
|
|
108
|
+
*/
|
|
109
|
+
private validateGiteaCredentials;
|
|
67
110
|
/**
|
|
68
111
|
* Gets configuration guidance for missing setup
|
|
69
112
|
*/
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,KAAK,CAAC,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kBAAkB,CAAC,EAAE;QACnB,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,aAAa,EAAE,MAAM,CAAC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