@andrebuzeli/git-mcp 5.5.0 → 5.5.2

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 (224) hide show
  1. package/README.md +25 -0
  2. package/dist/config.d.ts +5 -131
  3. package/dist/config.js +28 -430
  4. package/dist/index.d.ts +1 -21
  5. package/dist/index.js +66 -144
  6. package/dist/providers/giteaProvider.d.ts +3 -0
  7. package/dist/providers/giteaProvider.js +12 -0
  8. package/dist/providers/githubProvider.d.ts +2 -0
  9. package/dist/providers/githubProvider.js +7 -0
  10. package/dist/providers/providerManager.d.ts +11 -0
  11. package/dist/providers/providerManager.js +48 -0
  12. package/dist/server.d.ts +6 -40
  13. package/dist/server.js +30 -700
  14. package/dist/tools/gitAnalytics.d.ts +29 -0
  15. package/dist/tools/gitAnalytics.js +72 -0
  16. package/dist/tools/gitArchive.d.ts +6 -0
  17. package/dist/tools/gitArchive.js +27 -0
  18. package/dist/tools/gitBackup.d.ts +10 -0
  19. package/dist/tools/gitBackup.js +44 -0
  20. package/dist/tools/gitBranches.d.ts +72 -0
  21. package/dist/tools/gitBranches.js +97 -0
  22. package/dist/tools/gitConfig.d.ts +34 -0
  23. package/dist/tools/gitConfig.js +73 -0
  24. package/dist/tools/gitFiles.d.ts +24 -0
  25. package/dist/tools/gitFiles.js +53 -0
  26. package/dist/tools/gitIssues.d.ts +21 -0
  27. package/dist/tools/gitIssues.js +193 -0
  28. package/dist/tools/gitMonitor.d.ts +51 -0
  29. package/dist/tools/gitMonitor.js +102 -0
  30. package/dist/tools/gitPackages.d.ts +6 -0
  31. package/dist/tools/gitPackages.js +28 -0
  32. package/dist/tools/gitPulls.d.ts +74 -0
  33. package/dist/tools/gitPulls.js +190 -0
  34. package/dist/tools/gitRelease.d.ts +34 -0
  35. package/dist/tools/gitRelease.js +99 -0
  36. package/dist/tools/gitRemote.d.ts +51 -0
  37. package/dist/tools/gitRemote.js +68 -0
  38. package/dist/tools/gitReset.d.ts +34 -0
  39. package/dist/tools/gitReset.js +64 -0
  40. package/dist/tools/gitStash.d.ts +41 -0
  41. package/dist/tools/gitStash.js +67 -0
  42. package/dist/tools/gitSync.d.ts +25 -0
  43. package/dist/tools/gitSync.js +51 -0
  44. package/dist/tools/gitTags.d.ts +30 -0
  45. package/dist/tools/gitTags.js +69 -0
  46. package/dist/tools/gitWorkflow.d.ts +69 -0
  47. package/dist/tools/gitWorkflow.js +129 -0
  48. package/dist/types.d.ts +10 -0
  49. package/dist/types.js +2 -0
  50. package/dist/utils/errors.d.ts +13 -0
  51. package/dist/utils/errors.js +22 -0
  52. package/dist/utils/safetyController.d.ts +1 -0
  53. package/dist/utils/safetyController.js +15 -0
  54. package/package.json +7 -2
  55. package/dist/config.d.ts.map +0 -1
  56. package/dist/config.js.map +0 -1
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/index.js.map +0 -1
  59. package/dist/providers/base-provider.d.ts +0 -66
  60. package/dist/providers/base-provider.d.ts.map +0 -1
  61. package/dist/providers/base-provider.js +0 -65
  62. package/dist/providers/base-provider.js.map +0 -1
  63. package/dist/providers/gitea-provider.d.ts +0 -79
  64. package/dist/providers/gitea-provider.d.ts.map +0 -1
  65. package/dist/providers/gitea-provider.js +0 -576
  66. package/dist/providers/gitea-provider.js.map +0 -1
  67. package/dist/providers/github-provider.d.ts +0 -74
  68. package/dist/providers/github-provider.d.ts.map +0 -1
  69. package/dist/providers/github-provider.js +0 -683
  70. package/dist/providers/github-provider.js.map +0 -1
  71. package/dist/providers/index.d.ts +0 -13
  72. package/dist/providers/index.d.ts.map +0 -1
  73. package/dist/providers/index.js +0 -35
  74. package/dist/providers/index.js.map +0 -1
  75. package/dist/providers/provider-factory.d.ts +0 -49
  76. package/dist/providers/provider-factory.d.ts.map +0 -1
  77. package/dist/providers/provider-factory.js +0 -193
  78. package/dist/providers/provider-factory.js.map +0 -1
  79. package/dist/providers/provider-operation-handler.d.ts +0 -115
  80. package/dist/providers/provider-operation-handler.d.ts.map +0 -1
  81. package/dist/providers/provider-operation-handler.js +0 -449
  82. package/dist/providers/provider-operation-handler.js.map +0 -1
  83. package/dist/providers/types.d.ts +0 -200
  84. package/dist/providers/types.d.ts.map +0 -1
  85. package/dist/providers/types.js +0 -8
  86. package/dist/providers/types.js.map +0 -1
  87. package/dist/server.d.ts.map +0 -1
  88. package/dist/server.js.map +0 -1
  89. package/dist/tools/git-analytics.d.ts +0 -237
  90. package/dist/tools/git-analytics.d.ts.map +0 -1
  91. package/dist/tools/git-analytics.js +0 -828
  92. package/dist/tools/git-analytics.js.map +0 -1
  93. package/dist/tools/git-archive.d.ts +0 -113
  94. package/dist/tools/git-archive.d.ts.map +0 -1
  95. package/dist/tools/git-archive.js +0 -466
  96. package/dist/tools/git-archive.js.map +0 -1
  97. package/dist/tools/git-auto-monitor.d.ts +0 -180
  98. package/dist/tools/git-auto-monitor.d.ts.map +0 -1
  99. package/dist/tools/git-auto-monitor.js +0 -522
  100. package/dist/tools/git-auto-monitor.js.map +0 -1
  101. package/dist/tools/git-backup.d.ts +0 -105
  102. package/dist/tools/git-backup.d.ts.map +0 -1
  103. package/dist/tools/git-backup.js +0 -414
  104. package/dist/tools/git-backup.js.map +0 -1
  105. package/dist/tools/git-branches.d.ts +0 -183
  106. package/dist/tools/git-branches.d.ts.map +0 -1
  107. package/dist/tools/git-branches.js +0 -507
  108. package/dist/tools/git-branches.js.map +0 -1
  109. package/dist/tools/git-config.d.ts +0 -119
  110. package/dist/tools/git-config.d.ts.map +0 -1
  111. package/dist/tools/git-config.js +0 -449
  112. package/dist/tools/git-config.js.map +0 -1
  113. package/dist/tools/git-files.d.ts +0 -150
  114. package/dist/tools/git-files.d.ts.map +0 -1
  115. package/dist/tools/git-files.js +0 -536
  116. package/dist/tools/git-files.js.map +0 -1
  117. package/dist/tools/git-history.d.ts +0 -253
  118. package/dist/tools/git-history.d.ts.map +0 -1
  119. package/dist/tools/git-history.js +0 -824
  120. package/dist/tools/git-history.js.map +0 -1
  121. package/dist/tools/git-issues.d.ts +0 -164
  122. package/dist/tools/git-issues.d.ts.map +0 -1
  123. package/dist/tools/git-issues.js +0 -349
  124. package/dist/tools/git-issues.js.map +0 -1
  125. package/dist/tools/git-monitor.d.ts +0 -154
  126. package/dist/tools/git-monitor.d.ts.map +0 -1
  127. package/dist/tools/git-monitor.js +0 -531
  128. package/dist/tools/git-monitor.js.map +0 -1
  129. package/dist/tools/git-packages.d.ts +0 -157
  130. package/dist/tools/git-packages.d.ts.map +0 -1
  131. package/dist/tools/git-packages.js +0 -534
  132. package/dist/tools/git-packages.js.map +0 -1
  133. package/dist/tools/git-pulls.d.ts +0 -180
  134. package/dist/tools/git-pulls.d.ts.map +0 -1
  135. package/dist/tools/git-pulls.js +0 -378
  136. package/dist/tools/git-pulls.js.map +0 -1
  137. package/dist/tools/git-release.d.ts +0 -161
  138. package/dist/tools/git-release.d.ts.map +0 -1
  139. package/dist/tools/git-release.js +0 -466
  140. package/dist/tools/git-release.js.map +0 -1
  141. package/dist/tools/git-remote.d.ts +0 -128
  142. package/dist/tools/git-remote.d.ts.map +0 -1
  143. package/dist/tools/git-remote.js +0 -542
  144. package/dist/tools/git-remote.js.map +0 -1
  145. package/dist/tools/git-reset.d.ts +0 -120
  146. package/dist/tools/git-reset.d.ts.map +0 -1
  147. package/dist/tools/git-reset.js +0 -479
  148. package/dist/tools/git-reset.js.map +0 -1
  149. package/dist/tools/git-stash.d.ts +0 -124
  150. package/dist/tools/git-stash.d.ts.map +0 -1
  151. package/dist/tools/git-stash.js +0 -506
  152. package/dist/tools/git-stash.js.map +0 -1
  153. package/dist/tools/git-sync.d.ts +0 -154
  154. package/dist/tools/git-sync.d.ts.map +0 -1
  155. package/dist/tools/git-sync.js +0 -479
  156. package/dist/tools/git-sync.js.map +0 -1
  157. package/dist/tools/git-tags.d.ts +0 -136
  158. package/dist/tools/git-tags.d.ts.map +0 -1
  159. package/dist/tools/git-tags.js +0 -470
  160. package/dist/tools/git-tags.js.map +0 -1
  161. package/dist/tools/git-update.d.ts +0 -224
  162. package/dist/tools/git-update.d.ts.map +0 -1
  163. package/dist/tools/git-update.js +0 -948
  164. package/dist/tools/git-update.js.map +0 -1
  165. package/dist/tools/git-workflow.d.ts +0 -189
  166. package/dist/tools/git-workflow.d.ts.map +0 -1
  167. package/dist/tools/git-workflow.js +0 -551
  168. package/dist/tools/git-workflow.js.map +0 -1
  169. package/dist/utils/credential-manager.d.ts +0 -119
  170. package/dist/utils/credential-manager.d.ts.map +0 -1
  171. package/dist/utils/credential-manager.js +0 -450
  172. package/dist/utils/credential-manager.js.map +0 -1
  173. package/dist/utils/data-merger.d.ts +0 -49
  174. package/dist/utils/data-merger.d.ts.map +0 -1
  175. package/dist/utils/data-merger.js +0 -233
  176. package/dist/utils/data-merger.js.map +0 -1
  177. package/dist/utils/git-command-executor.d.ts +0 -330
  178. package/dist/utils/git-command-executor.d.ts.map +0 -1
  179. package/dist/utils/git-command-executor.js +0 -901
  180. package/dist/utils/git-command-executor.js.map +0 -1
  181. package/dist/utils/logger.d.ts +0 -143
  182. package/dist/utils/logger.d.ts.map +0 -1
  183. package/dist/utils/logger.js +0 -473
  184. package/dist/utils/logger.js.map +0 -1
  185. package/dist/utils/operation-error-handler.d.ts +0 -97
  186. package/dist/utils/operation-error-handler.d.ts.map +0 -1
  187. package/dist/utils/operation-error-handler.js +0 -367
  188. package/dist/utils/operation-error-handler.js.map +0 -1
  189. package/dist/utils/parameter-validator.d.ts +0 -49
  190. package/dist/utils/parameter-validator.d.ts.map +0 -1
  191. package/dist/utils/parameter-validator.js +0 -647
  192. package/dist/utils/parameter-validator.js.map +0 -1
  193. package/dist/utils/repository-checker.d.ts +0 -46
  194. package/dist/utils/repository-checker.d.ts.map +0 -1
  195. package/dist/utils/repository-checker.js +0 -151
  196. package/dist/utils/repository-checker.js.map +0 -1
  197. package/dist/utils/repository-detector.d.ts +0 -128
  198. package/dist/utils/repository-detector.d.ts.map +0 -1
  199. package/dist/utils/repository-detector.js +0 -422
  200. package/dist/utils/repository-detector.js.map +0 -1
  201. package/dist/utils/repository-sync.d.ts +0 -67
  202. package/dist/utils/repository-sync.d.ts.map +0 -1
  203. package/dist/utils/repository-sync.js +0 -344
  204. package/dist/utils/repository-sync.js.map +0 -1
  205. package/dist/utils/response-formatter.d.ts +0 -146
  206. package/dist/utils/response-formatter.d.ts.map +0 -1
  207. package/dist/utils/response-formatter.js +0 -378
  208. package/dist/utils/response-formatter.js.map +0 -1
  209. package/dist/utils/retry.d.ts +0 -12
  210. package/dist/utils/retry.d.ts.map +0 -1
  211. package/dist/utils/retry.js +0 -28
  212. package/dist/utils/retry.js.map +0 -1
  213. package/dist/utils/safety-warnings.d.ts +0 -56
  214. package/dist/utils/safety-warnings.d.ts.map +0 -1
  215. package/dist/utils/safety-warnings.js +0 -330
  216. package/dist/utils/safety-warnings.js.map +0 -1
  217. package/dist/utils/terminal-controller.d.ts +0 -79
  218. package/dist/utils/terminal-controller.d.ts.map +0 -1
  219. package/dist/utils/terminal-controller.js +0 -291
  220. package/dist/utils/terminal-controller.js.map +0 -1
  221. package/dist/utils/user-friendly-formatter.d.ts +0 -45
  222. package/dist/utils/user-friendly-formatter.d.ts.map +0 -1
  223. package/dist/utils/user-friendly-formatter.js +0 -175
  224. package/dist/utils/user-friendly-formatter.js.map +0 -1
