git-push-mcp 1.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/.env.example +25 -0
- package/README.md +201 -0
- package/index.js +163 -0
- package/lib/git-operator.js +351 -0
- package/lib/mcp-handler.js +603 -0
- package/lib/nlp-processor.js +279 -0
- package/mcp-server.js +199 -0
- package/mcp.json +119 -0
- package/package.json +51 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
class NaturalLanguageProcessor {
|
|
2
|
+
constructor() {
|
|
3
|
+
// 定义命令模式映射
|
|
4
|
+
this.patterns = {
|
|
5
|
+
commit: [
|
|
6
|
+
/(提交|commit)\s+(.+)/i,
|
|
7
|
+
/把(.+)提交/i,
|
|
8
|
+
/提交代码\s*(.*)/i,
|
|
9
|
+
/push\s+(.+)/i,
|
|
10
|
+
/发布\s+(.+)/i
|
|
11
|
+
],
|
|
12
|
+
add: [
|
|
13
|
+
/(添加|add)\s+(.+)/i,
|
|
14
|
+
/把(.+)加到暂存区/i,
|
|
15
|
+
/暂存\s+(.+)/i
|
|
16
|
+
],
|
|
17
|
+
status: [
|
|
18
|
+
/(状态|status)/i,
|
|
19
|
+
/查看修改/i,
|
|
20
|
+
/有什么变化/i,
|
|
21
|
+
/检查状态/i
|
|
22
|
+
],
|
|
23
|
+
log: [
|
|
24
|
+
/(日志|log)/i,
|
|
25
|
+
/提交历史/i,
|
|
26
|
+
/查看提交记录/i,
|
|
27
|
+
/历史记录/i
|
|
28
|
+
],
|
|
29
|
+
diff: [
|
|
30
|
+
/(差异|diff)/i,
|
|
31
|
+
/查看改动/i,
|
|
32
|
+
/比较变化/i,
|
|
33
|
+
/改动详情/i
|
|
34
|
+
],
|
|
35
|
+
branch: [
|
|
36
|
+
/(分支|branch)/i,
|
|
37
|
+
/切换分支/i,
|
|
38
|
+
/新建分支/i
|
|
39
|
+
]
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// 提交类型映射(支持约定式提交)
|
|
43
|
+
this.commitTypes = {
|
|
44
|
+
feat: ['新功能', 'feature', '功能'],
|
|
45
|
+
fix: ['修复', 'bug', '修复bug'],
|
|
46
|
+
docs: ['文档', 'document', '说明'],
|
|
47
|
+
style: ['格式', '样式', 'style'],
|
|
48
|
+
refactor: ['重构', 'refactor'],
|
|
49
|
+
perf: ['性能', '优化', 'performance'],
|
|
50
|
+
test: ['测试', 'test'],
|
|
51
|
+
chore: ['杂项', '维护', 'chore']
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 解析自然语言命令
|
|
57
|
+
* @param {string} text - 用户输入的自然语言文本
|
|
58
|
+
* @returns {Object} 解析结果
|
|
59
|
+
*/
|
|
60
|
+
parseCommand(text) {
|
|
61
|
+
const trimmedText = text.trim().toLowerCase();
|
|
62
|
+
|
|
63
|
+
// 遍历所有命令模式
|
|
64
|
+
for (const [command, patterns] of Object.entries(this.patterns)) {
|
|
65
|
+
for (const pattern of patterns) {
|
|
66
|
+
const match = trimmedText.match(pattern);
|
|
67
|
+
if (match) {
|
|
68
|
+
const message = this.extractMessage(match, trimmedText);
|
|
69
|
+
const commitType = this.detectCommitType(trimmedText);
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
command,
|
|
73
|
+
message,
|
|
74
|
+
commitType,
|
|
75
|
+
originalText: text,
|
|
76
|
+
confidence: this.calculateConfidence(command, match)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 智能解析未匹配的命令
|
|
83
|
+
return this.smartParse(text);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 从正则匹配结果中提取消息
|
|
88
|
+
*/
|
|
89
|
+
extractMessage(match, originalText) {
|
|
90
|
+
// 如果有捕获组,使用第一个非空的捕获组
|
|
91
|
+
if (match.length > 1) {
|
|
92
|
+
for (let i = 1; i < match.length; i++) {
|
|
93
|
+
if (match[i] && match[i].trim()) {
|
|
94
|
+
return match[i].trim();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 否则从原文本中提取有意义的内容
|
|
100
|
+
return this.extractMeaningfulContent(originalText);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 提取有意义的内容
|
|
105
|
+
*/
|
|
106
|
+
extractMeaningfulContent(text) {
|
|
107
|
+
// 移除常见的命令词
|
|
108
|
+
const cleaned = text
|
|
109
|
+
.replace(/(提交|commit|添加|add|推送|push|发布)/gi, '')
|
|
110
|
+
.replace(/\s+/g, ' ')
|
|
111
|
+
.trim();
|
|
112
|
+
|
|
113
|
+
return cleaned || this.generateDefaultMessage();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 检测提交类型
|
|
118
|
+
*/
|
|
119
|
+
detectCommitType(text) {
|
|
120
|
+
const lowerText = text.toLowerCase();
|
|
121
|
+
|
|
122
|
+
for (const [type, keywords] of Object.entries(this.commitTypes)) {
|
|
123
|
+
if (keywords.some(keyword => lowerText.includes(keyword))) {
|
|
124
|
+
return type;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 默认为普通提交
|
|
129
|
+
return 'feat';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 计算解析置信度
|
|
134
|
+
*/
|
|
135
|
+
calculateConfidence(command, match) {
|
|
136
|
+
// 基础置信度
|
|
137
|
+
let confidence = 0.8;
|
|
138
|
+
|
|
139
|
+
// 根据匹配的具体情况调整
|
|
140
|
+
if (match[0] && match[0].length > 10) {
|
|
141
|
+
confidence += 0.1; // 匹配内容较长,更可信
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 特定命令的置信度调整
|
|
145
|
+
const confidenceAdjustments = {
|
|
146
|
+
commit: 0.05,
|
|
147
|
+
status: -0.1, // 状态查询相对简单,降低一点置信度
|
|
148
|
+
log: -0.05
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
confidence += confidenceAdjustments[command] || 0;
|
|
152
|
+
|
|
153
|
+
return Math.min(1, Math.max(0, confidence));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 智能解析未匹配的命令
|
|
158
|
+
*/
|
|
159
|
+
smartParse(text) {
|
|
160
|
+
const lowerText = text.toLowerCase();
|
|
161
|
+
|
|
162
|
+
// 检查是否包含提交相关关键词
|
|
163
|
+
const commitKeywords = ['提交', 'commit', '推送', 'push', '发布'];
|
|
164
|
+
const hasCommitKeyword = commitKeywords.some(keyword => lowerText.includes(keyword));
|
|
165
|
+
|
|
166
|
+
if (hasCommitKeyword) {
|
|
167
|
+
const message = this.extractMeaningfulContent(text);
|
|
168
|
+
const commitType = this.detectCommitType(text);
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
command: 'commit',
|
|
172
|
+
message,
|
|
173
|
+
commitType,
|
|
174
|
+
originalText: text,
|
|
175
|
+
confidence: 0.7
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// 检查是否是询问状态
|
|
180
|
+
const statusKeywords = ['状态', 'status', '变化', '修改', '检查'];
|
|
181
|
+
const hasStatusKeyword = statusKeywords.some(keyword => lowerText.includes(keyword));
|
|
182
|
+
|
|
183
|
+
if (hasStatusKeyword) {
|
|
184
|
+
return {
|
|
185
|
+
command: 'status',
|
|
186
|
+
message: '',
|
|
187
|
+
commitType: null,
|
|
188
|
+
originalText: text,
|
|
189
|
+
confidence: 0.6
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// 默认返回状态查询
|
|
194
|
+
return {
|
|
195
|
+
command: 'status',
|
|
196
|
+
message: '',
|
|
197
|
+
commitType: null,
|
|
198
|
+
originalText: text,
|
|
199
|
+
confidence: 0.3
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* 生成默认提交消息
|
|
205
|
+
*/
|
|
206
|
+
generateDefaultMessage() {
|
|
207
|
+
const now = new Date();
|
|
208
|
+
const timeString = now.toLocaleString('zh-CN', {
|
|
209
|
+
year: 'numeric',
|
|
210
|
+
month: '2-digit',
|
|
211
|
+
day: '2-digit',
|
|
212
|
+
hour: '2-digit',
|
|
213
|
+
minute: '2-digit',
|
|
214
|
+
second: '2-digit'
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
return `Auto commit at ${timeString}`;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 格式化提交消息(支持约定式提交)
|
|
222
|
+
*/
|
|
223
|
+
formatCommitMessage(parsedResult, useConventional = true) {
|
|
224
|
+
if (!useConventional) {
|
|
225
|
+
return parsedResult.message || this.generateDefaultMessage();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const type = parsedResult.commitType || 'feat';
|
|
229
|
+
const message = parsedResult.message || this.generateDefaultMessage();
|
|
230
|
+
|
|
231
|
+
// 简单的约定式提交格式
|
|
232
|
+
return `${type}: ${message}`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 分析用户意图
|
|
237
|
+
*/
|
|
238
|
+
analyzeIntent(text) {
|
|
239
|
+
const analysis = {
|
|
240
|
+
action: null,
|
|
241
|
+
target: null,
|
|
242
|
+
modifiers: [],
|
|
243
|
+
confidence: 0
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const lowerText = text.toLowerCase();
|
|
247
|
+
|
|
248
|
+
// 识别动作
|
|
249
|
+
if (lowerText.includes('提交') || lowerText.includes('commit')) {
|
|
250
|
+
analysis.action = 'commit';
|
|
251
|
+
} else if (lowerText.includes('添加') || lowerText.includes('add')) {
|
|
252
|
+
analysis.action = 'add';
|
|
253
|
+
} else if (lowerText.includes('查看') || lowerText.includes('check')) {
|
|
254
|
+
analysis.action = 'view';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// 识别目标
|
|
258
|
+
if (lowerText.includes('所有') || lowerText.includes('全部')) {
|
|
259
|
+
analysis.target = 'all';
|
|
260
|
+
} else if (lowerText.includes('文件')) {
|
|
261
|
+
analysis.target = 'files';
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// 识别修饰符
|
|
265
|
+
if (lowerText.includes('自动')) {
|
|
266
|
+
analysis.modifiers.push('auto');
|
|
267
|
+
}
|
|
268
|
+
if (lowerText.includes('强制')) {
|
|
269
|
+
analysis.modifiers.push('force');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// 计算置信度
|
|
273
|
+
analysis.confidence = 0.5 + (analysis.action ? 0.3 : 0) + (analysis.target ? 0.2 : 0);
|
|
274
|
+
|
|
275
|
+
return analysis;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
module.exports = { NaturalLanguageProcessor };
|
package/mcp-server.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
|
|
4
|
+
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
5
|
+
const {
|
|
6
|
+
CallToolRequestSchema,
|
|
7
|
+
ListToolsRequestSchema,
|
|
8
|
+
GetPromptRequestSchema,
|
|
9
|
+
ListPromptsRequestSchema,
|
|
10
|
+
ListResourcesRequestSchema,
|
|
11
|
+
ReadResourceRequestSchema
|
|
12
|
+
} = require('@modelcontextprotocol/sdk/types.js');
|
|
13
|
+
|
|
14
|
+
const { MCPHandler } = require('./lib/mcp-handler');
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
// 创建MCP处理器实例
|
|
18
|
+
const handler = new MCPHandler();
|
|
19
|
+
|
|
20
|
+
// 创建服务器实例
|
|
21
|
+
const server = new Server(
|
|
22
|
+
{
|
|
23
|
+
name: 'git-push-mcp',
|
|
24
|
+
version: '1.0.0',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
capabilities: {
|
|
28
|
+
tools: {},
|
|
29
|
+
prompts: {},
|
|
30
|
+
resources: {}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// 注册工具调用处理器
|
|
36
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
37
|
+
const { name, arguments: args } = request.params;
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
let result;
|
|
41
|
+
|
|
42
|
+
switch (name) {
|
|
43
|
+
case 'process_natural_language':
|
|
44
|
+
result = await handler.processNaturalLanguage(args.text, args.context || {});
|
|
45
|
+
break;
|
|
46
|
+
case 'get_git_status':
|
|
47
|
+
result = await handler.getGitStatus();
|
|
48
|
+
break;
|
|
49
|
+
case 'commit_changes':
|
|
50
|
+
result = await handler.commitChanges(args.message, args.files, args.stageAll);
|
|
51
|
+
break;
|
|
52
|
+
case 'push_changes':
|
|
53
|
+
result = await handler.pushChanges(args.remote, args.branch);
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: JSON.stringify(result, null, 2)
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
} catch (error) {
|
|
68
|
+
return {
|
|
69
|
+
content: [
|
|
70
|
+
{
|
|
71
|
+
type: 'text',
|
|
72
|
+
text: JSON.stringify({
|
|
73
|
+
success: false,
|
|
74
|
+
error: error.message,
|
|
75
|
+
service: 'git-push-mcp'
|
|
76
|
+
}, null, 2)
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// 注册工具列表处理器
|
|
84
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
85
|
+
return {
|
|
86
|
+
tools: [
|
|
87
|
+
{
|
|
88
|
+
name: 'process_natural_language',
|
|
89
|
+
description: '处理自然语言Git命令,如"提交所有更改"、"推送代码"等',
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
text: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: '自然语言Git命令,如"提交所有更改"、"查看状态"等'
|
|
96
|
+
},
|
|
97
|
+
context: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
description: '执行上下文配置',
|
|
100
|
+
properties: {
|
|
101
|
+
autoStage: {
|
|
102
|
+
type: 'boolean',
|
|
103
|
+
description: '是否自动添加文件到暂存区',
|
|
104
|
+
default: true
|
|
105
|
+
},
|
|
106
|
+
autoPush: {
|
|
107
|
+
type: 'boolean',
|
|
108
|
+
description: '是否自动推送到远程仓库',
|
|
109
|
+
default: false
|
|
110
|
+
},
|
|
111
|
+
conventionalCommits: {
|
|
112
|
+
type: 'boolean',
|
|
113
|
+
description: '是否使用约定式提交格式',
|
|
114
|
+
default: true
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
required: ['text']
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'get_git_status',
|
|
124
|
+
description: '获取Git仓库状态信息',
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'commit_changes',
|
|
132
|
+
description: '提交Git更改',
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
message: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
description: '提交消息'
|
|
139
|
+
},
|
|
140
|
+
files: {
|
|
141
|
+
type: 'array',
|
|
142
|
+
items: {
|
|
143
|
+
type: 'string'
|
|
144
|
+
},
|
|
145
|
+
description: '要提交的文件列表'
|
|
146
|
+
},
|
|
147
|
+
stageAll: {
|
|
148
|
+
type: 'boolean',
|
|
149
|
+
description: '是否添加所有更改的文件',
|
|
150
|
+
default: true
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
required: ['message']
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'push_changes',
|
|
158
|
+
description: '推送到远程仓库',
|
|
159
|
+
inputSchema: {
|
|
160
|
+
type: 'object',
|
|
161
|
+
properties: {
|
|
162
|
+
remote: {
|
|
163
|
+
type: 'string',
|
|
164
|
+
description: '远程仓库名称',
|
|
165
|
+
default: 'origin'
|
|
166
|
+
},
|
|
167
|
+
branch: {
|
|
168
|
+
type: 'string',
|
|
169
|
+
description: '要推送的分支名称'
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// 注册资源和提示处理器(暂不实现)
|
|
179
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => ({ resources: [] }));
|
|
180
|
+
server.setRequestHandler(ReadResourceRequestSchema, async () => ({ contents: [] }));
|
|
181
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => ({ prompts: [] }));
|
|
182
|
+
server.setRequestHandler(GetPromptRequestSchema, async () => ({ messages: [] }));
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
// 设置传输层并连接
|
|
186
|
+
const transport = new StdioServerTransport();
|
|
187
|
+
await server.connect(transport);
|
|
188
|
+
|
|
189
|
+
console.error('Git Push MCP Server running on stdio');
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.error('Server connection error:', error);
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
main().catch((error) => {
|
|
197
|
+
console.error('Server startup error:', error);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
});
|
package/mcp.json
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.openagents.network/mcp/2024-01-01.json",
|
|
3
|
+
"name": "git-push-mcp",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "基于自然语言的代码提交MCP工具",
|
|
6
|
+
"capabilities": {
|
|
7
|
+
"tools": [
|
|
8
|
+
{
|
|
9
|
+
"name": "process_natural_language",
|
|
10
|
+
"description": "处理自然语言Git命令,如'提交所有更改'、'推送代码'等",
|
|
11
|
+
"inputSchema": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": {
|
|
14
|
+
"text": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "自然语言Git命令,如'提交所有更改'、'查看状态'等"
|
|
17
|
+
},
|
|
18
|
+
"context": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"description": "执行上下文配置",
|
|
21
|
+
"properties": {
|
|
22
|
+
"autoStage": {
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"description": "是否自动添加文件到暂存区",
|
|
25
|
+
"default": true
|
|
26
|
+
},
|
|
27
|
+
"autoPush": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"description": "是否自动推送到远程仓库",
|
|
30
|
+
"default": false
|
|
31
|
+
},
|
|
32
|
+
"conventionalCommits": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"description": "是否使用约定式提交格式",
|
|
35
|
+
"default": true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": ["text"]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "get_git_status",
|
|
45
|
+
"description": "获取Git仓库状态信息",
|
|
46
|
+
"inputSchema": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "commit_changes",
|
|
53
|
+
"description": "提交Git更改",
|
|
54
|
+
"inputSchema": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"properties": {
|
|
57
|
+
"message": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "提交消息"
|
|
60
|
+
},
|
|
61
|
+
"files": {
|
|
62
|
+
"type": "array",
|
|
63
|
+
"items": {
|
|
64
|
+
"type": "string"
|
|
65
|
+
},
|
|
66
|
+
"description": "要提交的文件列表"
|
|
67
|
+
},
|
|
68
|
+
"stageAll": {
|
|
69
|
+
"type": "boolean",
|
|
70
|
+
"description": "是否添加所有更改的文件",
|
|
71
|
+
"default": true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"required": ["message"]
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "push_changes",
|
|
79
|
+
"description": "推送到远程仓库",
|
|
80
|
+
"inputSchema": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"properties": {
|
|
83
|
+
"remote": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"description": "远程仓库名称",
|
|
86
|
+
"default": "origin"
|
|
87
|
+
},
|
|
88
|
+
"branch": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"description": "要推送的分支名称"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"resources": [],
|
|
97
|
+
"prompts": []
|
|
98
|
+
},
|
|
99
|
+
"entry": {
|
|
100
|
+
"type": "stdio",
|
|
101
|
+
"command": "node",
|
|
102
|
+
"args": ["./mcp-server.js"],
|
|
103
|
+
"env": {
|
|
104
|
+
"NODE_ENV": "production"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"permissions": {
|
|
108
|
+
"filesystem": {
|
|
109
|
+
"read": ["**/*"],
|
|
110
|
+
"write": ["**/*"]
|
|
111
|
+
},
|
|
112
|
+
"network": {
|
|
113
|
+
"outbound": false
|
|
114
|
+
},
|
|
115
|
+
"process": {
|
|
116
|
+
"spawn": ["git"]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "git-push-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "基于自然语言的代码提交MCP工具",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"git-push-mcp": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node index.js",
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"demo": "node demo.js",
|
|
13
|
+
"install-service": "node install.js",
|
|
14
|
+
"uninstall-service": "node install.js --uninstall",
|
|
15
|
+
"build": "node build.js",
|
|
16
|
+
"pack": "npm run build && npm pack"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"git",
|
|
20
|
+
"mcp",
|
|
21
|
+
"natural-language",
|
|
22
|
+
"code-commit",
|
|
23
|
+
"ai-assistant"
|
|
24
|
+
],
|
|
25
|
+
"author": "zhaolinjin",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
29
|
+
"dotenv": "^16.0.3",
|
|
30
|
+
"simple-git": "^3.19.1",
|
|
31
|
+
"winston": "^3.8.2"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"jest": "^29.5.0"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"index.js",
|
|
38
|
+
"mcp-server.js",
|
|
39
|
+
"mcp.json",
|
|
40
|
+
"lib/",
|
|
41
|
+
".env.example",
|
|
42
|
+
"README.md"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=14.0.0"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|