@andrebuzeli/git-mcp 5.8.0 → 5.8.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.
- package/dist/index.js +165 -48
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
3
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
38
|
};
|
|
6
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
40
|
+
const readline = __importStar(require("readline"));
|
|
8
41
|
const providerManager_1 = require("./providers/providerManager");
|
|
9
42
|
const config_1 = require("./config");
|
|
10
43
|
const gitFiles_1 = require("./tools/gitFiles");
|
|
@@ -65,63 +98,147 @@ async function main() {
|
|
|
65
98
|
const resources = [
|
|
66
99
|
toolsGuide_1.default
|
|
67
100
|
];
|
|
101
|
+
const toolRegistry = new Map();
|
|
102
|
+
for (const t of tools)
|
|
103
|
+
toolRegistry.set(t.name, t);
|
|
104
|
+
const resourceRegistry = new Map();
|
|
105
|
+
for (const r of resources)
|
|
106
|
+
resourceRegistry.set(r.uri, r);
|
|
68
107
|
// Silent mode for MCP clients - only log to stderr in debug mode
|
|
69
108
|
if (process.env.DEBUG) {
|
|
70
109
|
console.error(`Registered ${tools.length} Git tools`);
|
|
71
110
|
console.error(`Registered ${resources.length} resource(s)`);
|
|
72
111
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
112
|
+
// MCP JSON-RPC over stdio
|
|
113
|
+
const rl = readline.createInterface({
|
|
114
|
+
input: process.stdin,
|
|
115
|
+
output: process.stdout,
|
|
116
|
+
terminal: false
|
|
117
|
+
});
|
|
118
|
+
rl.on('line', async (line) => {
|
|
119
|
+
let requestId = null;
|
|
120
|
+
try {
|
|
121
|
+
const request = JSON.parse(line);
|
|
122
|
+
const { jsonrpc, id, method, params } = request;
|
|
123
|
+
requestId = id;
|
|
124
|
+
let response = { jsonrpc: '2.0', id };
|
|
125
|
+
switch (method) {
|
|
126
|
+
case 'initialize':
|
|
127
|
+
response.result = {
|
|
128
|
+
protocolVersion: '2024-11-05',
|
|
129
|
+
capabilities: {
|
|
130
|
+
tools: {},
|
|
131
|
+
resources: {}
|
|
132
|
+
},
|
|
133
|
+
serverInfo: {
|
|
134
|
+
name: 'git-mcp',
|
|
135
|
+
version: '5.8.1'
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
break;
|
|
139
|
+
case 'tools/list':
|
|
140
|
+
response.result = {
|
|
141
|
+
tools: tools.map(t => ({
|
|
142
|
+
name: t.name,
|
|
143
|
+
description: t.description,
|
|
144
|
+
inputSchema: {
|
|
145
|
+
type: 'object',
|
|
146
|
+
properties: {},
|
|
147
|
+
required: []
|
|
148
|
+
}
|
|
149
|
+
}))
|
|
150
|
+
};
|
|
151
|
+
break;
|
|
152
|
+
case 'tools/call':
|
|
153
|
+
const toolName = params?.name;
|
|
154
|
+
const tool = toolRegistry.get(toolName);
|
|
155
|
+
if (!tool) {
|
|
156
|
+
response.error = {
|
|
157
|
+
code: -32601,
|
|
158
|
+
message: `Tool not found: ${toolName}`
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
try {
|
|
163
|
+
const result = await tool.handle(params?.arguments ?? {}, { providerManager });
|
|
164
|
+
response.result = {
|
|
165
|
+
content: [
|
|
166
|
+
{
|
|
167
|
+
type: 'text',
|
|
168
|
+
text: JSON.stringify(result, null, 2)
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
response.error = {
|
|
175
|
+
code: -32603,
|
|
176
|
+
message: err.message || String(err)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
case 'resources/list':
|
|
182
|
+
response.result = {
|
|
183
|
+
resources: Array.from(resourceRegistry.values()).map(r => ({
|
|
184
|
+
uri: r.uri,
|
|
185
|
+
name: r.name,
|
|
186
|
+
description: r.description,
|
|
187
|
+
mimeType: r.mimeType
|
|
188
|
+
}))
|
|
189
|
+
};
|
|
190
|
+
break;
|
|
191
|
+
case 'resources/read':
|
|
192
|
+
const uri = params?.uri;
|
|
193
|
+
const resource = resourceRegistry.get(uri);
|
|
194
|
+
if (!resource) {
|
|
195
|
+
response.error = {
|
|
196
|
+
code: -32601,
|
|
197
|
+
message: `Resource not found: ${uri}`
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
response.result = {
|
|
202
|
+
contents: [
|
|
203
|
+
{
|
|
204
|
+
uri: resource.uri,
|
|
205
|
+
mimeType: resource.mimeType,
|
|
206
|
+
text: resource.content
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
default:
|
|
213
|
+
response.error = {
|
|
214
|
+
code: -32601,
|
|
215
|
+
message: `Method not found: ${method}`
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
console.log(JSON.stringify(response));
|
|
219
|
+
}
|
|
220
|
+
catch (err) {
|
|
221
|
+
// Always send a proper JSON-RPC error response, even for parse errors
|
|
222
|
+
const errorResponse = {
|
|
223
|
+
jsonrpc: '2.0',
|
|
224
|
+
id: requestId,
|
|
225
|
+
error: {
|
|
226
|
+
code: -32700,
|
|
227
|
+
message: `Parse error: ${err.message || String(err)}`
|
|
95
228
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const maxAttempts = 10;
|
|
102
|
-
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
103
|
-
const tryPort = port + attempt;
|
|
104
|
-
server = await startServer(tryPort);
|
|
105
|
-
if (server) {
|
|
106
|
-
port = tryPort;
|
|
107
|
-
break;
|
|
229
|
+
};
|
|
230
|
+
console.log(JSON.stringify(errorResponse));
|
|
231
|
+
if (process.env.DEBUG) {
|
|
232
|
+
console.error('Error processing request:', err);
|
|
233
|
+
}
|
|
108
234
|
}
|
|
109
|
-
}
|
|
110
|
-
if (!server) {
|
|
111
|
-
console.error(`❌ Failed to find available port after ${maxAttempts} attempts`);
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
server.on('error', (err) => {
|
|
115
|
-
console.error('❌ Server error:', err);
|
|
116
|
-
process.exit(1);
|
|
117
235
|
});
|
|
118
236
|
// Keep process alive
|
|
119
237
|
process.on('SIGINT', () => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
});
|
|
238
|
+
if (process.env.DEBUG) {
|
|
239
|
+
console.error('\n👋 Shutting down server...');
|
|
240
|
+
}
|
|
241
|
+
process.exit(0);
|
|
125
242
|
});
|
|
126
243
|
}
|
|
127
244
|
main().catch(err => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrebuzeli/git-mcp",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.2",
|
|
4
4
|
"description": "Professional MCP server for Git operations - automatic dual-provider execution (GitHub + Gitea), no provider parameter needed, organized responses by provider, enhanced security and safety features",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|