@@ -0,0 +1,29 @@
1
+ import { Tool, MCPContext } from '../types';
2
+ export declare class GitAnalyticsTool implements Tool {
3
+ name: string;
4
+ description: string;
5
+ handle(params: Record<string, any>, ctx: MCPContext): Promise<{
6
+ success: boolean;
7
+ stats: {
8
+ totalCommits: number;
9
+ branches: number;
10
+ tags: number;
11
+ latestCommit: (import("simple-git").DefaultLogFields & import("simple-git").ListLogLine) | null;
12
+ };
13
+ commits?: undefined;
14
+ details?: undefined;
15
+ contributors?: undefined;
16
+ } | {
17
+ success: boolean;
18
+ commits: number;
19
+ details: readonly (import("simple-git").DefaultLogFields & import("simple-git").ListLogLine)[];
20
+ stats?: undefined;
21
+ contributors?: undefined;
22
+ } | {
23
+ success: boolean;
24
+ contributors: any[];
25
+ stats?: undefined;
26
+ commits?: undefined;
27
+ details?: undefined;
28
+ }>;
29
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GitAnalyticsTool = void 0;
7
+ const simple_git_1 = __importDefault(require("simple-git"));
8
+ const errors_1 = require("../utils/errors");
9
+ class GitAnalyticsTool {
10
+ constructor() {
11
+ this.name = 'git-analytics';
12
+ this.description = 'Repository analytics and statistics';
13
+ }
14
+ async handle(params, ctx) {
15
+ const action = params.action;
16
+ const projectPath = params.projectPath;
17
+ if (!action || !projectPath) {
18
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
19
+ }
20
+ const git = (0, simple_git_1.default)({ baseDir: projectPath });
21
+ switch (action) {
22
+ case 'stats': {
23
+ const log = await git.log();
24
+ const branches = await git.branch();
25
+ const tags = await git.tags();
26
+ return {
27
+ success: true,
28
+ stats: {
29
+ totalCommits: log.total,
30
+ branches: branches.all.length,
31
+ tags: tags.all.length,
32
+ latestCommit: log.latest,
33
+ },
34
+ };
35
+ }
36
+ case 'commits': {
37
+ const since = params.since;
38
+ const until = params.until;
39
+ const log = await git.log({
40
+ from: since,
41
+ to: until,
42
+ maxCount: params.limit || 1000,
43
+ });
44
+ return {
45
+ success: true,
46
+ commits: log.all.length,
47
+ details: log.all,
48
+ };
49
+ }
50
+ case 'contributors': {
51
+ const log = await git.log();
52
+ const contributors = new Map();
53
+ log.all.forEach(commit => {
54
+ const author = commit.author_name;
55
+ if (contributors.has(author)) {
56
+ contributors.get(author).count++;
57
+ }
58
+ else {
59
+ contributors.set(author, { name: author, email: commit.author_email, count: 1 });
60
+ }
61
+ });
62
+ return {
63
+ success: true,
64
+ contributors: Array.from(contributors.values()).sort((a, b) => b.count - a.count),
65
+ };
66
+ }
67
+ default:
68
+ throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
69
+ }
70
+ }
71
+ }
72
+ exports.GitAnalyticsTool = GitAnalyticsTool;
@@ -0,0 +1,6 @@
1
+ import { Tool, MCPContext } from '../types';
2
+ export declare class GitArchiveTool implements Tool {
3
+ name: string;
4
+ description: string;
5
+ handle(params: Record<string, any>, ctx: MCPContext): Promise<void>;
6
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GitArchiveTool = void 0;
4
+ const errors_1 = require("../utils/errors");
5
+ class GitArchiveTool {
6
+ constructor() {
7
+ this.name = 'git-archive';
8
+ this.description = 'Repository archive operations';
9
+ }
10
+ async handle(params, ctx) {
11
+ const action = params.action;
12
+ const projectPath = params.projectPath;
13
+ if (!action || !projectPath) {
14
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
15
+ }
16
+ switch (action) {
17
+ case 'create':
18
+ case 'extract':
19
+ case 'list':
20
+ case 'verify':
21
+ throw new errors_1.MCPError('NOT_IMPLEMENTED', `Action ${action} not yet fully implemented`);
22
+ default:
23
+ throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
24
+ }
25
+ }
26
+ }
27
+ exports.GitArchiveTool = GitArchiveTool;
@@ -0,0 +1,10 @@
1
+ import { Tool, MCPContext } from '../types';
2
+ export declare class GitBackupTool implements Tool {
3
+ name: string;
4
+ description: string;
5
+ handle(params: Record<string, any>, ctx: MCPContext): Promise<{
6
+ success: boolean;
7
+ backupPath: any;
8
+ message: string;
9
+ }>;
10
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GitBackupTool = void 0;
7
+ const promises_1 = __importDefault(require("fs/promises"));
8
+ const errors_1 = require("../utils/errors");
9
+ class GitBackupTool {
10
+ constructor() {
11
+ this.name = 'git-backup';
12
+ this.description = 'Repository backup and restore operations';
13
+ }
14
+ async handle(params, ctx) {
15
+ const action = params.action;
16
+ const projectPath = params.projectPath;
17
+ if (!action || !projectPath) {
18
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
19
+ }
20
+ switch (action) {
21
+ case 'backup': {
22
+ const backupPath = params.backupPath || `${projectPath}-backup-${Date.now()}.tar.gz`;
23
+ // Simplified: just create a marker file
24
+ await promises_1.default.writeFile(backupPath, JSON.stringify({
25
+ path: projectPath,
26
+ timestamp: new Date().toISOString(),
27
+ }));
28
+ return { success: true, backupPath, message: 'Backup created (simplified)' };
29
+ }
30
+ case 'restore': {
31
+ throw new errors_1.MCPError('NOT_IMPLEMENTED', 'Restore not yet fully implemented');
32
+ }
33
+ case 'list': {
34
+ throw new errors_1.MCPError('NOT_IMPLEMENTED', 'List not yet fully implemented');
35
+ }
36
+ case 'verify': {
37
+ throw new errors_1.MCPError('NOT_IMPLEMENTED', 'Verify not yet fully implemented');
38
+ }
39
+ default:
40
+ throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
41
+ }
42
+ }
43
+ }
44
+ exports.GitBackupTool = GitBackupTool;
@@ -0,0 +1,72 @@
1
+ import { Tool, MCPContext } from '../types';
2
+ export declare class GitBranchesTool implements Tool {
3
+ name: string;
4
+ description: string;
5
+ handle(params: Record<string, any>, ctx: MCPContext): Promise<{
6
+ success: boolean;
7
+ branch: any;
8
+ branches?: undefined;
9
+ current?: undefined;
10
+ deleted?: undefined;
11
+ result?: undefined;
12
+ baseBranch?: undefined;
13
+ compareBranch?: undefined;
14
+ commits?: undefined;
15
+ diff?: undefined;
16
+ } | {
17
+ branches: string[];
18
+ current: string;
19
+ success?: undefined;
20
+ branch?: undefined;
21
+ deleted?: undefined;
22
+ result?: undefined;
23
+ baseBranch?: undefined;
24
+ compareBranch?: undefined;
25
+ commits?: undefined;
26
+ diff?: undefined;
27
+ } | {
28
+ branch: string;
29
+ current: boolean;
30
+ success?: undefined;
31
+ branches?: undefined;
32
+ deleted?: undefined;
33
+ result?: undefined;
34
+ baseBranch?: undefined;
35
+ compareBranch?: undefined;
36
+ commits?: undefined;
37
+ diff?: undefined;
38
+ } | {
39
+ success: boolean;
40
+ deleted: any;
41
+ branch?: undefined;
42
+ branches?: undefined;
43
+ current?: undefined;
44
+ result?: undefined;
45
+ baseBranch?: undefined;
46
+ compareBranch?: undefined;
47
+ commits?: undefined;
48
+ diff?: undefined;
49
+ } | {
50
+ success: boolean;
51
+ result: import("simple-git").MergeResult;
52
+ branch?: undefined;
53
+ branches?: undefined;
54
+ current?: undefined;
55
+ deleted?: undefined;
56
+ baseBranch?: undefined;
57
+ compareBranch?: undefined;
58
+ commits?: undefined;
59
+ diff?: undefined;
60
+ } | {
61
+ baseBranch: any;
62
+ compareBranch: any;
63
+ commits: readonly (import("simple-git").DefaultLogFields & import("simple-git").ListLogLine)[];
64
+ diff: string;
65
+ success?: undefined;
66
+ branch?: undefined;
67
+ branches?: undefined;
68
+ current?: undefined;
69
+ deleted?: undefined;
70
+ result?: undefined;
71
+ }>;
72
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GitBranchesTool = void 0;
7
+ const simple_git_1 = __importDefault(require("simple-git"));
8
+ const errors_1 = require("../utils/errors");
9
+ const safetyController_1 = require("../utils/safetyController");
10
+ class GitBranchesTool {
11
+ constructor() {
12
+ this.name = 'git-branches';
13
+ this.description = 'Branch management operations';
14
+ }
15
+ async handle(params, ctx) {
16
+ const action = params.action;
17
+ const projectPath = params.projectPath;
18
+ if (!action || !projectPath) {
19
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
20
+ }
21
+ const git = (0, simple_git_1.default)({ baseDir: projectPath });
22
+ switch (action) {
23
+ case 'create': {
24
+ const branchName = params.branchName;
25
+ if (!branchName)
26
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'branchName is required');
27
+ const sourceBranch = params.sourceBranch;
28
+ if (sourceBranch) {
29
+ await git.checkout(sourceBranch);
30
+ }
31
+ await git.checkoutLocalBranch(branchName);
32
+ if (params.checkout !== false) {
33
+ await git.checkout(branchName);
34
+ }
35
+ return { success: true, branch: branchName };
36
+ }
37
+ case 'list': {
38
+ const branches = await git.branch();
39
+ return {
40
+ branches: branches.all,
41
+ current: branches.current,
42
+ };
43
+ }
44
+ case 'get': {
45
+ const branchName = params.branchName;
46
+ if (!branchName)
47
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'branchName is required');
48
+ const branches = await git.branch();
49
+ const branch = branches.all.find(b => b === branchName);
50
+ if (!branch) {
51
+ throw new errors_1.MCPError('BRANCH_NOT_FOUND', `Branch '${branchName}' not found`, [
52
+ 'Check if the branch name is correct',
53
+ 'Use git branch -a to see all available branches',
54
+ ]);
55
+ }
56
+ return { branch, current: branches.current === branchName };
57
+ }
58
+ case 'delete': {
59
+ (0, safetyController_1.requireConfirmationIfDestructive)('delete', params);
60
+ const branchName = params.branchName;
61
+ if (!branchName)
62
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'branchName is required');
63
+ await git.deleteLocalBranch(branchName, params.force);
64
+ return { success: true, deleted: branchName };
65
+ }
66
+ case 'merge': {
67
+ const branchName = params.branchName;
68
+ const targetBranch = params.targetBranch;
69
+ if (!branchName)
70
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'branchName is required');
71
+ if (targetBranch) {
72
+ await git.checkout(targetBranch);
73
+ }
74
+ const result = await git.merge([branchName]);
75
+ return { success: true, result };
76
+ }
77
+ case 'compare': {
78
+ const baseBranch = params.baseBranch;
79
+ const compareBranch = params.compareBranch;
80
+ if (!baseBranch || !compareBranch) {
81
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'baseBranch and compareBranch are required');
82
+ }
83
+ const diff = await git.diff([`${baseBranch}...${compareBranch}`]);
84
+ const log = await git.log({ from: baseBranch, to: compareBranch });
85
+ return {
86
+ baseBranch,
87
+ compareBranch,
88
+ commits: log.all,
89
+ diff,
90
+ };
91
+ }
92
+ default:
93
+ throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
94
+ }
95
+ }
96
+ }
97
+ exports.GitBranchesTool = GitBranchesTool;
@@ -0,0 +1,34 @@
1
+ import { Tool, MCPContext } from '../types';
2
+ export declare class GitConfigTool implements Tool {
3
+ name: string;
4
+ description: string;
5
+ handle(params: Record<string, any>, ctx: MCPContext): Promise<{
6
+ success: boolean;
7
+ key: any;
8
+ value: any;
9
+ message?: undefined;
10
+ scope?: undefined;
11
+ configs?: undefined;
12
+ } | {
13
+ success: boolean;
14
+ key: any;
15
+ message: string;
16
+ value?: undefined;
17
+ scope?: undefined;
18
+ configs?: undefined;
19
+ } | {
20
+ success: boolean;
21
+ scope: string;
22
+ configs: import("simple-git").ConfigValues;
23
+ key?: undefined;
24
+ value?: undefined;
25
+ message?: undefined;
26
+ } | {
27
+ success: boolean;
28
+ key: any;
29
+ value: string | null;
30
+ scope: string | undefined;
31
+ message?: undefined;
32
+ configs?: undefined;
33
+ }>;
34
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GitConfigTool = void 0;
7
+ const simple_git_1 = __importDefault(require("simple-git"));
8
+ const errors_1 = require("../utils/errors");
9
+ class GitConfigTool {
10
+ constructor() {
11
+ this.name = 'git-config';
12
+ this.description = 'Git configuration management';
13
+ }
14
+ async handle(params, ctx) {
15
+ const action = params.action;
16
+ const projectPath = params.projectPath;
17
+ if (!action || !projectPath) {
18
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
19
+ }
20
+ const git = (0, simple_git_1.default)({ baseDir: projectPath });
21
+ const scope = params.global ? 'global' : params.system ? 'system' : 'local';
22
+ switch (action) {
23
+ case 'get': {
24
+ const key = params.key;
25
+ if (!key)
26
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'key is required');
27
+ try {
28
+ const value = await git.getConfig(key, scope);
29
+ return { success: true, key, value: value.value };
30
+ }
31
+ catch (err) {
32
+ throw new errors_1.MCPError('CONFIG_NOT_FOUND', `Configuration key '${key}' not found`);
33
+ }
34
+ }
35
+ case 'set': {
36
+ const key = params.key;
37
+ const value = params.value;
38
+ if (!key || value === undefined)
39
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'key and value are required');
40
+ await git.addConfig(key, value, false, scope);
41
+ return { success: true, key, value };
42
+ }
43
+ case 'unset': {
44
+ const key = params.key;
45
+ if (!key)
46
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'key is required');
47
+ await git.raw(['config', `--${scope}`, '--unset', key]);
48
+ return { success: true, key, message: 'Configuration removed' };
49
+ }
50
+ case 'list': {
51
+ const configs = await git.listConfig(scope);
52
+ return { success: true, scope, configs: configs.all };
53
+ }
54
+ case 'show': {
55
+ const key = params.key;
56
+ if (!key)
57
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'key is required');
58
+ const value = await git.getConfig(key, scope);
59
+ return {
60
+ success: true,
61
+ key,
62
+ value: value.value,
63
+ scope: params.showScope ? scope : undefined,
64
+ };
65
+ }
66
+ case 'edit':
67
+ throw new errors_1.MCPError('NOT_IMPLEMENTED', 'Edit action requires manual editing of config file');
68
+ default:
69
+ throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
70
+ }
71
+ }
72
+ }
73
+ exports.GitConfigTool = GitConfigTool;
@@ -0,0 +1,24 @@
1
+ import { Tool } from '../types';
2
+ export declare class GitFilesTool implements Tool {
3
+ name: string;
4
+ description: string;
5
+ handle(params: Record<string, any>): Promise<{
6
+ path: string;
7
+ content: string;
8
+ files?: undefined;
9
+ matches?: undefined;
10
+ } | {
11
+ files: string[];
12
+ path?: undefined;
13
+ content?: undefined;
14
+ matches?: undefined;
15
+ } | {
16
+ matches: {
17
+ file: string;
18
+ snippet: string;
19
+ }[];
20
+ path?: undefined;
21
+ content?: undefined;
22
+ files?: undefined;
23
+ }>;
24
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GitFilesTool = void 0;
7
+ const promises_1 = __importDefault(require("fs/promises"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const errors_1 = require("../utils/errors");
10
+ class GitFilesTool {
11
+ constructor() {
12
+ this.name = 'git-files';
13
+ this.description = 'Read-only file operations for repositories';
14
+ }
15
+ async handle(params) {
16
+ const action = params.action;
17
+ const projectPath = params.projectPath;
18
+ if (!action || !projectPath)
19
+ throw new errors_1.MCPError('VALIDATION_ERROR', 'action and projectPath are required');
20
+ const fullPath = path_1.default.resolve(projectPath, params.filePath ?? '');
21
+ if (action === 'read') {
22
+ const content = await promises_1.default.readFile(fullPath, 'utf8');
23
+ return { path: fullPath, content };
24
+ }
25
+ if (action === 'list') {
26
+ const files = await promises_1.default.readdir(projectPath);
27
+ return { files };
28
+ }
29
+ // Blocked operations
30
+ if (['create', 'update', 'delete'].includes(action)) {
31
+ throw new errors_1.MCPError('OPERATION_RESTRICTED', 'File modification operations are blocked via MCP.');
32
+ }
33
+ if (action === 'search') {
34
+ // Simple string search within files in projectPath (non-recursive)
35
+ const files = await promises_1.default.readdir(projectPath);
36
+ const q = params.query ?? '';
37
+ const matches = [];
38
+ for (const f of files) {
39
+ try {
40
+ const txt = await promises_1.default.readFile(path_1.default.join(projectPath, f), 'utf8');
41
+ if (txt.includes(q))
42
+ matches.push({ file: f, snippet: txt.substr(txt.indexOf(q), 200) });
43
+ }
44
+ catch (e) {
45
+ // ignore binary/unreadable
46
+ }
47
+ }
48
+ return { matches };
49
+ }
50
+ throw new errors_1.MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
51
+ }
52
+ }
53
+ exports.GitFilesTool = GitFilesTool;
@@ -0,0 +1,21 @@
1
+ import { Tool, MCPContext } from '../types';
2
+ export declare class GitIssuesTool implements Tool {
3
+ name: string;
4
+ description: string;
5
+ handle(params: Record<string, any>, ctx: MCPContext): Promise<{
6
+ success: boolean;
7
+ issue: any;
8
+ issues?: undefined;
9
+ comment?: undefined;
10
+ } | {
11
+ success: boolean;
12
+ issues: any;
13
+ issue?: undefined;
14
+ comment?: undefined;
15
+ } | {
16
+ success: boolean;
17
+ comment: any;
18
+ issue?: undefined;
19
+ issues?: undefined;
20
+ }>;
21
+ }