@andrebuzeli/git-mcp 7.2.5 → 7.3.1
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/dist/config.js +6 -12
- package/dist/index.js +60 -65
- package/dist/providers/giteaProvider.js +3 -9
- package/dist/providers/githubProvider.js +3 -6
- package/dist/providers/providerManager.js +5 -12
- package/dist/resources/toolsGuide.js +2 -5
- package/dist/server.js +11 -17
- package/dist/tools/gitAnalytics.js +14 -21
- package/dist/tools/gitArchive.js +16 -23
- package/dist/tools/gitBackup.js +21 -28
- package/dist/tools/gitBranches.js +20 -27
- package/dist/tools/gitConfig.js +12 -19
- package/dist/tools/gitFiles.js +14 -21
- package/dist/tools/gitFix.js +12 -18
- package/dist/tools/gitFix.tool.js +3 -7
- package/dist/tools/gitHistory.js +18 -58
- package/dist/tools/gitIgnore.js +9 -46
- package/dist/tools/gitIssues.js +20 -24
- package/dist/tools/gitMonitor.js +14 -21
- package/dist/tools/gitPackages.js +12 -19
- package/dist/tools/gitPulls.js +18 -25
- package/dist/tools/gitRelease.js +24 -31
- package/dist/tools/gitRemote.js +19 -26
- package/dist/tools/gitReset.js +10 -17
- package/dist/tools/gitStash.js +6 -13
- package/dist/tools/gitSync.js +6 -13
- package/dist/tools/gitTags.js +18 -25
- package/dist/tools/gitUpdate.js +19 -59
- package/dist/tools/gitUpload.js +13 -53
- package/dist/tools/gitWorkflow.js +25 -32
- package/dist/types.js +1 -2
- package/dist/utils/errors.js +2 -7
- package/dist/utils/repoHelpers.js +9 -21
- package/dist/utils/safetyController.js +3 -6
- package/package.json +2 -1
package/dist/config.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.loadMCPConfig = loadMCPConfig;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
9
3
|
function maskSecret(value) {
|
|
10
4
|
if (!value)
|
|
11
5
|
return 'undefined';
|
|
@@ -13,12 +7,12 @@ function maskSecret(value) {
|
|
|
13
7
|
return '****';
|
|
14
8
|
return `${value.slice(0, 4)}...${value.slice(-4)}`;
|
|
15
9
|
}
|
|
16
|
-
function loadMCPConfig(configPath) {
|
|
17
|
-
const cfgPath =
|
|
18
|
-
if (!
|
|
10
|
+
export function loadMCPConfig(configPath) {
|
|
11
|
+
const cfgPath = path.resolve(process.cwd(), configPath ?? 'mcp.json');
|
|
12
|
+
if (!fs.existsSync(cfgPath))
|
|
19
13
|
return null;
|
|
20
14
|
try {
|
|
21
|
-
const raw =
|
|
15
|
+
const raw = fs.readFileSync(cfgPath, 'utf8');
|
|
22
16
|
const cfg = JSON.parse(raw);
|
|
23
17
|
if (cfg.env) {
|
|
24
18
|
for (const [k, v] of Object.entries(cfg.env)) {
|
package/dist/index.js
CHANGED
|
@@ -1,71 +1,66 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const gitUpdate_1 = require("./tools/gitUpdate");
|
|
31
|
-
const gitHistory_1 = require("./tools/gitHistory");
|
|
32
|
-
const gitFix_tool_1 = require("./tools/gitFix.tool");
|
|
33
|
-
const gitIgnore_1 = require("./tools/gitIgnore");
|
|
34
|
-
const toolsGuide_1 = __importDefault(require("./resources/toolsGuide"));
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { ProviderManager } from './providers/providerManager.js';
|
|
6
|
+
import { loadMCPConfig } from './config.js';
|
|
7
|
+
import { GitFilesTool } from './tools/gitFiles.js';
|
|
8
|
+
import { GitWorkflowTool } from './tools/gitWorkflow.js';
|
|
9
|
+
import { GitBranchesTool } from './tools/gitBranches.js';
|
|
10
|
+
import { GitIssuesTool } from './tools/gitIssues.js';
|
|
11
|
+
import { GitPullsTool } from './tools/gitPulls.js';
|
|
12
|
+
import { GitTagsTool } from './tools/gitTags.js';
|
|
13
|
+
import { GitReleaseTool } from './tools/gitRelease.js';
|
|
14
|
+
import { GitRemoteTool } from './tools/gitRemote.js';
|
|
15
|
+
import { GitResetTool } from './tools/gitReset.js';
|
|
16
|
+
import { GitStashTool } from './tools/gitStash.js';
|
|
17
|
+
import { GitConfigTool } from './tools/gitConfig.js';
|
|
18
|
+
import { GitMonitorTool } from './tools/gitMonitor.js';
|
|
19
|
+
import { GitBackupTool } from './tools/gitBackup.js';
|
|
20
|
+
import { GitArchiveTool } from './tools/gitArchive.js';
|
|
21
|
+
import { GitSyncTool } from './tools/gitSync.js';
|
|
22
|
+
import { GitPackagesTool } from './tools/gitPackages.js';
|
|
23
|
+
import { GitAnalyticsTool } from './tools/gitAnalytics.js';
|
|
24
|
+
import { GitUploadTool } from './tools/gitUpload.js';
|
|
25
|
+
import { GitUpdateTool } from './tools/gitUpdate.js';
|
|
26
|
+
import { GitHistoryTool } from './tools/gitHistory.js';
|
|
27
|
+
import { GitFixTool } from './tools/gitFix.tool.js';
|
|
28
|
+
import { GitIgnoreTool } from './tools/gitIgnore.js';
|
|
29
|
+
import TOOLS_GUIDE from './resources/toolsGuide.js';
|
|
35
30
|
async function main() {
|
|
36
31
|
// Load optional mcp.json configuration (will populate process.env if values present)
|
|
37
|
-
|
|
38
|
-
const providerManager = new
|
|
32
|
+
loadMCPConfig();
|
|
33
|
+
const providerManager = new ProviderManager();
|
|
39
34
|
// Skip validation on startup to prevent hanging (validation happens on first use)
|
|
40
35
|
// Provider validation moved to lazy initialization
|
|
41
36
|
// Register all 22 Git tools
|
|
42
37
|
const tools = [
|
|
43
|
-
new
|
|
44
|
-
new
|
|
45
|
-
new
|
|
46
|
-
new
|
|
47
|
-
new
|
|
48
|
-
new
|
|
49
|
-
new
|
|
50
|
-
new
|
|
51
|
-
new
|
|
52
|
-
new
|
|
53
|
-
new
|
|
54
|
-
new
|
|
55
|
-
new
|
|
56
|
-
new
|
|
57
|
-
new
|
|
58
|
-
new
|
|
59
|
-
new
|
|
60
|
-
new
|
|
61
|
-
new
|
|
62
|
-
new
|
|
63
|
-
new
|
|
64
|
-
new
|
|
38
|
+
new GitWorkflowTool(),
|
|
39
|
+
new GitFilesTool(),
|
|
40
|
+
new GitBranchesTool(),
|
|
41
|
+
new GitIssuesTool(),
|
|
42
|
+
new GitPullsTool(),
|
|
43
|
+
new GitTagsTool(),
|
|
44
|
+
new GitReleaseTool(),
|
|
45
|
+
new GitRemoteTool(),
|
|
46
|
+
new GitResetTool(),
|
|
47
|
+
new GitStashTool(),
|
|
48
|
+
new GitConfigTool(),
|
|
49
|
+
new GitMonitorTool(),
|
|
50
|
+
new GitBackupTool(),
|
|
51
|
+
new GitArchiveTool(),
|
|
52
|
+
new GitSyncTool(),
|
|
53
|
+
new GitPackagesTool(),
|
|
54
|
+
new GitAnalyticsTool(),
|
|
55
|
+
new GitUploadTool(),
|
|
56
|
+
new GitUpdateTool(),
|
|
57
|
+
new GitHistoryTool(),
|
|
58
|
+
new GitFixTool(),
|
|
59
|
+
new GitIgnoreTool(),
|
|
65
60
|
];
|
|
66
61
|
// Register resources
|
|
67
62
|
const resources = [
|
|
68
|
-
|
|
63
|
+
TOOLS_GUIDE
|
|
69
64
|
];
|
|
70
65
|
// Silent mode for MCP clients - only log to stderr in debug mode
|
|
71
66
|
if (process.env.DEBUG) {
|
|
@@ -73,12 +68,12 @@ async function main() {
|
|
|
73
68
|
console.error(`Registered ${resources.length} resource(s)`);
|
|
74
69
|
}
|
|
75
70
|
// Create MCP Server with STDIO transport
|
|
76
|
-
const server = new
|
|
71
|
+
const server = new Server({
|
|
77
72
|
name: '@andrebuzeli/git-mcp',
|
|
78
|
-
version: '7.
|
|
73
|
+
version: '7.3.1',
|
|
79
74
|
});
|
|
80
75
|
// Register tool list handler
|
|
81
|
-
server.setRequestHandler(
|
|
76
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
82
77
|
return {
|
|
83
78
|
tools: tools.map(tool => ({
|
|
84
79
|
name: tool.name,
|
|
@@ -92,7 +87,7 @@ async function main() {
|
|
|
92
87
|
};
|
|
93
88
|
});
|
|
94
89
|
// Register tool execution handler
|
|
95
|
-
server.setRequestHandler(
|
|
90
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
96
91
|
const toolName = request.params.name;
|
|
97
92
|
const tool = tools.find(t => t.name === toolName);
|
|
98
93
|
if (!tool) {
|
|
@@ -122,7 +117,7 @@ async function main() {
|
|
|
122
117
|
}
|
|
123
118
|
});
|
|
124
119
|
// Register resource list handler
|
|
125
|
-
server.setRequestHandler(
|
|
120
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
126
121
|
return {
|
|
127
122
|
resources: resources.map(resource => ({
|
|
128
123
|
uri: resource.uri,
|
|
@@ -133,7 +128,7 @@ async function main() {
|
|
|
133
128
|
};
|
|
134
129
|
});
|
|
135
130
|
// Register resource read handler
|
|
136
|
-
server.setRequestHandler(
|
|
131
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
137
132
|
const uri = request.params.uri;
|
|
138
133
|
const resource = resources.find(r => r.uri === uri);
|
|
139
134
|
if (!resource) {
|
|
@@ -150,7 +145,7 @@ async function main() {
|
|
|
150
145
|
};
|
|
151
146
|
});
|
|
152
147
|
// Start server with STDIO transport
|
|
153
|
-
const transport = new
|
|
148
|
+
const transport = new StdioServerTransport();
|
|
154
149
|
await server.connect(transport);
|
|
155
150
|
// Only log in debug mode
|
|
156
151
|
if (process.env.DEBUG) {
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createGiteaClient = createGiteaClient;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
function createGiteaClient(baseUrl, token) {
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
export function createGiteaClient(baseUrl, token) {
|
|
9
3
|
return {
|
|
10
|
-
request: (path, opts = {}) =>
|
|
4
|
+
request: (path, opts = {}) => axios.request({ url: `${baseUrl}${path}`, headers: { Authorization: `token ${token}` }, ...opts }),
|
|
11
5
|
};
|
|
12
6
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const rest_1 = require("@octokit/rest");
|
|
5
|
-
function createGitHubClient(token) {
|
|
6
|
-
return new rest_1.Octokit({ auth: token });
|
|
1
|
+
import { Octokit } from '@octokit/rest';
|
|
2
|
+
export function createGitHubClient(token) {
|
|
3
|
+
return new Octokit({ auth: token });
|
|
7
4
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ProviderManager = void 0;
|
|
7
|
-
const rest_1 = require("@octokit/rest");
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
class ProviderManager {
|
|
1
|
+
import { Octokit } from '@octokit/rest';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
export class ProviderManager {
|
|
10
4
|
constructor() {
|
|
11
5
|
const ghToken = process.env.GITHUB_TOKEN;
|
|
12
6
|
if (ghToken) {
|
|
13
|
-
this.github = new
|
|
7
|
+
this.github = new Octokit({ auth: ghToken });
|
|
14
8
|
}
|
|
15
9
|
if (process.env.GITEA_URL && process.env.GITEA_TOKEN) {
|
|
16
10
|
this.giteaBaseUrl = process.env.GITEA_URL;
|
|
@@ -37,7 +31,7 @@ class ProviderManager {
|
|
|
37
31
|
}
|
|
38
32
|
if (this.giteaBaseUrl && this.giteaToken) {
|
|
39
33
|
try {
|
|
40
|
-
const resp = await
|
|
34
|
+
const resp = await axios.get(`${this.giteaBaseUrl}/api/v1/user`, {
|
|
41
35
|
headers: { Authorization: `token ${this.giteaToken}` },
|
|
42
36
|
timeout: timeout,
|
|
43
37
|
});
|
|
@@ -53,4 +47,3 @@ class ProviderManager {
|
|
|
53
47
|
return results;
|
|
54
48
|
}
|
|
55
49
|
}
|
|
56
|
-
exports.ProviderManager = ProviderManager;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Git-MCP Tools Guide Resource
|
|
4
3
|
* Comprehensive documentation for all 20 Git tools available in the MCP server
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
exports.TOOLS_GUIDE = void 0;
|
|
8
|
-
exports.TOOLS_GUIDE = {
|
|
5
|
+
export const TOOLS_GUIDE = {
|
|
9
6
|
uri: "git-mcp://tools/guide",
|
|
10
7
|
name: "Git-MCP Tools Complete Guide",
|
|
11
8
|
description: "Detailed documentation and usage instructions for all 20 Git tools with 102 actions",
|
|
@@ -1713,4 +1710,4 @@ for (const repo of repos) {
|
|
|
1713
1710
|
**Git-MCP v6.3.1** | Built with ❤️ for developers | 110+ Actions | 21 Tools | 3 Provider Types | NEW: git-fix migration tool
|
|
1714
1711
|
`
|
|
1715
1712
|
};
|
|
1716
|
-
|
|
1713
|
+
export default TOOLS_GUIDE;
|
package/dist/server.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const express_1 = __importDefault(require("express"));
|
|
8
|
-
const body_parser_1 = __importDefault(require("body-parser"));
|
|
9
|
-
const errors_1 = require("./utils/errors");
|
|
10
|
-
function createServer(opts) {
|
|
11
|
-
const app = (0, express_1.default)();
|
|
12
|
-
app.use(body_parser_1.default.json({ limit: '1mb' }));
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import bodyParser from 'body-parser';
|
|
3
|
+
import { createErrorResponse } from './utils/errors';
|
|
4
|
+
export function createServer(opts) {
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.json({ limit: '1mb' }));
|
|
13
7
|
const toolRegistry = new Map();
|
|
14
8
|
for (const t of opts.tools)
|
|
15
9
|
toolRegistry.set(t.name, t);
|
|
@@ -33,7 +27,7 @@ function createServer(opts) {
|
|
|
33
27
|
const uri = req.params.uri;
|
|
34
28
|
const resource = resourceRegistry.get(uri);
|
|
35
29
|
if (!resource) {
|
|
36
|
-
return res.status(404).json(
|
|
30
|
+
return res.status(404).json(createErrorResponse('RESOURCE_NOT_FOUND', `Resource not found: ${uri}`));
|
|
37
31
|
}
|
|
38
32
|
res.json({
|
|
39
33
|
success: true,
|
|
@@ -49,14 +43,14 @@ function createServer(opts) {
|
|
|
49
43
|
app.post('/call', async (req, res) => {
|
|
50
44
|
const { tool, params } = req.body ?? {};
|
|
51
45
|
if (!tool)
|
|
52
|
-
return res.status(400).json(
|
|
46
|
+
return res.status(400).json(createErrorResponse('VALIDATION_ERROR', 'Missing tool name'));
|
|
53
47
|
const t = toolRegistry.get(tool);
|
|
54
48
|
if (!t)
|
|
55
|
-
return res.status(404).json(
|
|
49
|
+
return res.status(404).json(createErrorResponse('TOOL_NOT_FOUND', `Tool not found: ${tool}`));
|
|
56
50
|
// Enforce projectPath presence for all tool calls to avoid agents calling tools without context
|
|
57
51
|
// Many tools require projectPath; centralize the check so callers receive a clear validation error.
|
|
58
52
|
if (!params || !params.projectPath) {
|
|
59
|
-
return res.status(400).json(
|
|
53
|
+
return res.status(400).json(createErrorResponse('VALIDATION_ERROR', 'projectPath is required for all tool calls'));
|
|
60
54
|
}
|
|
61
55
|
try {
|
|
62
56
|
// TODO: validate params via JSON Schema
|
|
@@ -67,7 +61,7 @@ function createServer(opts) {
|
|
|
67
61
|
console.error(`Error in tool ${tool}:`, err);
|
|
68
62
|
const errorCode = err.status || err.code || 'INTERNAL_ERROR';
|
|
69
63
|
const errorMsg = err.message || String(err);
|
|
70
|
-
res.status(500).json(
|
|
64
|
+
res.status(500).json(createErrorResponse(errorCode, errorMsg));
|
|
71
65
|
}
|
|
72
66
|
});
|
|
73
67
|
return app;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GitAnalyticsTool = void 0;
|
|
7
|
-
const errors_1 = require("../utils/errors");
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const repoHelpers_1 = require("../utils/repoHelpers");
|
|
10
|
-
class GitAnalyticsTool {
|
|
1
|
+
import { MCPError } from '../utils/errors';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { getRepoInfo } from '../utils/repoHelpers';
|
|
4
|
+
export class GitAnalyticsTool {
|
|
11
5
|
constructor() {
|
|
12
6
|
this.name = 'git-analytics';
|
|
13
7
|
this.description = 'Repository analytics and statistics - automatic dual-provider execution using GitHub and Gitea APIs';
|
|
@@ -16,11 +10,11 @@ class GitAnalyticsTool {
|
|
|
16
10
|
const action = params.action;
|
|
17
11
|
const projectPath = params.projectPath;
|
|
18
12
|
if (!action)
|
|
19
|
-
throw new
|
|
13
|
+
throw new MCPError('VALIDATION_ERROR', 'action is required');
|
|
20
14
|
if (!projectPath)
|
|
21
|
-
throw new
|
|
15
|
+
throw new MCPError('VALIDATION_ERROR', 'projectPath is required');
|
|
22
16
|
// Auto-extract repo info from projectPath
|
|
23
|
-
const repoInfo =
|
|
17
|
+
const repoInfo = getRepoInfo(projectPath);
|
|
24
18
|
const repo = repoInfo.repoName;
|
|
25
19
|
// Each provider uses its own username from env
|
|
26
20
|
const githubOwner = process.env.GITHUB_USERNAME;
|
|
@@ -71,10 +65,10 @@ class GitAnalyticsTool {
|
|
|
71
65
|
// Gitea API
|
|
72
66
|
if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
|
|
73
67
|
try {
|
|
74
|
-
const repoData = await
|
|
75
|
-
const branches = await
|
|
76
|
-
const tags = await
|
|
77
|
-
const commits = await
|
|
68
|
+
const repoData = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
|
|
69
|
+
const branches = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/branches`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
|
|
70
|
+
const tags = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/tags`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
|
|
71
|
+
const commits = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/commits`, {
|
|
78
72
|
params: { limit: 1 },
|
|
79
73
|
headers: { Authorization: `token ${ctx.providerManager.giteaToken}` }
|
|
80
74
|
});
|
|
@@ -125,7 +119,7 @@ class GitAnalyticsTool {
|
|
|
125
119
|
// Gitea API
|
|
126
120
|
if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
|
|
127
121
|
try {
|
|
128
|
-
const commits = await
|
|
122
|
+
const commits = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/commits`, {
|
|
129
123
|
params: {
|
|
130
124
|
since: params.since,
|
|
131
125
|
until: params.until,
|
|
@@ -172,7 +166,7 @@ class GitAnalyticsTool {
|
|
|
172
166
|
// Gitea API
|
|
173
167
|
if (ctx.providerManager.giteaBaseUrl && giteaOwner) {
|
|
174
168
|
try {
|
|
175
|
-
const contributors = await
|
|
169
|
+
const contributors = await axios.get(`${ctx.providerManager.giteaBaseUrl}/api/v1/repos/${giteaOwner}/${repo}/contributors`, { headers: { Authorization: `token ${ctx.providerManager.giteaToken}` } });
|
|
176
170
|
results.providers.gitea = {
|
|
177
171
|
success: true,
|
|
178
172
|
contributors: contributors.data.map((c) => ({
|
|
@@ -190,8 +184,7 @@ class GitAnalyticsTool {
|
|
|
190
184
|
return results;
|
|
191
185
|
}
|
|
192
186
|
default:
|
|
193
|
-
throw new
|
|
187
|
+
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
194
188
|
}
|
|
195
189
|
}
|
|
196
190
|
}
|
|
197
|
-
exports.GitAnalyticsTool = GitAnalyticsTool;
|
package/dist/tools/gitArchive.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GitArchiveTool = 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 GitArchiveTool {
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { MCPError } from '../utils/errors';
|
|
4
|
+
export class GitArchiveTool {
|
|
11
5
|
constructor() {
|
|
12
6
|
this.name = 'git-archive';
|
|
13
7
|
this.description = 'Repository archive operations';
|
|
@@ -16,22 +10,22 @@ class GitArchiveTool {
|
|
|
16
10
|
const action = params.action;
|
|
17
11
|
const projectPath = params.projectPath;
|
|
18
12
|
if (!action || !projectPath) {
|
|
19
|
-
throw new
|
|
13
|
+
throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
|
|
20
14
|
}
|
|
21
15
|
switch (action) {
|
|
22
16
|
case 'create': {
|
|
23
17
|
const archiveName = params.archiveName || `archive-${Date.now()}.json`;
|
|
24
|
-
const outputPath = params.outputPath ||
|
|
18
|
+
const outputPath = params.outputPath || path.join(projectPath, '.git-archives');
|
|
25
19
|
try {
|
|
26
20
|
// Criar diretório de archives se não existir
|
|
27
|
-
await
|
|
28
|
-
const archivePath =
|
|
21
|
+
await fs.mkdir(outputPath, { recursive: true });
|
|
22
|
+
const archivePath = path.join(outputPath, archiveName);
|
|
29
23
|
const archiveData = {
|
|
30
24
|
projectPath,
|
|
31
25
|
timestamp: new Date().toISOString(),
|
|
32
26
|
type: 'git-archive',
|
|
33
27
|
};
|
|
34
|
-
await
|
|
28
|
+
await fs.writeFile(archivePath, JSON.stringify(archiveData, null, 2));
|
|
35
29
|
return {
|
|
36
30
|
success: true,
|
|
37
31
|
archivePath,
|
|
@@ -39,13 +33,13 @@ class GitArchiveTool {
|
|
|
39
33
|
};
|
|
40
34
|
}
|
|
41
35
|
catch (error) {
|
|
42
|
-
throw new
|
|
36
|
+
throw new MCPError('FILE_ERROR', `Failed to create archive: ${error.message}`);
|
|
43
37
|
}
|
|
44
38
|
}
|
|
45
39
|
case 'list': {
|
|
46
|
-
const archivesDir = params.archivesDir ||
|
|
40
|
+
const archivesDir = params.archivesDir || path.join(projectPath, '.git-archives');
|
|
47
41
|
try {
|
|
48
|
-
const files = await
|
|
42
|
+
const files = await fs.readdir(archivesDir);
|
|
49
43
|
const archives = files.filter(f => f.endsWith('.json'));
|
|
50
44
|
return {
|
|
51
45
|
success: true,
|
|
@@ -66,9 +60,9 @@ class GitArchiveTool {
|
|
|
66
60
|
case 'verify': {
|
|
67
61
|
const archivePath = params.archivePath;
|
|
68
62
|
if (!archivePath)
|
|
69
|
-
throw new
|
|
63
|
+
throw new MCPError('VALIDATION_ERROR', 'archivePath is required');
|
|
70
64
|
try {
|
|
71
|
-
const content = await
|
|
65
|
+
const content = await fs.readFile(archivePath, 'utf-8');
|
|
72
66
|
const archive = JSON.parse(content);
|
|
73
67
|
return {
|
|
74
68
|
success: true,
|
|
@@ -86,10 +80,9 @@ class GitArchiveTool {
|
|
|
86
80
|
}
|
|
87
81
|
}
|
|
88
82
|
case 'extract':
|
|
89
|
-
throw new
|
|
83
|
+
throw new MCPError('NOT_IMPLEMENTED', 'Extract not yet fully implemented');
|
|
90
84
|
default:
|
|
91
|
-
throw new
|
|
85
|
+
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
92
86
|
}
|
|
93
87
|
}
|
|
94
88
|
}
|
|
95
|
-
exports.GitArchiveTool = GitArchiveTool;
|
package/dist/tools/gitBackup.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.GitBackupTool = void 0;
|
|
7
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const simple_git_1 = __importDefault(require("simple-git"));
|
|
10
|
-
const errors_1 = require("../utils/errors");
|
|
11
|
-
class GitBackupTool {
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import simpleGit from 'simple-git';
|
|
4
|
+
import { MCPError } from '../utils/errors';
|
|
5
|
+
export class GitBackupTool {
|
|
12
6
|
constructor() {
|
|
13
7
|
this.name = 'git-backup';
|
|
14
8
|
this.description = 'Repository backup and restore operations';
|
|
@@ -17,17 +11,17 @@ class GitBackupTool {
|
|
|
17
11
|
const action = params.action;
|
|
18
12
|
const projectPath = params.projectPath;
|
|
19
13
|
if (!action || !projectPath) {
|
|
20
|
-
throw new
|
|
14
|
+
throw new MCPError('VALIDATION_ERROR', 'action and projectPath are required');
|
|
21
15
|
}
|
|
22
16
|
switch (action) {
|
|
23
17
|
case 'backup': {
|
|
24
|
-
const backupDir = params.backupDir ||
|
|
18
|
+
const backupDir = params.backupDir || path.join(projectPath, '.git-backups');
|
|
25
19
|
const backupName = params.backupName || `backup-${Date.now()}.json`;
|
|
26
20
|
try {
|
|
27
21
|
// Criar diretório de backups
|
|
28
|
-
await
|
|
29
|
-
const backupPath =
|
|
30
|
-
const git = (
|
|
22
|
+
await fs.mkdir(backupDir, { recursive: true });
|
|
23
|
+
const backupPath = path.join(backupDir, backupName);
|
|
24
|
+
const git = simpleGit({ baseDir: projectPath });
|
|
31
25
|
const status = await git.status();
|
|
32
26
|
const log = await git.log({ maxCount: 1 });
|
|
33
27
|
const backupData = {
|
|
@@ -37,7 +31,7 @@ class GitBackupTool {
|
|
|
37
31
|
lastCommit: log.latest?.hash,
|
|
38
32
|
files: status.files.length,
|
|
39
33
|
};
|
|
40
|
-
await
|
|
34
|
+
await fs.writeFile(backupPath, JSON.stringify(backupData, null, 2));
|
|
41
35
|
return {
|
|
42
36
|
success: true,
|
|
43
37
|
backupPath,
|
|
@@ -46,18 +40,18 @@ class GitBackupTool {
|
|
|
46
40
|
};
|
|
47
41
|
}
|
|
48
42
|
catch (error) {
|
|
49
|
-
throw new
|
|
43
|
+
throw new MCPError('FILE_ERROR', `Failed to create backup: ${error.message}`);
|
|
50
44
|
}
|
|
51
45
|
}
|
|
52
46
|
case 'list': {
|
|
53
|
-
const backupDir = params.backupDir ||
|
|
47
|
+
const backupDir = params.backupDir || path.join(projectPath, '.git-backups');
|
|
54
48
|
try {
|
|
55
|
-
const files = await
|
|
49
|
+
const files = await fs.readdir(backupDir);
|
|
56
50
|
const backups = [];
|
|
57
51
|
for (const file of files) {
|
|
58
52
|
if (file.endsWith('.json')) {
|
|
59
53
|
try {
|
|
60
|
-
const content = await
|
|
54
|
+
const content = await fs.readFile(path.join(backupDir, file), 'utf-8');
|
|
61
55
|
const backup = JSON.parse(content);
|
|
62
56
|
backups.push({ file, ...backup });
|
|
63
57
|
}
|
|
@@ -85,9 +79,9 @@ class GitBackupTool {
|
|
|
85
79
|
case 'verify': {
|
|
86
80
|
const backupPath = params.backupPath;
|
|
87
81
|
if (!backupPath)
|
|
88
|
-
throw new
|
|
82
|
+
throw new MCPError('VALIDATION_ERROR', 'backupPath is required');
|
|
89
83
|
try {
|
|
90
|
-
const content = await
|
|
84
|
+
const content = await fs.readFile(backupPath, 'utf-8');
|
|
91
85
|
const backup = JSON.parse(content);
|
|
92
86
|
const isValid = backup.timestamp && backup.projectPath;
|
|
93
87
|
return {
|
|
@@ -108,9 +102,9 @@ class GitBackupTool {
|
|
|
108
102
|
case 'restore': {
|
|
109
103
|
const backupPath = params.backupPath;
|
|
110
104
|
if (!backupPath)
|
|
111
|
-
throw new
|
|
105
|
+
throw new MCPError('VALIDATION_ERROR', 'backupPath is required');
|
|
112
106
|
try {
|
|
113
|
-
const content = await
|
|
107
|
+
const content = await fs.readFile(backupPath, 'utf-8');
|
|
114
108
|
const backup = JSON.parse(content);
|
|
115
109
|
return {
|
|
116
110
|
success: true,
|
|
@@ -120,12 +114,11 @@ class GitBackupTool {
|
|
|
120
114
|
};
|
|
121
115
|
}
|
|
122
116
|
catch (error) {
|
|
123
|
-
throw new
|
|
117
|
+
throw new MCPError('FILE_ERROR', `Failed to read backup: ${error.message}`);
|
|
124
118
|
}
|
|
125
119
|
}
|
|
126
120
|
default:
|
|
127
|
-
throw new
|
|
121
|
+
throw new MCPError('VALIDATION_ERROR', `Unsupported action: ${action}`);
|
|
128
122
|
}
|
|
129
123
|
}
|
|
130
124
|
}
|
|
131
|
-
exports.GitBackupTool = GitBackupTool;
|