mcp-adder-simple 1.0.2 → 1.0.4
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/mcp-adder.js +21 -3
- package/package.json +1 -1
package/mcp-adder.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
1
|
const readline = require('readline');
|
|
4
2
|
|
|
5
3
|
// 创建 readline 接口
|
|
@@ -23,13 +21,33 @@ rl.on('line', (line) => {
|
|
|
23
21
|
const msg = JSON.parse(trimmed);
|
|
24
22
|
console.error('[MCP] ✅ 解析成功:', msg.method);
|
|
25
23
|
|
|
26
|
-
if (
|
|
24
|
+
if (msg.id === undefined || msg.id === null) return;
|
|
27
25
|
|
|
28
26
|
let result = null;
|
|
29
27
|
let error = null;
|
|
30
28
|
|
|
31
29
|
try {
|
|
32
30
|
switch (msg.method) {
|
|
31
|
+
case 'tools/list':
|
|
32
|
+
result = {
|
|
33
|
+
tools: [
|
|
34
|
+
{
|
|
35
|
+
name: 'add_numbers',
|
|
36
|
+
description: '将两个数字相加',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
a: { type: 'number', description: '第一个数' },
|
|
41
|
+
b: { type: 'number', description: '第二个数' }
|
|
42
|
+
},
|
|
43
|
+
required: ['a', 'b']
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
console.error('[MCP] ← tools/list 成功响应');
|
|
49
|
+
break;
|
|
50
|
+
|
|
33
51
|
case 'initialize':
|
|
34
52
|
result = {
|
|
35
53
|
protocolVersion: '2024-10-07',
|