hono-mcp 1.4.1 → 1.4.3
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/commands/math.js +36 -28
- package/dist/commands/prompt.js +102 -0
- package/dist/index.js +1 -0
- package/dist/tools/decorator-tools.js +5 -8
- package/package.json +1 -1
package/dist/commands/math.js
CHANGED
|
@@ -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
|
|
11
|
-
import { Command, Param } from
|
|
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 =
|
|
15
|
+
async execute(params) {
|
|
16
|
+
const result = params.a + params.b;
|
|
17
17
|
return {
|
|
18
|
-
content: [
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
39
|
+
async execute(params) {
|
|
40
|
+
const result = params.a - params.b;
|
|
39
41
|
return {
|
|
40
|
-
content: [
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
63
|
+
async execute(params) {
|
|
64
|
+
const result = params.a * params.b;
|
|
61
65
|
return {
|
|
62
|
-
content: [
|
|
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(
|
|
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(
|
|
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(
|
|
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 (
|
|
87
|
+
async execute(params) {
|
|
88
|
+
if (params.b === 0) {
|
|
83
89
|
return {
|
|
84
|
-
content: [{ type:
|
|
90
|
+
content: [{ type: "text", text: "Error: Division by zero" }],
|
|
85
91
|
isError: true,
|
|
86
92
|
};
|
|
87
93
|
}
|
|
88
|
-
const result =
|
|
94
|
+
const result = params.a / params.b;
|
|
89
95
|
return {
|
|
90
|
-
content: [
|
|
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(
|
|
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(
|
|
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(
|
|
111
|
+
Command("math.divide", "Divide two numbers")
|
|
104
112
|
], DivideCommand);
|
|
105
113
|
export { DivideCommand };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { Command, Param } from "../decorators/command.js";
|
|
12
|
+
const GIT_COMMIT_EMOJIS = {
|
|
13
|
+
feat: "✨",
|
|
14
|
+
fix: "🐛",
|
|
15
|
+
docs: "📝",
|
|
16
|
+
style: "🎨",
|
|
17
|
+
refactor: "♻️",
|
|
18
|
+
perf: "⚡",
|
|
19
|
+
test: "✅",
|
|
20
|
+
build: "📦",
|
|
21
|
+
ci: "👷",
|
|
22
|
+
chore: "🔧",
|
|
23
|
+
revert: "⏪",
|
|
24
|
+
};
|
|
25
|
+
let GitCommitPromptCommand = class GitCommitPromptCommand {
|
|
26
|
+
includeExamples;
|
|
27
|
+
async execute(params) {
|
|
28
|
+
const includeExamples = params.includeExamples ?? true;
|
|
29
|
+
let prompt = `# Git Commit Convention
|
|
30
|
+
|
|
31
|
+
Please format your git commit messages using the following convention:
|
|
32
|
+
|
|
33
|
+
## Format
|
|
34
|
+
\`\`\`
|
|
35
|
+
<emoji> <type>: <description>
|
|
36
|
+
\`\`\`
|
|
37
|
+
|
|
38
|
+
## Commit Types
|
|
39
|
+
`;
|
|
40
|
+
for (const [type, emoji] of Object.entries(GIT_COMMIT_EMOJIS)) {
|
|
41
|
+
prompt += `- ${emoji} **${type}**: ${this.getTypeDescription(type)}\n`;
|
|
42
|
+
}
|
|
43
|
+
if (includeExamples) {
|
|
44
|
+
prompt += `
|
|
45
|
+
## Examples
|
|
46
|
+
\`\`\`
|
|
47
|
+
${GIT_COMMIT_EMOJIS.feat} feat: add user authentication
|
|
48
|
+
${GIT_COMMIT_EMOJIS.fix} fix: resolve login timeout issue
|
|
49
|
+
${GIT_COMMIT_EMOJIS.docs} docs: update API documentation
|
|
50
|
+
${GIT_COMMIT_EMOJIS.style} style: format code with prettier
|
|
51
|
+
${GIT_COMMIT_EMOJIS.refactor} refactor: simplify user service logic
|
|
52
|
+
${GIT_COMMIT_EMOJIS.perf} perf: optimize database queries
|
|
53
|
+
${GIT_COMMIT_EMOJIS.test} test: add unit tests for auth module
|
|
54
|
+
${GIT_COMMIT_EMOJIS.build} build: upgrade webpack to v5
|
|
55
|
+
${GIT_COMMIT_EMOJIS.ci} ci: add GitHub Actions workflow
|
|
56
|
+
${GIT_COMMIT_EMOJIS.chore} chore: update dependencies
|
|
57
|
+
${GIT_COMMIT_EMOJIS.revert} revert: remove deprecated feature
|
|
58
|
+
\`\`\`
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
prompt += `
|
|
62
|
+
## Guidelines
|
|
63
|
+
- Keep the description concise and clear
|
|
64
|
+
- Use imperative mood (e.g., "add" not "added" or "adds")
|
|
65
|
+
- Limit the first line to 50 characters
|
|
66
|
+
- Reference issues in the description if applicable
|
|
67
|
+
- Break long descriptions into multiple paragraphs
|
|
68
|
+
`;
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: "text",
|
|
73
|
+
text: prompt,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
getTypeDescription(type) {
|
|
79
|
+
const descriptions = {
|
|
80
|
+
feat: "A new feature",
|
|
81
|
+
fix: "A bug fix",
|
|
82
|
+
docs: "Documentation only changes",
|
|
83
|
+
style: "Code style changes (formatting, etc.)",
|
|
84
|
+
refactor: "Code refactoring",
|
|
85
|
+
perf: "Performance improvements",
|
|
86
|
+
test: "Adding or updating tests",
|
|
87
|
+
build: "Build system or dependencies",
|
|
88
|
+
ci: "CI/CD configuration changes",
|
|
89
|
+
chore: "Other changes that don't fit above",
|
|
90
|
+
revert: "Revert a previous commit",
|
|
91
|
+
};
|
|
92
|
+
return descriptions[type] || "Other changes";
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
__decorate([
|
|
96
|
+
Param(z.boolean().optional().describe("Include examples in the prompt")),
|
|
97
|
+
__metadata("design:type", Boolean)
|
|
98
|
+
], GitCommitPromptCommand.prototype, "includeExamples", void 0);
|
|
99
|
+
GitCommitPromptCommand = __decorate([
|
|
100
|
+
Command("prompt.git-commit", "Inject git commit convention prompt")
|
|
101
|
+
], GitCommitPromptCommand);
|
|
102
|
+
export { GitCommitPromptCommand };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import 'reflect-metadata';
|
|
|
4
4
|
import vscodeSettings from './data/vscode-settings.json' with { type: 'json' };
|
|
5
5
|
import { executeCommandTool, helpTool } from "./tools/decorator-tools.js";
|
|
6
6
|
import './commands/math.js';
|
|
7
|
+
import './commands/prompt.js';
|
|
7
8
|
const app = new Hono();
|
|
8
9
|
const tools = [executeCommandTool, helpTool];
|
|
9
10
|
var ToolName;
|
|
@@ -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
|
-
|
|
7
|
-
|
|
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 {
|