@andrebuzeli/git-mcp 5.8.0 → 5.8.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/index.js +154 -49
- 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,135 @@ 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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
+
try {
|
|
120
|
+
const request = JSON.parse(line);
|
|
121
|
+
const { jsonrpc, id, method, params } = request;
|
|
122
|
+
let response = { jsonrpc: '2.0', id };
|
|
123
|
+
switch (method) {
|
|
124
|
+
case 'initialize':
|
|
125
|
+
response.result = {
|
|
126
|
+
protocolVersion: '2024-11-05',
|
|
127
|
+
capabilities: {
|
|
128
|
+
tools: {},
|
|
129
|
+
resources: {}
|
|
130
|
+
},
|
|
131
|
+
serverInfo: {
|
|
132
|
+
name: 'git-mcp',
|
|
133
|
+
version: '5.8.0'
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
break;
|
|
137
|
+
case 'tools/list':
|
|
138
|
+
response.result = {
|
|
139
|
+
tools: tools.map(t => ({
|
|
140
|
+
name: t.name,
|
|
141
|
+
description: t.description,
|
|
142
|
+
inputSchema: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: {},
|
|
145
|
+
required: []
|
|
146
|
+
}
|
|
147
|
+
}))
|
|
148
|
+
};
|
|
149
|
+
break;
|
|
150
|
+
case 'tools/call':
|
|
151
|
+
const toolName = params?.name;
|
|
152
|
+
const tool = toolRegistry.get(toolName);
|
|
153
|
+
if (!tool) {
|
|
154
|
+
response.error = {
|
|
155
|
+
code: -32601,
|
|
156
|
+
message: `Tool not found: ${toolName}`
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
try {
|
|
161
|
+
const result = await tool.handle(params?.arguments ?? {}, { providerManager });
|
|
162
|
+
response.result = {
|
|
163
|
+
content: [
|
|
164
|
+
{
|
|
165
|
+
type: 'text',
|
|
166
|
+
text: JSON.stringify(result, null, 2)
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
response.error = {
|
|
173
|
+
code: -32603,
|
|
174
|
+
message: err.message || String(err)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
case 'resources/list':
|
|
180
|
+
response.result = {
|
|
181
|
+
resources: Array.from(resourceRegistry.values()).map(r => ({
|
|
182
|
+
uri: r.uri,
|
|
183
|
+
name: r.name,
|
|
184
|
+
description: r.description,
|
|
185
|
+
mimeType: r.mimeType
|
|
186
|
+
}))
|
|
187
|
+
};
|
|
188
|
+
break;
|
|
189
|
+
case 'resources/read':
|
|
190
|
+
const uri = params?.uri;
|
|
191
|
+
const resource = resourceRegistry.get(uri);
|
|
192
|
+
if (!resource) {
|
|
193
|
+
response.error = {
|
|
194
|
+
code: -32601,
|
|
195
|
+
message: `Resource not found: ${uri}`
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
response.result = {
|
|
200
|
+
contents: [
|
|
201
|
+
{
|
|
202
|
+
uri: resource.uri,
|
|
203
|
+
mimeType: resource.mimeType,
|
|
204
|
+
text: resource.content
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
default:
|
|
211
|
+
response.error = {
|
|
212
|
+
code: -32601,
|
|
213
|
+
message: `Method not found: ${method}`
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
console.log(JSON.stringify(response));
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
if (process.env.DEBUG) {
|
|
220
|
+
console.error('Error processing request:', err);
|
|
221
|
+
}
|
|
108
222
|
}
|
|
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
223
|
});
|
|
118
224
|
// Keep process alive
|
|
119
225
|
process.on('SIGINT', () => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
});
|
|
226
|
+
if (process.env.DEBUG) {
|
|
227
|
+
console.error('\n👋 Shutting down server...');
|
|
228
|
+
}
|
|
229
|
+
process.exit(0);
|
|
125
230
|
});
|
|
126
231
|
}
|
|
127
232
|
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.1",
|
|
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",
|