@julong/mono-rele2-core 1.14.0 → 1.16.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/dist/cli.js +1 -1
- package/dist/server.js +109 -0
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ ${paramLines}`;
|
|
|
32
32
|
return "Available skills:\n\n" + sections.join("\n\n");
|
|
33
33
|
}
|
|
34
34
|
async function runCli(tools2) {
|
|
35
|
-
const [, ,
|
|
35
|
+
const [, , toolName, ...rawArgs] = process.argv;
|
|
36
36
|
console.log(process.argv);
|
|
37
37
|
if (!toolName || !(toolName in tools2)) {
|
|
38
38
|
if (toolName) console.error(`Unknown skill: "${toolName}"
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ../common/kit/tool.ts
|
|
4
|
+
function toolDef(def) {
|
|
5
|
+
return def;
|
|
6
|
+
}
|
|
7
|
+
function defineTool(tool) {
|
|
8
|
+
return tool;
|
|
9
|
+
}
|
|
10
|
+
function text(content) {
|
|
11
|
+
return { content: [{ type: "text", text: content }] };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ../common/kit/server.ts
|
|
15
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
16
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
17
|
+
function createMcpServer(config, tools2) {
|
|
18
|
+
const server3 = new McpServer(config);
|
|
19
|
+
for (const tool of tools2) {
|
|
20
|
+
server3.registerTool(
|
|
21
|
+
tool.name,
|
|
22
|
+
{ description: tool.description, inputSchema: tool.inputSchema },
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
tool.handler
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return server3;
|
|
28
|
+
}
|
|
29
|
+
async function startServer(server3) {
|
|
30
|
+
const transport = new StdioServerTransport();
|
|
31
|
+
await server3.connect(transport);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ../common/kit/cli.ts
|
|
35
|
+
import { z } from "zod";
|
|
36
|
+
|
|
37
|
+
// ../common/kit/skill.ts
|
|
38
|
+
import { z as z2 } from "zod";
|
|
39
|
+
|
|
40
|
+
// src/tools/system.ts
|
|
41
|
+
import { z as z3 } from "zod";
|
|
42
|
+
import { randomUUID } from "crypto";
|
|
43
|
+
var tools = {
|
|
44
|
+
echoTool: toolDef({
|
|
45
|
+
name: "echo",
|
|
46
|
+
description: "Returns the message as-is",
|
|
47
|
+
inputSchema: {
|
|
48
|
+
message: z3.string().describe("Message to echo")
|
|
49
|
+
},
|
|
50
|
+
handler: async ({ message }) => text(message),
|
|
51
|
+
examples: [{ args: [`"hello world"`], result: "hello world" }]
|
|
52
|
+
}),
|
|
53
|
+
timestampTool: toolDef({
|
|
54
|
+
name: "timestamp",
|
|
55
|
+
description: "Returns the current UTC timestamp",
|
|
56
|
+
inputSchema: {
|
|
57
|
+
format: z3.enum(["iso", "unix"]).default("iso").describe("Timestamp format")
|
|
58
|
+
},
|
|
59
|
+
handler: async ({ format }) => {
|
|
60
|
+
const value = format === "unix" ? String(Date.now()) : (/* @__PURE__ */ new Date()).toISOString();
|
|
61
|
+
return text(value);
|
|
62
|
+
},
|
|
63
|
+
examples: [
|
|
64
|
+
{ args: [], result: "2026-05-02T00:00:00.000Z" },
|
|
65
|
+
{ args: ["unix"], result: "1746144000000" }
|
|
66
|
+
]
|
|
67
|
+
}),
|
|
68
|
+
envTool: toolDef({
|
|
69
|
+
name: "env",
|
|
70
|
+
description: "Returns the value of an environment variable",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
key: z3.string().describe("Environment variable name")
|
|
73
|
+
},
|
|
74
|
+
handler: async ({ key }) => text(process.env[key] ?? ""),
|
|
75
|
+
examples: [
|
|
76
|
+
{ args: ["HOME"], result: "/Users/julong" },
|
|
77
|
+
{ args: ["NODE_ENV"], result: "development" }
|
|
78
|
+
],
|
|
79
|
+
guidelines: ["`envTool` returns an empty string when the variable is not set"]
|
|
80
|
+
}),
|
|
81
|
+
uuidTool: toolDef({
|
|
82
|
+
name: "uuid",
|
|
83
|
+
description: "Generates a random UUID v4",
|
|
84
|
+
inputSchema: {},
|
|
85
|
+
handler: async () => text(randomUUID()),
|
|
86
|
+
examples: [{ args: [], result: "550e8400-e29b-41d4-a716-446655440000" }]
|
|
87
|
+
})
|
|
88
|
+
};
|
|
89
|
+
var echoTool = defineTool(tools.echoTool);
|
|
90
|
+
var timestampTool = defineTool(tools.timestampTool);
|
|
91
|
+
var envTool = defineTool(tools.envTool);
|
|
92
|
+
var uuidTool = defineTool(tools.uuidTool);
|
|
93
|
+
|
|
94
|
+
// src/index.ts
|
|
95
|
+
function createCoreServer() {
|
|
96
|
+
return createMcpServer({ name: "mono-rele2-core", version: "1.0.0" }, [echoTool, timestampTool, envTool, uuidTool]);
|
|
97
|
+
}
|
|
98
|
+
var server = createCoreServer();
|
|
99
|
+
startServer(server).catch((err) => {
|
|
100
|
+
console.error("[core] server error:", err);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// src/server.ts
|
|
105
|
+
var server2 = createCoreServer();
|
|
106
|
+
startServer(server2).catch((err) => {
|
|
107
|
+
console.error("[core] server error:", err);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@julong/mono-rele2-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Use this skill to invoke core system utility functions via the mono-rele2-core CLI. Handles message echo, UTC timestamp generation, and environment variable lookup.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"bin": {
|
|
14
|
-
"mono-rele2-core": "./dist/
|
|
14
|
+
"mono-rele2-core": "./dist/server.js",
|
|
15
15
|
"mono-rele2-core-cli": "./dist/cli.js"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|