hono-mcp 1.4.1 → 1.4.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.
@@ -7,99 +7,107 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { z } from 'zod';
11
- import { Command, Param } from '../decorators/command.js';
10
+ import { z } from "zod";
11
+ import { Command, Param } from "../decorators/command.js";
12
12
  let AddCommand = class AddCommand {
13
13
  a;
14
14
  b;
15
- async execute() {
16
- const result = this.a + this.b;
15
+ async execute(params) {
16
+ const result = params.a + params.b;
17
17
  return {
18
- content: [{ type: 'text', text: `${this.a} + ${this.b} = ${result}` }],
18
+ content: [
19
+ { type: "text", text: `${params.a} + ${params.b} = ${result}` },
20
+ ],
19
21
  };
20
22
  }
21
23
  };
22
24
  __decorate([
23
- Param(z.number().describe('First number')),
25
+ Param(z.number().describe("First number")),
24
26
  __metadata("design:type", Number)
25
27
  ], AddCommand.prototype, "a", void 0);
26
28
  __decorate([
27
- Param(z.number().describe('Second number')),
29
+ Param(z.number().describe("Second number")),
28
30
  __metadata("design:type", Number)
29
31
  ], AddCommand.prototype, "b", void 0);
30
32
  AddCommand = __decorate([
31
- Command('math.add', 'Add two numbers')
33
+ Command("math.add", "Add two numbers")
32
34
  ], AddCommand);
33
35
  export { AddCommand };
34
36
  let SubtractCommand = class SubtractCommand {
35
37
  a;
36
38
  b;
37
- async execute() {
38
- const result = this.a - this.b;
39
+ async execute(params) {
40
+ const result = params.a - params.b;
39
41
  return {
40
- content: [{ type: 'text', text: `${this.a} - ${this.b} = ${result}` }],
42
+ content: [
43
+ { type: "text", text: `${params.a} - ${params.b} = ${result}` },
44
+ ],
41
45
  };
42
46
  }
43
47
  };
44
48
  __decorate([
45
- Param(z.number().describe('First number')),
49
+ Param(z.number().describe("First number")),
46
50
  __metadata("design:type", Number)
47
51
  ], SubtractCommand.prototype, "a", void 0);
48
52
  __decorate([
49
- Param(z.number().describe('Second number')),
53
+ Param(z.number().describe("Second number")),
50
54
  __metadata("design:type", Number)
51
55
  ], SubtractCommand.prototype, "b", void 0);
52
56
  SubtractCommand = __decorate([
53
- Command('math.subtract', 'Subtract two numbers')
57
+ Command("math.subtract", "Subtract two numbers")
54
58
  ], SubtractCommand);
55
59
  export { SubtractCommand };
56
60
  let MultiplyCommand = class MultiplyCommand {
57
61
  a;
58
62
  b;
59
- async execute() {
60
- const result = this.a * this.b;
63
+ async execute(params) {
64
+ const result = params.a * params.b;
61
65
  return {
62
- content: [{ type: 'text', text: `${this.a} × ${this.b} = ${result}` }],
66
+ content: [
67
+ { type: "text", text: `${params.a} × ${params.b} = ${result}` },
68
+ ],
63
69
  };
64
70
  }
65
71
  };
66
72
  __decorate([
67
- Param(z.number().describe('First number')),
73
+ Param(z.number().describe("First number")),
68
74
  __metadata("design:type", Number)
69
75
  ], MultiplyCommand.prototype, "a", void 0);
70
76
  __decorate([
71
- Param(z.number().describe('Second number')),
77
+ Param(z.number().describe("Second number")),
72
78
  __metadata("design:type", Number)
73
79
  ], MultiplyCommand.prototype, "b", void 0);
74
80
  MultiplyCommand = __decorate([
75
- Command('math.multiply', 'Multiply two numbers')
81
+ Command("math.multiply", "Multiply two numbers")
76
82
  ], MultiplyCommand);
77
83
  export { MultiplyCommand };
78
84
  let DivideCommand = class DivideCommand {
79
85
  a;
80
86
  b;
81
- async execute() {
82
- if (this.b === 0) {
87
+ async execute(params) {
88
+ if (params.b === 0) {
83
89
  return {
84
- content: [{ type: 'text', text: 'Error: Division by zero' }],
90
+ content: [{ type: "text", text: "Error: Division by zero" }],
85
91
  isError: true,
86
92
  };
87
93
  }
88
- const result = this.a / this.b;
94
+ const result = params.a / params.b;
89
95
  return {
90
- content: [{ type: 'text', text: `${this.a} ÷ ${this.b} = ${result}` }],
96
+ content: [
97
+ { type: "text", text: `${params.a} ÷ ${params.b} = ${result}` },
98
+ ],
91
99
  };
92
100
  }
93
101
  };
94
102
  __decorate([
95
- Param(z.number().describe('First number')),
103
+ Param(z.number().describe("First number")),
96
104
  __metadata("design:type", Number)
97
105
  ], DivideCommand.prototype, "a", void 0);
98
106
  __decorate([
99
- Param(z.number().describe('Second number')),
107
+ Param(z.number().describe("Second number")),
100
108
  __metadata("design:type", Number)
101
109
  ], DivideCommand.prototype, "b", void 0);
102
110
  DivideCommand = __decorate([
103
- Command('math.divide', 'Divide two numbers')
111
+ Command("math.divide", "Divide two numbers")
104
112
  ], DivideCommand);
105
113
  export { DivideCommand };
@@ -2,15 +2,12 @@ import { z } from "zod";
2
2
  import { getCommandRegistry } from "../decorators/command.js";
3
3
  export const executeCommandTool = (server) => {
4
4
  server.tool("executeCommand", "Execute any command by specifying its type and parameters", {
5
- type: {
6
- type: "string",
7
- description: "Command type (e.g., math.add, math.subtract, math.multiply, math.divide)",
8
- },
9
- params: {
10
- type: "object",
11
- description: "Command parameters",
12
- },
5
+ type: z
6
+ .string()
7
+ .describe("Command type (e.g., math.add, math.subtract, math.multiply, math.divide)"),
8
+ params: z.record(z.any()).describe("Command parameters"),
13
9
  }, async ({ type, params }) => {
10
+ console.log("executeCommand called with:", { type, params });
14
11
  const command = getCommandRegistry().get(type);
15
12
  if (!command) {
16
13
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-mcp",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "MCP server built with Hono - supports both Vercel deployment and npx CLI usage",
5
5
  "main": "dist/index.js",
6
6
  "bin": {