@andrebuzeli/git-mcp 7.3.2 → 7.3.3

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.
@@ -12,6 +12,10 @@ export declare class GitArchiveTool implements Tool {
12
12
  valid?: undefined;
13
13
  archive?: undefined;
14
14
  error?: undefined;
15
+ extracted?: undefined;
16
+ extractTo?: undefined;
17
+ metadataPath?: undefined;
18
+ note?: undefined;
15
19
  } | {
16
20
  success: boolean;
17
21
  archives: string[];
@@ -22,6 +26,10 @@ export declare class GitArchiveTool implements Tool {
22
26
  valid?: undefined;
23
27
  archive?: undefined;
24
28
  error?: undefined;
29
+ extracted?: undefined;
30
+ extractTo?: undefined;
31
+ metadataPath?: undefined;
32
+ note?: undefined;
25
33
  } | {
26
34
  success: boolean;
27
35
  archives: never[];
@@ -32,6 +40,10 @@ export declare class GitArchiveTool implements Tool {
32
40
  valid?: undefined;
33
41
  archive?: undefined;
34
42
  error?: undefined;
43
+ extracted?: undefined;
44
+ extractTo?: undefined;
45
+ metadataPath?: undefined;
46
+ note?: undefined;
35
47
  } | {
36
48
  success: boolean;
37
49
  valid: boolean;
@@ -42,6 +54,10 @@ export declare class GitArchiveTool implements Tool {
42
54
  count?: undefined;
43
55
  archivesDir?: undefined;
44
56
  error?: undefined;
57
+ extracted?: undefined;
58
+ extractTo?: undefined;
59
+ metadataPath?: undefined;
60
+ note?: undefined;
45
61
  } | {
46
62
  success: boolean;
47
63
  valid: boolean;
@@ -52,5 +68,23 @@ export declare class GitArchiveTool implements Tool {
52
68
  count?: undefined;
53
69
  archivesDir?: undefined;
54
70
  archive?: undefined;
71
+ extracted?: undefined;
72
+ extractTo?: undefined;
73
+ metadataPath?: undefined;
74
+ note?: undefined;
75
+ } | {
76
+ success: boolean;
77
+ extracted: boolean;
78
+ archivePath: any;
79
+ extractTo: any;
80
+ archive: any;
81
+ metadataPath: string;
82
+ message: string;
83
+ note: string;
84
+ archives?: undefined;
85
+ count?: undefined;
86
+ archivesDir?: undefined;
87
+ valid?: undefined;
88
+ error?: undefined;
55
89
  }>;
56
90
  }
@@ -79,8 +79,41 @@ export class GitArchiveTool {
79
79
  };
80
80
  }
81
81
  }
82
- case 'extract':
83
- throw new MCPError('NOT_IMPLEMENTED', 'Extract not yet fully implemented');
82
+ case 'extract': {
83
+ const archivePath = params.archivePath;
84
+ const extractTo = params.extractTo || projectPath;
85
+ if (!archivePath)
86
+ throw new MCPError('VALIDATION_ERROR', 'archivePath is required');
87
+ if (!extractTo)
88
+ throw new MCPError('VALIDATION_ERROR', 'extractTo is required');
89
+ try {
90
+ // Ler o arquivo de archive
91
+ const content = await fs.readFile(archivePath, 'utf-8');
92
+ const archive = JSON.parse(content);
93
+ // Verificar se é um archive válido
94
+ if (!archive.projectPath || !archive.timestamp) {
95
+ throw new MCPError('VALIDATION_ERROR', 'Invalid archive format');
96
+ }
97
+ // Criar diretório de extração
98
+ await fs.mkdir(extractTo, { recursive: true });
99
+ // Copiar informações do archive para um arquivo de metadados
100
+ const metadataPath = path.join(extractTo, '.archive-metadata.json');
101
+ await fs.writeFile(metadataPath, JSON.stringify(archive, null, 2), 'utf-8');
102
+ return {
103
+ success: true,
104
+ extracted: true,
105
+ archivePath,
106
+ extractTo,
107
+ archive,
108
+ metadataPath,
109
+ message: 'Archive extracted successfully. Metadata saved to .archive-metadata.json',
110
+ note: 'This is a simplified extraction. For full restoration, use git commands or backup tools.',
111
+ };
112
+ }
113
+ catch (error) {
114
+ throw new MCPError('EXTRACT_ERROR', `Failed to extract archive: ${error.message}`);
115
+ }
116
+ }
84
117
  default:
85
118
  throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
86
119
  }
