mcp-adder-simple 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/mcp-adder.js +39 -3
  2. package/package.json +4 -3
package/mcp-adder.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * MCP Adder Server
3
- * 一个简单的 MCP (Model Context Protocol) 服务器,提供数字相加功能
2
+ * MCP Calculator Server
3
+ * 一个简单的 MCP (Model Context Protocol) 服务器,提供基本的数学计算功能
4
4
  */
5
5
 
6
6
  const readline = require('readline');
@@ -107,7 +107,7 @@ function handleInitialize() {
107
107
  return {
108
108
  protocolVersion: '2024-10-07',
109
109
  serverInfo: {
110
- name: 'mcp-adder-server',
110
+ name: 'mcp-calculator-server',
111
111
  version: '1.0.0'
112
112
  },
113
113
  capabilities: {
@@ -140,6 +140,24 @@ function handleToolsList() {
140
140
  },
141
141
  required: ['a', 'b']
142
142
  }
143
+ },
144
+ {
145
+ name: 'multiply_numbers',
146
+ description: '将两个数字相乘',
147
+ inputSchema: {
148
+ type: 'object',
149
+ properties: {
150
+ a: {
151
+ type: 'number',
152
+ description: '第一个数'
153
+ },
154
+ b: {
155
+ type: 'number',
156
+ description: '第二个数'
157
+ }
158
+ },
159
+ required: ['a', 'b']
160
+ }
143
161
  }
144
162
  ]
145
163
  };
@@ -173,6 +191,24 @@ function handleToolCall(params) {
173
191
  ]
174
192
  };
175
193
 
194
+ } else if (name === 'multiply_numbers') {
195
+ const { a, b } = args;
196
+
197
+ // 参数类型验证
198
+ if (typeof a !== 'number' || typeof b !== 'number') {
199
+ throw new Error('参数必须是数字');
200
+ }
201
+
202
+ // 计算并返回结果
203
+ return {
204
+ content: [
205
+ {
206
+ type: 'text',
207
+ text: `${a} × ${b} = ${a * b}`
208
+ }
209
+ ]
210
+ };
211
+
176
212
  } else {
177
213
  throw new Error(`未知工具: ${name}`);
178
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-adder-simple",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "main": "mcp-adder.js",
5
5
  "bin": {
6
6
  "mcp-adder-simple": "./bin/mcp-adder-simple.cmd"
@@ -12,11 +12,12 @@
12
12
  "mcp",
13
13
  "model-context-protocol",
14
14
  "calculator",
15
- "add"
15
+ "add",
16
+ "multiply"
16
17
  ],
17
18
  "author": "xiaosheng_2021",
18
19
  "license": "MIT",
19
- "description": "A simple MCP server for adding numbers",
20
+ "description": "A simple MCP server for basic math calculations",
20
21
  "repository": {
21
22
  "type": "git",
22
23
  "url": "https://github.com/xiaosheng-2021/mcp-adder.git"