@andrebuzeli/git-mcp 10.0.9 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -428
- package/bin/git-mcp.js +21 -0
- package/docs/TOOLS.md +110 -0
- package/mcp.json.template +12 -0
- package/package.json +9 -76
- package/src/local/git.js +14 -0
- package/src/providers/gitea.js +13 -0
- package/src/providers/github.js +13 -0
- package/src/server.js +63 -0
- package/src/tools/git-actions.js +19 -0
- package/src/tools/git-activity.js +28 -0
- package/src/tools/git-admin.js +20 -0
- package/src/tools/git-checks.js +14 -0
- package/src/tools/git-commits.js +34 -0
- package/src/tools/git-contents.js +30 -0
- package/src/tools/git-deployments.js +21 -0
- package/src/tools/git-gists.js +15 -0
- package/src/tools/git-gitdata.js +19 -0
- package/src/tools/git-issues-prs.js +44 -0
- package/src/tools/git-issues.js +12 -0
- package/src/tools/git-local.js +66 -0
- package/src/tools/git-meta.js +19 -0
- package/src/tools/git-misc.js +21 -0
- package/src/tools/git-orgs.js +26 -0
- package/src/tools/git-packages.js +12 -0
- package/src/tools/git-raw.js +14 -0
- package/src/tools/git-releases.js +17 -0
- package/src/tools/git-remote.js +29 -0
- package/src/tools/git-repos.js +60 -0
- package/src/tools/git-search.js +18 -0
- package/src/tools/git-sync.js +40 -0
- package/src/tools/git-user.js +26 -0
- package/src/tools/schema.js +3 -0
- package/src/utils/fs.js +29 -0
- package/src/utils/project.js +7 -0
- package/tests/errors.js +26 -0
- package/tests/full_suite.js +98 -0
- package/tests/run.js +50 -0
- package/LICENSE +0 -21
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -224
- package/dist/prompts/gitPrompts.d.ts +0 -93
- package/dist/prompts/gitPrompts.js +0 -177
- package/dist/providers/giteaProvider.d.ts +0 -3
- package/dist/providers/giteaProvider.js +0 -6
- package/dist/providers/githubProvider.d.ts +0 -2
- package/dist/providers/githubProvider.js +0 -4
- package/dist/providers/providerManager.d.ts +0 -11
- package/dist/providers/providerManager.js +0 -49
- package/dist/resources/toolsGuide.d.ts +0 -12
- package/dist/resources/toolsGuide.js +0 -1713
- package/dist/scripts/test_e2e.d.ts +0 -1
- package/dist/scripts/test_e2e.js +0 -199
- package/dist/scripts/test_exhaustive.d.ts +0 -1
- package/dist/scripts/test_exhaustive.js +0 -275
- package/dist/scripts/test_gitea_creation.d.ts +0 -1
- package/dist/scripts/test_gitea_creation.js +0 -116
- package/dist/scripts/verify_setup.d.ts +0 -1
- package/dist/scripts/verify_setup.js +0 -61
- package/dist/server.d.ts +0 -9
- package/dist/server.js +0 -73
- package/dist/tools/gitAnalytics.d.ts +0 -35
- package/dist/tools/gitAnalytics.js +0 -220
- package/dist/tools/gitArchive.d.ts +0 -119
- package/dist/tools/gitArchive.js +0 -150
- package/dist/tools/gitBackup.d.ts +0 -116
- package/dist/tools/gitBackup.js +0 -156
- package/dist/tools/gitBranches.d.ts +0 -54
- package/dist/tools/gitBranches.js +0 -282
- package/dist/tools/gitChangelog.d.ts +0 -37
- package/dist/tools/gitChangelog.js +0 -67
- package/dist/tools/gitConfig.d.ts +0 -97
- package/dist/tools/gitConfig.js +0 -125
- package/dist/tools/gitFiles.d.ts +0 -129
- package/dist/tools/gitFiles.js +0 -213
- package/dist/tools/gitFix.d.ts +0 -4
- package/dist/tools/gitFix.js +0 -159
- package/dist/tools/gitFix.tool.d.ts +0 -31
- package/dist/tools/gitFix.tool.js +0 -92
- package/dist/tools/gitHistory.d.ts +0 -41
- package/dist/tools/gitHistory.js +0 -349
- package/dist/tools/gitIgnore.d.ts +0 -214
- package/dist/tools/gitIgnore.js +0 -338
- package/dist/tools/gitIssues.d.ts +0 -80
- package/dist/tools/gitIssues.js +0 -363
- package/dist/tools/gitLog.d.ts +0 -30
- package/dist/tools/gitLog.js +0 -46
- package/dist/tools/gitMonitor.d.ts +0 -30
- package/dist/tools/gitMonitor.js +0 -284
- package/dist/tools/gitPackages.d.ts +0 -180
- package/dist/tools/gitPackages.js +0 -214
- package/dist/tools/gitPulls.d.ts +0 -66
- package/dist/tools/gitPulls.js +0 -347
- package/dist/tools/gitPush.d.ts +0 -40
- package/dist/tools/gitPush.js +0 -59
- package/dist/tools/gitRelease.d.ts +0 -49
- package/dist/tools/gitRelease.js +0 -359
- package/dist/tools/gitRemote.d.ts +0 -47
- package/dist/tools/gitRemote.js +0 -111
- package/dist/tools/gitReset.d.ts +0 -57
- package/dist/tools/gitReset.js +0 -79
- package/dist/tools/gitStash.d.ts +0 -61
- package/dist/tools/gitStash.js +0 -80
- package/dist/tools/gitSync.d.ts +0 -34
- package/dist/tools/gitSync.js +0 -182
- package/dist/tools/gitTags.d.ts +0 -45
- package/dist/tools/gitTags.js +0 -251
- package/dist/tools/gitUpdate.d.ts +0 -60
- package/dist/tools/gitUpdate.js +0 -474
- package/dist/tools/gitUpload.d.ts +0 -35
- package/dist/tools/gitUpload.js +0 -385
- package/dist/tools/gitWorkflow.d.ts +0 -117
- package/dist/tools/gitWorkflow.js +0 -472
- package/dist/types.d.ts +0 -20
- package/dist/types.js +0 -1
- package/dist/utils/agentHelpers.d.ts +0 -11
- package/dist/utils/agentHelpers.js +0 -41
- package/dist/utils/apiHelpers.d.ts +0 -29
- package/dist/utils/apiHelpers.js +0 -125
- package/dist/utils/cache.d.ts +0 -96
- package/dist/utils/cache.js +0 -208
- package/dist/utils/contextDetector.d.ts +0 -0
- package/dist/utils/contextDetector.js +0 -1
- package/dist/utils/errors.d.ts +0 -13
- package/dist/utils/errors.js +0 -17
- package/dist/utils/gitAdapter.d.ts +0 -224
- package/dist/utils/gitAdapter.js +0 -1162
- package/dist/utils/logger.d.ts +0 -45
- package/dist/utils/logger.js +0 -140
- package/dist/utils/rateLimiter.d.ts +0 -113
- package/dist/utils/rateLimiter.js +0 -257
- package/dist/utils/repoHelpers.d.ts +0 -44
- package/dist/utils/repoHelpers.js +0 -122
- package/dist/utils/safetyController.d.ts +0 -1
- package/dist/utils/safetyController.js +0 -12
- package/dist/utils/validation.d.ts +0 -115
- package/dist/utils/validation.js +0 -270
package/dist/tools/gitMonitor.js
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { MCPError } from '../utils/errors.js';
|
|
2
|
-
import { getRepoInfo } from '../utils/repoHelpers.js';
|
|
3
|
-
import axios from 'axios';
|
|
4
|
-
export class GitMonitorTool {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.name = 'git-monitor';
|
|
7
|
-
this.description = 'Repository monitoring and status operations - automatic dual-provider execution for remote queries';
|
|
8
|
-
this.inputSchema = {
|
|
9
|
-
type: "object",
|
|
10
|
-
properties: {
|
|
11
|
-
projectPath: {
|
|
12
|
-
type: "string",
|
|
13
|
-
description: "The absolute path to the Git repository directory on the local filesystem. This should be the root directory containing the .git folder. For example: '/home/user/my-project' on Linux/Mac or 'C:\\Users\\user\\my-project' on Windows."
|
|
14
|
-
},
|
|
15
|
-
action: {
|
|
16
|
-
type: "string",
|
|
17
|
-
enum: ["log", "status", "commits", "contributors"],
|
|
18
|
-
description: "Monitor operation to perform: log (get activity log), status (get repo status), commits (get commit activity), contributors (get contributor activity)"
|
|
19
|
-
},
|
|
20
|
-
since: {
|
|
21
|
-
type: "string",
|
|
22
|
-
description: "Start date for activity query (ISO 8601, optional)"
|
|
23
|
-
},
|
|
24
|
-
until: {
|
|
25
|
-
type: "string",
|
|
26
|
-
description: "End date for activity query (ISO 8601, optional)"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
required: ["projectPath", "action"],
|
|
30
|
-
additionalProperties: true
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
async handle(params, ctx) {
|
|
34
|
-
const action = params.action;
|
|
35
|
-
const projectPath = params.projectPath;
|
|
36
|
-
if (!action || !projectPath) {
|
|
37
|
-
throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
|
|
38
|
-
}
|
|
39
|
-
const git = ctx.gitAdapter;
|
|
40
|
-
switch (action) {
|
|
41
|
-
case 'log': {
|
|
42
|
-
const options = {
|
|
43
|
-
maxCount: params.limit || 10,
|
|
44
|
-
};
|
|
45
|
-
if (params.since)
|
|
46
|
-
options.from = params.since; // Note: GitAdapter log doesn't support 'from' date filtering natively yet, but we pass it anyway or ignore
|
|
47
|
-
// GitAdapter log supports 'ref' and 'maxCount'. Date filtering would need to be done manually if not supported.
|
|
48
|
-
// For now, we'll just get the log and filter if needed, or rely on maxCount.
|
|
49
|
-
const logEntries = await git.log(projectPath, options);
|
|
50
|
-
const results = {
|
|
51
|
-
success: true,
|
|
52
|
-
local: {
|
|
53
|
-
commits: logEntries,
|
|
54
|
-
total: logEntries.length,
|
|
55
|
-
},
|
|
56
|
-
providers: {}
|
|
57
|
-
};
|
|
58
|
-
// Also query remote APIs
|
|
59
|
-
const repoInfo = getRepoInfo(projectPath);
|
|
60
|
-
const repo = params.repo || repoInfo.repoName;
|
|
61
|
-
const githubOwner = params.owner || process.env.GITHUB_USERNAME;
|
|
62
|
-
const giteaOwner = params.owner || process.env.GITEA_USERNAME;
|
|
63
|
-
// GitHub
|
|
64
|
-
if (ctx.providerManager.github && githubOwner) {
|
|
65
|
-
try {
|
|
66
|
-
const commits = await ctx.providerManager.github.rest.repos.listCommits({
|
|
67
|
-
owner: githubOwner,
|
|
68
|
-
repo: repo,
|
|
69
|
-
since: params.since,
|
|
70
|
-
until: params.until,
|
|
71
|
-
per_page: params.limit || 10,
|
|
72
|
-
});
|
|
73
|
-
results.providers.github = {
|
|
74
|
-
success: true,
|
|
75
|
-
commits: commits.data.map((c) => ({
|
|
76
|
-
sha: c.sha,
|
|
77
|
-
message: c.commit.message,
|
|
78
|
-
author: c.commit.author.name,
|
|
79
|
-
email: c.commit.author.email,
|
|
80
|
-
date: c.commit.author.date,
|
|
81
|
-
url: c.html_url,
|
|
82
|
-
})),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
results.providers.github = { success: false, error: err.message };
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// Gitea
|
|
90
|
-
if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
|
|
91
|
-
try {
|
|
92
|
-
const commits = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/commits`, {
|
|
93
|
-
params: {
|
|
94
|
-
since: params.since,
|
|
95
|
-
until: params.until,
|
|
96
|
-
limit: params.limit || 10,
|
|
97
|
-
},
|
|
98
|
-
headers: { Authorization: `token ${ctx.providerManager.giteaToken}` }
|
|
99
|
-
});
|
|
100
|
-
results.providers.gitea = {
|
|
101
|
-
success: true,
|
|
102
|
-
commits: commits.data.map((c) => ({
|
|
103
|
-
sha: c.sha,
|
|
104
|
-
message: c.commit.message,
|
|
105
|
-
author: c.commit.author.name,
|
|
106
|
-
email: c.commit.author.email,
|
|
107
|
-
date: c.commit.author.date,
|
|
108
|
-
url: c.html_url,
|
|
109
|
-
})),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
results.providers.gitea = { success: false, error: err.message };
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return results;
|
|
117
|
-
}
|
|
118
|
-
case 'status': {
|
|
119
|
-
const status = await git.status(projectPath);
|
|
120
|
-
const detailed = params.detailed ? {
|
|
121
|
-
branch: status.current,
|
|
122
|
-
ahead: status.ahead,
|
|
123
|
-
behind: status.behind,
|
|
124
|
-
staged: status.staged,
|
|
125
|
-
modified: status.modified,
|
|
126
|
-
deleted: status.deleted,
|
|
127
|
-
created: status.created,
|
|
128
|
-
renamed: status.renamed,
|
|
129
|
-
conflicted: status.conflicted,
|
|
130
|
-
not_added: status.not_added,
|
|
131
|
-
} : status;
|
|
132
|
-
return { success: true, local: { status: detailed } };
|
|
133
|
-
}
|
|
134
|
-
case 'commits': {
|
|
135
|
-
const branch = params.branch;
|
|
136
|
-
const options = {
|
|
137
|
-
maxCount: params.limit || 50,
|
|
138
|
-
ref: branch
|
|
139
|
-
};
|
|
140
|
-
const logEntries = await git.log(projectPath, options);
|
|
141
|
-
const results = {
|
|
142
|
-
success: true,
|
|
143
|
-
local: {
|
|
144
|
-
commits: logEntries.map(c => ({
|
|
145
|
-
hash: c.hash,
|
|
146
|
-
date: c.date,
|
|
147
|
-
message: c.message,
|
|
148
|
-
author: c.author_name,
|
|
149
|
-
email: c.author_email,
|
|
150
|
-
})),
|
|
151
|
-
},
|
|
152
|
-
providers: {}
|
|
153
|
-
};
|
|
154
|
-
// Also query remote APIs
|
|
155
|
-
const repoInfo = getRepoInfo(projectPath);
|
|
156
|
-
const repo = params.repo || repoInfo.repoName;
|
|
157
|
-
const githubOwner = params.owner || process.env.GITHUB_USERNAME;
|
|
158
|
-
const giteaOwner = params.owner || process.env.GITEA_USERNAME;
|
|
159
|
-
// GitHub
|
|
160
|
-
if (ctx.providerManager.github && githubOwner) {
|
|
161
|
-
try {
|
|
162
|
-
const commits = await ctx.providerManager.github.rest.repos.listCommits({
|
|
163
|
-
owner: githubOwner,
|
|
164
|
-
repo: repo,
|
|
165
|
-
sha: branch,
|
|
166
|
-
since: params.since,
|
|
167
|
-
per_page: params.limit || 50,
|
|
168
|
-
});
|
|
169
|
-
results.providers.github = {
|
|
170
|
-
success: true,
|
|
171
|
-
commits: commits.data.map((c) => ({
|
|
172
|
-
sha: c.sha,
|
|
173
|
-
message: c.commit.message,
|
|
174
|
-
author: c.commit.author.name,
|
|
175
|
-
email: c.commit.author.email,
|
|
176
|
-
date: c.commit.author.date,
|
|
177
|
-
})),
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
catch (err) {
|
|
181
|
-
results.providers.github = { success: false, error: err.message };
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
// Gitea
|
|
185
|
-
if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
|
|
186
|
-
try {
|
|
187
|
-
const commits = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/commits`, {
|
|
188
|
-
params: {
|
|
189
|
-
sha: branch,
|
|
190
|
-
since: params.since,
|
|
191
|
-
limit: params.limit || 50,
|
|
192
|
-
},
|
|
193
|
-
headers: { Authorization: `token ${ctx.providerManager.giteaToken}` }
|
|
194
|
-
});
|
|
195
|
-
results.providers.gitea = {
|
|
196
|
-
success: true,
|
|
197
|
-
commits: commits.data.map((c) => ({
|
|
198
|
-
sha: c.sha,
|
|
199
|
-
message: c.commit.message,
|
|
200
|
-
author: c.commit.author.name,
|
|
201
|
-
email: c.commit.author.email,
|
|
202
|
-
date: c.commit.author.date,
|
|
203
|
-
})),
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
catch (err) {
|
|
207
|
-
results.providers.gitea = { success: false, error: err.message };
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return results;
|
|
211
|
-
}
|
|
212
|
-
case 'contributors': {
|
|
213
|
-
const logEntries = await git.log(projectPath);
|
|
214
|
-
const contributors = new Map();
|
|
215
|
-
logEntries.forEach(commit => {
|
|
216
|
-
const key = commit.author_email;
|
|
217
|
-
if (contributors.has(key)) {
|
|
218
|
-
contributors.get(key).commits++;
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
contributors.set(key, {
|
|
222
|
-
name: commit.author_name,
|
|
223
|
-
email: commit.author_email,
|
|
224
|
-
commits: 1,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
const sorted = Array.from(contributors.values()).sort((a, b) => b.commits - a.commits);
|
|
229
|
-
const results = {
|
|
230
|
-
success: true,
|
|
231
|
-
local: { contributors: sorted },
|
|
232
|
-
providers: {}
|
|
233
|
-
};
|
|
234
|
-
// Also query remote APIs
|
|
235
|
-
const repoInfo = getRepoInfo(projectPath);
|
|
236
|
-
const repo = params.repo || repoInfo.repoName;
|
|
237
|
-
const githubOwner = params.owner || process.env.GITHUB_USERNAME;
|
|
238
|
-
const giteaOwner = params.owner || process.env.GITEA_USERNAME;
|
|
239
|
-
// GitHub
|
|
240
|
-
if (ctx.providerManager.github && githubOwner) {
|
|
241
|
-
try {
|
|
242
|
-
const contributors = await ctx.providerManager.github.rest.repos.listContributors({
|
|
243
|
-
owner: githubOwner,
|
|
244
|
-
repo: repo,
|
|
245
|
-
});
|
|
246
|
-
results.providers.github = {
|
|
247
|
-
success: true,
|
|
248
|
-
contributors: contributors.data.map((c) => ({
|
|
249
|
-
login: c.login,
|
|
250
|
-
contributions: c.contributions,
|
|
251
|
-
avatar_url: c.avatar_url,
|
|
252
|
-
url: c.html_url,
|
|
253
|
-
})),
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
catch (err) {
|
|
257
|
-
results.providers.github = { success: false, error: err.message };
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
// Gitea
|
|
261
|
-
if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
|
|
262
|
-
try {
|
|
263
|
-
const contributors = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/contributors`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
|
|
264
|
-
results.providers.gitea = {
|
|
265
|
-
success: true,
|
|
266
|
-
contributors: contributors.data.map((c) => ({
|
|
267
|
-
login: c.login,
|
|
268
|
-
name: c.name || c.login,
|
|
269
|
-
contributions: c.contributions,
|
|
270
|
-
avatar_url: c.avatar_url,
|
|
271
|
-
})),
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
catch (err) {
|
|
275
|
-
results.providers.gitea = { success: false, error: err.message };
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return results;
|
|
279
|
-
}
|
|
280
|
-
default:
|
|
281
|
-
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { Tool, MCPContext } from '../types.js';
|
|
2
|
-
export declare class GitPackagesTool implements Tool {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
inputSchema: {
|
|
6
|
-
type: "object";
|
|
7
|
-
properties: {
|
|
8
|
-
projectPath: {
|
|
9
|
-
type: string;
|
|
10
|
-
description: string;
|
|
11
|
-
};
|
|
12
|
-
action: {
|
|
13
|
-
type: string;
|
|
14
|
-
enum: string[];
|
|
15
|
-
description: string;
|
|
16
|
-
};
|
|
17
|
-
confirm: {
|
|
18
|
-
type: string;
|
|
19
|
-
description: string;
|
|
20
|
-
};
|
|
21
|
-
packageName: {
|
|
22
|
-
type: string;
|
|
23
|
-
description: string;
|
|
24
|
-
};
|
|
25
|
-
packageType: {
|
|
26
|
-
type: string;
|
|
27
|
-
enum: string[];
|
|
28
|
-
description: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
required: string[];
|
|
32
|
-
};
|
|
33
|
-
handle(params: Record<string, any>, ctx: MCPContext): Promise<{
|
|
34
|
-
success: boolean;
|
|
35
|
-
name: any;
|
|
36
|
-
version: any;
|
|
37
|
-
dependencies: any;
|
|
38
|
-
devDependencies: any;
|
|
39
|
-
scripts: any;
|
|
40
|
-
message?: undefined;
|
|
41
|
-
note?: undefined;
|
|
42
|
-
created?: undefined;
|
|
43
|
-
path?: undefined;
|
|
44
|
-
package?: undefined;
|
|
45
|
-
updated?: undefined;
|
|
46
|
-
deleted?: undefined;
|
|
47
|
-
instructions?: undefined;
|
|
48
|
-
projectPath?: undefined;
|
|
49
|
-
} | {
|
|
50
|
-
success: boolean;
|
|
51
|
-
message: string;
|
|
52
|
-
note: string;
|
|
53
|
-
name?: undefined;
|
|
54
|
-
version?: undefined;
|
|
55
|
-
dependencies?: undefined;
|
|
56
|
-
devDependencies?: undefined;
|
|
57
|
-
scripts?: undefined;
|
|
58
|
-
created?: undefined;
|
|
59
|
-
path?: undefined;
|
|
60
|
-
package?: undefined;
|
|
61
|
-
updated?: undefined;
|
|
62
|
-
deleted?: undefined;
|
|
63
|
-
instructions?: undefined;
|
|
64
|
-
projectPath?: undefined;
|
|
65
|
-
} | {
|
|
66
|
-
success: boolean;
|
|
67
|
-
created: boolean;
|
|
68
|
-
path: string;
|
|
69
|
-
package: any;
|
|
70
|
-
name?: undefined;
|
|
71
|
-
version?: undefined;
|
|
72
|
-
dependencies?: undefined;
|
|
73
|
-
devDependencies?: undefined;
|
|
74
|
-
scripts?: undefined;
|
|
75
|
-
message?: undefined;
|
|
76
|
-
note?: undefined;
|
|
77
|
-
updated?: undefined;
|
|
78
|
-
deleted?: undefined;
|
|
79
|
-
instructions?: undefined;
|
|
80
|
-
projectPath?: undefined;
|
|
81
|
-
} | {
|
|
82
|
-
success: boolean;
|
|
83
|
-
updated: boolean;
|
|
84
|
-
path: string;
|
|
85
|
-
package: any;
|
|
86
|
-
name?: undefined;
|
|
87
|
-
version?: undefined;
|
|
88
|
-
dependencies?: undefined;
|
|
89
|
-
devDependencies?: undefined;
|
|
90
|
-
scripts?: undefined;
|
|
91
|
-
message?: undefined;
|
|
92
|
-
note?: undefined;
|
|
93
|
-
created?: undefined;
|
|
94
|
-
deleted?: undefined;
|
|
95
|
-
instructions?: undefined;
|
|
96
|
-
projectPath?: undefined;
|
|
97
|
-
} | {
|
|
98
|
-
success: boolean;
|
|
99
|
-
deleted: boolean;
|
|
100
|
-
path: string;
|
|
101
|
-
name?: undefined;
|
|
102
|
-
version?: undefined;
|
|
103
|
-
dependencies?: undefined;
|
|
104
|
-
devDependencies?: undefined;
|
|
105
|
-
scripts?: undefined;
|
|
106
|
-
message?: undefined;
|
|
107
|
-
note?: undefined;
|
|
108
|
-
created?: undefined;
|
|
109
|
-
package?: undefined;
|
|
110
|
-
updated?: undefined;
|
|
111
|
-
instructions?: undefined;
|
|
112
|
-
projectPath?: undefined;
|
|
113
|
-
} | {
|
|
114
|
-
success: boolean;
|
|
115
|
-
message: string;
|
|
116
|
-
path: string;
|
|
117
|
-
name?: undefined;
|
|
118
|
-
version?: undefined;
|
|
119
|
-
dependencies?: undefined;
|
|
120
|
-
devDependencies?: undefined;
|
|
121
|
-
scripts?: undefined;
|
|
122
|
-
note?: undefined;
|
|
123
|
-
created?: undefined;
|
|
124
|
-
package?: undefined;
|
|
125
|
-
updated?: undefined;
|
|
126
|
-
deleted?: undefined;
|
|
127
|
-
instructions?: undefined;
|
|
128
|
-
projectPath?: undefined;
|
|
129
|
-
} | {
|
|
130
|
-
success: boolean;
|
|
131
|
-
message: string;
|
|
132
|
-
instructions: {
|
|
133
|
-
command: string;
|
|
134
|
-
registry: any;
|
|
135
|
-
access: any;
|
|
136
|
-
tag: any;
|
|
137
|
-
note: string;
|
|
138
|
-
package?: undefined;
|
|
139
|
-
version?: undefined;
|
|
140
|
-
destination?: undefined;
|
|
141
|
-
};
|
|
142
|
-
projectPath: any;
|
|
143
|
-
name?: undefined;
|
|
144
|
-
version?: undefined;
|
|
145
|
-
dependencies?: undefined;
|
|
146
|
-
devDependencies?: undefined;
|
|
147
|
-
scripts?: undefined;
|
|
148
|
-
note?: undefined;
|
|
149
|
-
created?: undefined;
|
|
150
|
-
path?: undefined;
|
|
151
|
-
package?: undefined;
|
|
152
|
-
updated?: undefined;
|
|
153
|
-
deleted?: undefined;
|
|
154
|
-
} | {
|
|
155
|
-
success: boolean;
|
|
156
|
-
message: string;
|
|
157
|
-
instructions: {
|
|
158
|
-
command: string;
|
|
159
|
-
package: any;
|
|
160
|
-
version: any;
|
|
161
|
-
destination: any;
|
|
162
|
-
note: string;
|
|
163
|
-
registry?: undefined;
|
|
164
|
-
access?: undefined;
|
|
165
|
-
tag?: undefined;
|
|
166
|
-
};
|
|
167
|
-
name?: undefined;
|
|
168
|
-
version?: undefined;
|
|
169
|
-
dependencies?: undefined;
|
|
170
|
-
devDependencies?: undefined;
|
|
171
|
-
scripts?: undefined;
|
|
172
|
-
note?: undefined;
|
|
173
|
-
created?: undefined;
|
|
174
|
-
path?: undefined;
|
|
175
|
-
package?: undefined;
|
|
176
|
-
updated?: undefined;
|
|
177
|
-
deleted?: undefined;
|
|
178
|
-
projectPath?: undefined;
|
|
179
|
-
}>;
|
|
180
|
-
}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { MCPError } from '../utils/errors.js';
|
|
4
|
-
import { normalizeToolParams } from '../utils/repoHelpers.js';
|
|
5
|
-
export class GitPackagesTool {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.name = 'git-packages';
|
|
8
|
-
this.description = 'Package management operations - automatic dual-provider execution';
|
|
9
|
-
this.inputSchema = {
|
|
10
|
-
type: "object",
|
|
11
|
-
properties: {
|
|
12
|
-
projectPath: {
|
|
13
|
-
type: "string",
|
|
14
|
-
description: "The absolute path to the Git repository directory on the local filesystem. This should be the root directory containing the .git folder. For example: '/home/user/my-project' on Linux/Mac or 'C:\\Users\\user\\my-project' on Windows."
|
|
15
|
-
},
|
|
16
|
-
action: {
|
|
17
|
-
type: "string",
|
|
18
|
-
enum: ["list", "get", "delete", "versions"],
|
|
19
|
-
description: "Package operation to perform: list (list packages), get (get package details), delete (delete package), versions (list package versions)"
|
|
20
|
-
},
|
|
21
|
-
confirm: {
|
|
22
|
-
type: "boolean",
|
|
23
|
-
description: "Confirm destructive operations (optional for delete)"
|
|
24
|
-
},
|
|
25
|
-
packageName: {
|
|
26
|
-
type: "string",
|
|
27
|
-
description: "Package name (required for get/delete/versions)"
|
|
28
|
-
},
|
|
29
|
-
packageType: {
|
|
30
|
-
type: "string",
|
|
31
|
-
enum: ["npm", "container", "maven", "nuget", "rubygems"],
|
|
32
|
-
description: "Package type (required for operations)"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
required: ["projectPath", "action"]
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
async handle(params, ctx) {
|
|
39
|
-
params = normalizeToolParams(params);
|
|
40
|
-
const action = params.action;
|
|
41
|
-
const projectPath = params.projectPath;
|
|
42
|
-
if (!action)
|
|
43
|
-
throw new MCPError('VALIDATION_ERROR', 'action is required');
|
|
44
|
-
switch (action) {
|
|
45
|
-
case 'list': {
|
|
46
|
-
if (!projectPath)
|
|
47
|
-
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
48
|
-
// Ler package.json
|
|
49
|
-
try {
|
|
50
|
-
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
51
|
-
const content = await fs.readFile(packageJsonPath, 'utf-8');
|
|
52
|
-
const pkg = JSON.parse(content);
|
|
53
|
-
return {
|
|
54
|
-
success: true,
|
|
55
|
-
name: pkg.name,
|
|
56
|
-
version: pkg.version,
|
|
57
|
-
dependencies: pkg.dependencies || {},
|
|
58
|
-
devDependencies: pkg.devDependencies || {},
|
|
59
|
-
scripts: pkg.scripts || {},
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
throw new MCPError('FILE_ERROR', `Failed to read package.json: ${error.message}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
case 'get': {
|
|
67
|
-
const packageName = params.packageName;
|
|
68
|
-
if (!packageName)
|
|
69
|
-
throw new MCPError('VALIDATION_ERROR', 'packageName is required');
|
|
70
|
-
return {
|
|
71
|
-
success: true,
|
|
72
|
-
message: `Package info for ${packageName}`,
|
|
73
|
-
note: 'Use npm view or yarn info for detailed package information',
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
case 'create': {
|
|
77
|
-
if (!projectPath)
|
|
78
|
-
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
79
|
-
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
80
|
-
const packageData = {
|
|
81
|
-
name: params.name || path.basename(projectPath),
|
|
82
|
-
version: params.version || '1.0.0',
|
|
83
|
-
description: params.description || '',
|
|
84
|
-
main: params.main || 'index.js',
|
|
85
|
-
scripts: params.scripts || {},
|
|
86
|
-
keywords: params.keywords || [],
|
|
87
|
-
author: params.author || '',
|
|
88
|
-
license: params.license || 'MIT',
|
|
89
|
-
};
|
|
90
|
-
if (params.dependencies)
|
|
91
|
-
packageData.dependencies = params.dependencies;
|
|
92
|
-
if (params.devDependencies)
|
|
93
|
-
packageData.devDependencies = params.devDependencies;
|
|
94
|
-
try {
|
|
95
|
-
await fs.writeFile(packageJsonPath, JSON.stringify(packageData, null, 2), 'utf-8');
|
|
96
|
-
return {
|
|
97
|
-
success: true,
|
|
98
|
-
created: true,
|
|
99
|
-
path: packageJsonPath,
|
|
100
|
-
package: packageData,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
throw new MCPError('FILE_ERROR', `Failed to create package.json: ${error.message}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
case 'update': {
|
|
108
|
-
if (!projectPath)
|
|
109
|
-
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
110
|
-
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
111
|
-
try {
|
|
112
|
-
const content = await fs.readFile(packageJsonPath, 'utf-8');
|
|
113
|
-
const pkg = JSON.parse(content);
|
|
114
|
-
// Update fields if provided
|
|
115
|
-
if (params.name)
|
|
116
|
-
pkg.name = params.name;
|
|
117
|
-
if (params.version)
|
|
118
|
-
pkg.version = params.version;
|
|
119
|
-
if (params.description)
|
|
120
|
-
pkg.description = params.description;
|
|
121
|
-
if (params.main)
|
|
122
|
-
pkg.main = params.main;
|
|
123
|
-
if (params.scripts)
|
|
124
|
-
pkg.scripts = { ...pkg.scripts, ...params.scripts };
|
|
125
|
-
if (params.keywords)
|
|
126
|
-
pkg.keywords = params.keywords;
|
|
127
|
-
if (params.author)
|
|
128
|
-
pkg.author = params.author;
|
|
129
|
-
if (params.license)
|
|
130
|
-
pkg.license = params.license;
|
|
131
|
-
if (params.dependencies)
|
|
132
|
-
pkg.dependencies = { ...pkg.dependencies, ...params.dependencies };
|
|
133
|
-
if (params.devDependencies)
|
|
134
|
-
pkg.devDependencies = { ...pkg.devDependencies, ...params.devDependencies };
|
|
135
|
-
await fs.writeFile(packageJsonPath, JSON.stringify(pkg, null, 2), 'utf-8');
|
|
136
|
-
return {
|
|
137
|
-
success: true,
|
|
138
|
-
updated: true,
|
|
139
|
-
path: packageJsonPath,
|
|
140
|
-
package: pkg,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
catch (error) {
|
|
144
|
-
throw new MCPError('FILE_ERROR', `Failed to update package.json: ${error.message}`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
case 'delete': {
|
|
148
|
-
if (!projectPath)
|
|
149
|
-
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
150
|
-
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
151
|
-
try {
|
|
152
|
-
await fs.unlink(packageJsonPath);
|
|
153
|
-
return {
|
|
154
|
-
success: true,
|
|
155
|
-
deleted: true,
|
|
156
|
-
path: packageJsonPath,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
if (error.code === 'ENOENT') {
|
|
161
|
-
return {
|
|
162
|
-
success: false,
|
|
163
|
-
message: 'package.json not found',
|
|
164
|
-
path: packageJsonPath,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
throw new MCPError('FILE_ERROR', `Failed to delete package.json: ${error.message}`);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
case 'publish': {
|
|
171
|
-
if (!projectPath)
|
|
172
|
-
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
173
|
-
const registry = params.registry || 'https://registry.npmjs.org';
|
|
174
|
-
const access = params.access || 'public'; // public or restricted
|
|
175
|
-
const tag = params.tag || 'latest';
|
|
176
|
-
const dryRun = params.dryRun || false;
|
|
177
|
-
return {
|
|
178
|
-
success: true,
|
|
179
|
-
message: 'To publish, run: npm publish in your terminal',
|
|
180
|
-
instructions: {
|
|
181
|
-
command: dryRun ? 'npm publish --dry-run' : 'npm publish',
|
|
182
|
-
registry,
|
|
183
|
-
access,
|
|
184
|
-
tag,
|
|
185
|
-
note: 'Make sure you are logged in with: npm login',
|
|
186
|
-
},
|
|
187
|
-
projectPath,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
case 'download': {
|
|
191
|
-
const packageName = params.packageName;
|
|
192
|
-
const version = params.version || 'latest';
|
|
193
|
-
const destination = params.destination || projectPath;
|
|
194
|
-
if (!packageName)
|
|
195
|
-
throw new MCPError('VALIDATION_ERROR', 'packageName is required');
|
|
196
|
-
if (!destination)
|
|
197
|
-
throw new MCPError('VALIDATION_ERROR', 'destination is required');
|
|
198
|
-
return {
|
|
199
|
-
success: true,
|
|
200
|
-
message: `To download ${packageName}@${version}, run: npm install ${packageName}@${version} in your terminal`,
|
|
201
|
-
instructions: {
|
|
202
|
-
command: `npm install ${packageName}@${version}`,
|
|
203
|
-
package: packageName,
|
|
204
|
-
version,
|
|
205
|
-
destination,
|
|
206
|
-
note: 'Run this command in your project directory',
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
default:
|
|
211
|
-
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|