@@ -11,6 +11,13 @@ export declare class GitPackagesTool implements Tool {
11
11
  scripts: any;
12
12
  message?: undefined;
13
13
  note?: undefined;
14
+ created?: undefined;
15
+ path?: undefined;
16
+ package?: undefined;
17
+ updated?: undefined;
18
+ deleted?: undefined;
19
+ instructions?: undefined;
20
+ projectPath?: undefined;
14
21
  } | {
15
22
  success: boolean;
16
23
  message: string;
@@ -20,5 +27,126 @@ export declare class GitPackagesTool implements Tool {
20
27
  dependencies?: undefined;
21
28
  devDependencies?: undefined;
22
29
  scripts?: undefined;
30
+ created?: undefined;
31
+ path?: undefined;
32
+ package?: undefined;
33
+ updated?: undefined;
34
+ deleted?: undefined;
35
+ instructions?: undefined;
36
+ projectPath?: undefined;
37
+ } | {
38
+ success: boolean;
39
+ created: boolean;
40
+ path: string;
41
+ package: any;
42
+ name?: undefined;
43
+ version?: undefined;
44
+ dependencies?: undefined;
45
+ devDependencies?: undefined;
46
+ scripts?: undefined;
47
+ message?: undefined;
48
+ note?: undefined;
49
+ updated?: undefined;
50
+ deleted?: undefined;
51
+ instructions?: undefined;
52
+ projectPath?: undefined;
53
+ } | {
54
+ success: boolean;
55
+ updated: boolean;
56
+ path: string;
57
+ package: any;
58
+ name?: undefined;
59
+ version?: undefined;
60
+ dependencies?: undefined;
61
+ devDependencies?: undefined;
62
+ scripts?: undefined;
63
+ message?: undefined;
64
+ note?: undefined;
65
+ created?: undefined;
66
+ deleted?: undefined;
67
+ instructions?: undefined;
68
+ projectPath?: undefined;
69
+ } | {
70
+ success: boolean;
71
+ deleted: boolean;
72
+ path: string;
73
+ name?: undefined;
74
+ version?: undefined;
75
+ dependencies?: undefined;
76
+ devDependencies?: undefined;
77
+ scripts?: undefined;
78
+ message?: undefined;
79
+ note?: undefined;
80
+ created?: undefined;
81
+ package?: undefined;
82
+ updated?: undefined;
83
+ instructions?: undefined;
84
+ projectPath?: undefined;
85
+ } | {
86
+ success: boolean;
87
+ message: string;
88
+ path: string;
89
+ name?: undefined;
90
+ version?: undefined;
91
+ dependencies?: undefined;
92
+ devDependencies?: undefined;
93
+ scripts?: undefined;
94
+ note?: undefined;
95
+ created?: undefined;
96
+ package?: undefined;
97
+ updated?: undefined;
98
+ deleted?: undefined;
99
+ instructions?: undefined;
100
+ projectPath?: undefined;
101
+ } | {
102
+ success: boolean;
103
+ message: string;
104
+ instructions: {
105
+ command: string;
106
+ registry: any;
107
+ access: any;
108
+ tag: any;
109
+ note: string;
110
+ package?: undefined;
111
+ version?: undefined;
112
+ destination?: undefined;
113
+ };
114
+ projectPath: any;
115
+ name?: undefined;
116
+ version?: undefined;
117
+ dependencies?: undefined;
118
+ devDependencies?: undefined;
119
+ scripts?: undefined;
120
+ note?: undefined;
121
+ created?: undefined;
122
+ path?: undefined;
123
+ package?: undefined;
124
+ updated?: undefined;
125
+ deleted?: undefined;
126
+ } | {
127
+ success: boolean;
128
+ message: string;
129
+ instructions: {
130
+ command: string;
131
+ package: any;
132
+ version: any;
133
+ destination: any;
134
+ note: string;
135
+ registry?: undefined;
136
+ access?: undefined;
137
+ tag?: undefined;
138
+ };
139
+ name?: undefined;
140
+ version?: undefined;
141
+ dependencies?: undefined;
142
+ devDependencies?: undefined;
143
+ scripts?: undefined;
144
+ note?: undefined;
145
+ created?: undefined;
146
+ path?: undefined;
147
+ package?: undefined;
148
+ updated?: undefined;
149
+ deleted?: undefined;
150
+ projectPath?: undefined;
23
151
  }>;
24
152
  }
@@ -43,12 +43,140 @@ export class GitPackagesTool {
43
43
  note: 'Use npm view or yarn info for detailed package information',
44
44
  };
45
45
  }
46
- case 'create':
47
- case 'update':
48
- case 'delete':
49
- case 'publish':
50
- case 'download':
51
- throw new MCPError('NOT_IMPLEMENTED', `Action ${action} not yet fully implemented`);
46
+ case 'create': {
47
+ if (!projectPath)
48
+ throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
49
+ const packageJsonPath = path.join(projectPath, 'package.json');
50
+ const packageData = {
51
+ name: params.name || path.basename(projectPath),
52
+ version: params.version || '1.0.0',
53
+ description: params.description || '',
54
+ main: params.main || 'index.js',
55
+ scripts: params.scripts || {},
56
+ keywords: params.keywords || [],
57
+ author: params.author || '',
58
+ license: params.license || 'MIT',
59
+ };
60
+ if (params.dependencies)
61
+ packageData.dependencies = params.dependencies;
62
+ if (params.devDependencies)
63
+ packageData.devDependencies = params.devDependencies;
64
+ try {
65
+ await fs.writeFile(packageJsonPath, JSON.stringify(packageData, null, 2), 'utf-8');
66
+ return {
67
+ success: true,
68
+ created: true,
69
+ path: packageJsonPath,
70
+ package: packageData,
71
+ };
72
+ }
73
+ catch (error) {
74
+ throw new MCPError('FILE_ERROR', `Failed to create package.json: ${error.message}`);
75
+ }
76
+ }
77
+ case 'update': {
78
+ if (!projectPath)
79
+ throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
80
+ const packageJsonPath = path.join(projectPath, 'package.json');
81
+ try {
82
+ const content = await fs.readFile(packageJsonPath, 'utf-8');
83
+ const pkg = JSON.parse(content);
84
+ // Update fields if provided
85
+ if (params.name)
86
+ pkg.name = params.name;
87
+ if (params.version)
88
+ pkg.version = params.version;
89
+ if (params.description)
90
+ pkg.description = params.description;
91
+ if (params.main)
92
+ pkg.main = params.main;
93
+ if (params.scripts)
94
+ pkg.scripts = { ...pkg.scripts, ...params.scripts };
95
+ if (params.keywords)
96
+ pkg.keywords = params.keywords;
97
+ if (params.author)
98
+ pkg.author = params.author;
99
+ if (params.license)
100
+ pkg.license = params.license;
101
+ if (params.dependencies)
102
+ pkg.dependencies = { ...pkg.dependencies, ...params.dependencies };
103
+ if (params.devDependencies)
104
+ pkg.devDependencies = { ...pkg.devDependencies, ...params.devDependencies };
105
+ await fs.writeFile(packageJsonPath, JSON.stringify(pkg, null, 2), 'utf-8');
106
+ return {
107
+ success: true,
108
+ updated: true,
109
+ path: packageJsonPath,
110
+ package: pkg,
111
+ };
112
+ }
113
+ catch (error) {
114
+ throw new MCPError('FILE_ERROR', `Failed to update package.json: ${error.message}`);
115
+ }
116
+ }
117
+ case 'delete': {
118
+ if (!projectPath)
119
+ throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
120
+ const packageJsonPath = path.join(projectPath, 'package.json');
121
+ try {
122
+ await fs.unlink(packageJsonPath);
123
+ return {
124
+ success: true,
125
+ deleted: true,
126
+ path: packageJsonPath,
127
+ };
128
+ }
129
+ catch (error) {
130
+ if (error.code === 'ENOENT') {
131
+ return {
132
+ success: false,
133
+ message: 'package.json not found',
134
+ path: packageJsonPath,
135
+ };
136
+ }
137
+ throw new MCPError('FILE_ERROR', `Failed to delete package.json: ${error.message}`);
138
+ }
139
+ }
140
+ case 'publish': {
141
+ if (!projectPath)
142
+ throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
143
+ const registry = params.registry || 'https://registry.npmjs.org';
144
+ const access = params.access || 'public'; // public or restricted
145
+ const tag = params.tag || 'latest';
146
+ const dryRun = params.dryRun || false;
147
+ return {
148
+ success: true,
149
+ message: 'To publish, run: npm publish in your terminal',
150
+ instructions: {
151
+ command: dryRun ? 'npm publish --dry-run' : 'npm publish',
152
+ registry,
153
+ access,
154
+ tag,
155
+ note: 'Make sure you are logged in with: npm login',
156
+ },
157
+ projectPath,
158
+ };
159
+ }
160
+ case 'download': {
161
+ const packageName = params.packageName;
162
+ const version = params.version || 'latest';
163
+ const destination = params.destination || projectPath;
164
+ if (!packageName)
165
+ throw new MCPError('VALIDATION_ERROR', 'packageName is required');
166
+ if (!destination)
167
+ throw new MCPError('VALIDATION_ERROR', 'destination is required');
168
+ return {
169
+ success: true,
170
+ message: `To download ${packageName}@${version}, run: npm install ${packageName}@${version} in your terminal`,
171
+ instructions: {
172
+ command: `npm install ${packageName}@${version}`,
173
+ package: packageName,
174
+ version,
175
+ destination,
176
+ note: 'Run this command in your project directory',
177
+ },
178
+ };
179
+ }
52
180
  default:
53
181
  throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
54
182
  }
@@ -2,24 +2,5 @@ import { Tool, MCPContext } from '../types.js';
2
2
  export declare class GitSyncTool implements Tool {
3
3
  name: string;
4
4
  description: string;
5
- handle(params: Record<string, any>, ctx: MCPContext): Promise<{
6
- success: boolean;
7
- remote: any;
8
- branch: any;
9
- message: string;
10
- status?: undefined;
11
- remotes?: undefined;
12
- } | {
13
- success: boolean;
14
- status: {
15
- branch: string | null;
16
- ahead: number;
17
- behind: number;
18
- clean: boolean;
19
- };
20
- remotes: import("simple-git").RemoteWithRefs[];
21
- remote?: undefined;
22
- branch?: undefined;
23
- message?: undefined;
24
- }>;
5
+ handle(params: Record<string, any>, ctx: MCPContext): Promise<any>;
25
6
  }
@@ -37,6 +37,44 @@ export class GitSyncTool {
37
37
  remotes,
38
38
  };
39
39
  }
40
+ case 'one-shot': {
41
+ // One-shot sync: fetch, pull, and push in a single operation
42
+ const remote = params.remote || 'origin';
43
+ const branch = params.branch;
44
+ const results = {
45
+ success: true,
46
+ remote,
47
+ branch: branch || 'current',
48
+ steps: [],
49
+ };
50
+ // Step 1: Fetch
51
+ results.steps.push({ action: 'fetch', timestamp: new Date().toISOString() });
52
+ await git.fetch(remote);
53
+ // Step 2: Pull
54
+ results.steps.push({ action: 'pull', timestamp: new Date().toISOString() });
55
+ if (branch) {
56
+ await git.pull(remote, branch);
57
+ }
58
+ else {
59
+ await git.pull(remote);
60
+ }
61
+ // Step 3: Push
62
+ results.steps.push({ action: 'push', timestamp: new Date().toISOString() });
63
+ const pushResult = await git.push(remote, branch);
64
+ results.pushResult = {
65
+ pushed: pushResult.pushed || [],
66
+ remoteMessages: pushResult.remoteMessages?.all || [],
67
+ };
68
+ // Step 4: Final status
69
+ const finalStatus = await git.status();
70
+ results.finalStatus = {
71
+ branch: finalStatus.current,
72
+ ahead: finalStatus.ahead,
73
+ behind: finalStatus.behind,
74
+ clean: finalStatus.isClean(),
75
+ };
76
+ return results;
77
+ }
40
78
  default:
41
79
  throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
42
80
  }
@@ -289,6 +289,37 @@ export class GitWorkflowTool {
289
289
  }
290
290
  return results;
291
291
  }
292
+ case 'push': {
293
+ if (!projectPath || !git)
294
+ throw new MCPError('VALIDATION_ERROR', 'projectPath is required for push');
295
+ const remote = params.remote || 'origin';
296
+ const branch = params.branch;
297
+ const force = params.force || false;
298
+ const setUpstream = params.setUpstream || false;
299
+ const pushOptions = [];
300
+ if (force)
301
+ pushOptions.push('--force');
302
+ if (setUpstream)
303
+ pushOptions.push('--set-upstream');
304
+ try {
305
+ const pushResult = await git.push(remote, branch, pushOptions);
306
+ return {
307
+ success: true,
308
+ remote,
309
+ branch: branch || 'current',
310
+ force,
311
+ setUpstream,
312
+ result: {
313
+ pushed: pushResult.pushed || [],
314
+ remoteMessages: pushResult.remoteMessages?.all || [],
315
+ update: pushResult.update,
316
+ },
317
+ };
318
+ }
319
+ catch (err) {
320
+ throw new MCPError('PUSH_ERROR', `Failed to push: ${err.message}`);
321
+ }
322
+ }
292
323
  default:
293
324
  throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
294
325
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrebuzeli/git-mcp",
3
- "version": "7.3.2",
3
+ "version": "7.3.3",
4
4
  "type": "module",
5
5
  "description": "Professional MCP server for Git operations - STDIO UNIVERSAL: works in ANY IDE (Cursor, VSCode, Claude Desktop). Fully autonomous DUAL execution (GitHub + Gitea APIs) with automatic username detection. All tools execute on BOTH providers simultaneously. No manual parameters needed.",
6
6
  "main": "dist/index.js",