@julong/mono-rele2-core 1.9.0 → 1.10.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 ADDED
@@ -0,0 +1,127 @@
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
+
18
+ // ../common/kit/cli.ts
19
+ import { z } from "zod";
20
+ function formatSkills(tools2) {
21
+ const sections = Object.entries(tools2).map(([key, tool]) => {
22
+ const params = Object.entries(tool.inputSchema);
23
+ const maxLen = Math.max(...params.map(([f]) => f.length));
24
+ const paramLines = params.map(([field, schema]) => {
25
+ const desc = schema.description ?? "";
26
+ return ` ${field.padEnd(maxLen + 2)}${desc}`;
27
+ }).join("\n");
28
+ return ` ${key}
29
+ ${tool.description}
30
+ ${paramLines}`;
31
+ });
32
+ return "Available skills:\n\n" + sections.join("\n\n");
33
+ }
34
+ async function runCli(tools2) {
35
+ const [, , toolName, ...rawArgs] = process.argv;
36
+ if (!toolName || !(toolName in tools2)) {
37
+ if (toolName) console.error(`Unknown skill: "${toolName}"
38
+ `);
39
+ console.log(formatSkills(tools2));
40
+ process.exit(toolName ? 1 : 0);
41
+ }
42
+ const tool = tools2[toolName];
43
+ const fieldNames = Object.keys(tool.inputSchema);
44
+ const rawInput = {};
45
+ for (let i = 0; i < fieldNames.length; i++) {
46
+ const raw = rawArgs[i];
47
+ if (raw === void 0) continue;
48
+ try {
49
+ rawInput[fieldNames[i]] = JSON.parse(raw);
50
+ } catch {
51
+ rawInput[fieldNames[i]] = raw;
52
+ }
53
+ }
54
+ const parsed = z.object(tool.inputSchema).parse(rawInput);
55
+ const result = await tool.handler(parsed);
56
+ for (const part of result.content) {
57
+ if (part.type === "text") console.log(part.text);
58
+ }
59
+ }
60
+ function handleCliError(err) {
61
+ if (err instanceof z.ZodError) {
62
+ console.error("Validation error:", err.issues.map((e) => `${e.path.join(".")}: ${e.message}`).join(", "));
63
+ } else {
64
+ console.error("Error:", err instanceof Error ? err.message : String(err));
65
+ }
66
+ process.exit(1);
67
+ }
68
+
69
+ // ../common/kit/skill.ts
70
+ import { z as z2 } from "zod";
71
+
72
+ // src/tools/index.ts
73
+ import { z as z3 } from "zod";
74
+ import { randomUUID } from "crypto";
75
+ var tools = {
76
+ echoTool: toolDef({
77
+ name: "echo",
78
+ description: "Returns the message as-is",
79
+ inputSchema: {
80
+ message: z3.string().describe("Message to echo")
81
+ },
82
+ handler: async ({ message }) => text(message),
83
+ examples: [{ args: [`"hello world"`], result: "hello world" }]
84
+ }),
85
+ timestampTool: toolDef({
86
+ name: "timestamp",
87
+ description: "Returns the current UTC timestamp",
88
+ inputSchema: {
89
+ format: z3.enum(["iso", "unix"]).default("iso").describe("Timestamp format")
90
+ },
91
+ handler: async ({ format }) => {
92
+ const value = format === "unix" ? String(Date.now()) : (/* @__PURE__ */ new Date()).toISOString();
93
+ return text(value);
94
+ },
95
+ examples: [
96
+ { args: [], result: "2026-05-02T00:00:00.000Z" },
97
+ { args: ["unix"], result: "1746144000000" }
98
+ ]
99
+ }),
100
+ envTool: toolDef({
101
+ name: "env",
102
+ description: "Returns the value of an environment variable",
103
+ inputSchema: {
104
+ key: z3.string().describe("Environment variable name")
105
+ },
106
+ handler: async ({ key }) => text(process.env[key] ?? ""),
107
+ examples: [
108
+ { args: ["HOME"], result: "/Users/julong" },
109
+ { args: ["NODE_ENV"], result: "development" }
110
+ ],
111
+ guidelines: ["`envTool` returns an empty string when the variable is not set"]
112
+ }),
113
+ uuidTool: toolDef({
114
+ name: "uuid",
115
+ description: "Generates a random UUID v4",
116
+ inputSchema: {},
117
+ handler: async () => text(randomUUID()),
118
+ examples: [{ args: [], result: "550e8400-e29b-41d4-a716-446655440000" }]
119
+ })
120
+ };
121
+ var echoTool = defineTool(tools.echoTool);
122
+ var timestampTool = defineTool(tools.timestampTool);
123
+ var envTool = defineTool(tools.envTool);
124
+ var uuidTool = defineTool(tools.uuidTool);
125
+
126
+ // src/cli.ts
127
+ runCli(tools).catch(handleCliError);
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import * as _modelcontextprotocol_sdk_server_mcp_js from '@modelcontextprotocol/sdk/server/mcp.js';
1
2
  import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
3
  import { z } from 'zod';
3
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
4
 
5
5
  type ToolResult = CallToolResult;
6
6
  type ToolExample = {
@@ -16,14 +16,16 @@ type AnyToolDef = {
16
16
  guidelines?: string[];
17
17
  };
18
18
 
19
- declare function startServer(server: McpServer): Promise<void>;
20
-
21
19
  type SkillTools = Record<string, AnyToolDef>;
22
20
  declare function generateSkillMarkdown(opts: {
23
21
  binName: string;
24
22
  description: string;
25
23
  tools: SkillTools;
26
24
  }): string;
25
+ declare function generateReadmeSkills(opts: {
26
+ binName: string;
27
+ tools: SkillTools;
28
+ }): string;
27
29
 
28
30
  declare const tools: {
29
31
  echoTool: {
@@ -75,4 +77,6 @@ declare const tools: {
75
77
  };
76
78
  };
77
79
 
78
- export { generateSkillMarkdown, startServer, tools };
80
+ declare function createCoreServer(): _modelcontextprotocol_sdk_server_mcp_js.McpServer;
81
+
82
+ export { createCoreServer, generateReadmeSkills, generateSkillMarkdown, tools };
package/dist/index.js CHANGED
@@ -24,61 +24,9 @@ function createMcpServer(config, tools2) {
24
24
  }
25
25
  return server;
26
26
  }
27
- async function startServer(server) {
28
- const transport = new StdioServerTransport();
29
- await server.connect(transport);
30
- }
31
27
 
32
28
  // ../common/kit/cli.ts
33
29
  import { z } from "zod";
34
- function formatSkills(tools2) {
35
- const sections = Object.entries(tools2).map(([key, tool]) => {
36
- const params = Object.entries(tool.inputSchema);
37
- const maxLen = Math.max(...params.map(([f]) => f.length));
38
- const paramLines = params.map(([field, schema]) => {
39
- const desc = schema.description ?? "";
40
- return ` ${field.padEnd(maxLen + 2)}${desc}`;
41
- }).join("\n");
42
- return ` ${key}
43
- ${tool.description}
44
- ${paramLines}`;
45
- });
46
- return "Available skills:\n\n" + sections.join("\n\n");
47
- }
48
- async function runCli(tools2) {
49
- const [, , toolName, ...rawArgs] = process.argv;
50
- if (!toolName || !(toolName in tools2)) {
51
- if (toolName) console.error(`Unknown skill: "${toolName}"
52
- `);
53
- console.log(formatSkills(tools2));
54
- process.exit(toolName ? 1 : 0);
55
- }
56
- const tool = tools2[toolName];
57
- const fieldNames = Object.keys(tool.inputSchema);
58
- const rawInput = {};
59
- for (let i = 0; i < fieldNames.length; i++) {
60
- const raw = rawArgs[i];
61
- if (raw === void 0) continue;
62
- try {
63
- rawInput[fieldNames[i]] = JSON.parse(raw);
64
- } catch {
65
- rawInput[fieldNames[i]] = raw;
66
- }
67
- }
68
- const parsed = z.object(tool.inputSchema).parse(rawInput);
69
- const result = await tool.handler(parsed);
70
- for (const part of result.content) {
71
- if (part.type === "text") console.log(part.text);
72
- }
73
- }
74
- function handleCliError(err) {
75
- if (err instanceof z.ZodError) {
76
- console.error("Validation error:", err.issues.map((e) => `${e.path.join(".")}: ${e.message}`).join(", "));
77
- } else {
78
- console.error("Error:", err instanceof Error ? err.message : String(err));
79
- }
80
- process.exit(1);
81
- }
82
30
 
83
31
  // ../common/kit/skill.ts
84
32
  import { z as z2 } from "zod";
@@ -187,6 +135,78 @@ function containsType(schema, ctor) {
187
135
  }
188
136
  return inner instanceof ctor;
189
137
  }
138
+ function generateReadmeSkills(opts) {
139
+ const { binName, tools: tools2 } = opts;
140
+ return Object.entries(tools2).map(([key, tool]) => renderReadmeSkill(binName, key, tool)).join("\n\n");
141
+ }
142
+ function renderReadmeSkill(binName, key, tool) {
143
+ const fields = Object.entries(tool.inputSchema);
144
+ const usageArgs = fields.map(([field, schema]) => {
145
+ const isOpt = schema instanceof z2.ZodOptional || schema instanceof z2.ZodDefault;
146
+ return isOpt ? `[${field}]` : `<${field}>`;
147
+ }).join(" ");
148
+ const usage = [binName, key, usageArgs].filter(Boolean).join(" ");
149
+ const rows = fields.map(([field, schema]) => {
150
+ const t = describeReadmeType(schema);
151
+ const d = describeReadmeDesc(schema);
152
+ return `| \`${field}\` | ${t} | ${d} |`;
153
+ }).join("\n");
154
+ const examples = tool.examples ?? [];
155
+ let exampleBlock = "";
156
+ if (examples.length > 0) {
157
+ const cmds = examples.map((ex) => [binName, key, ...ex.args].join(" "));
158
+ const width = Math.max(...cmds.map((c) => c.length));
159
+ const lines = examples.map((ex, i) => `${cmds[i].padEnd(width)} # ${ex.result}`);
160
+ exampleBlock = `
161
+
162
+ \`\`\`sh
163
+ ${lines.join("\n")}
164
+ \`\`\``;
165
+ }
166
+ const tableBlock = rows ? `
167
+
168
+ | arg | type | description |
169
+ |-----|------|-------------|
170
+ ${rows}` : "";
171
+ return `#### \`${key}\`
172
+
173
+ ${tool.description}.
174
+
175
+ \`\`\`sh
176
+ ${usage}
177
+ \`\`\`${tableBlock}${exampleBlock}`;
178
+ }
179
+ function describeReadmeType(schema) {
180
+ let inner = schema;
181
+ while (inner instanceof z2.ZodOptional || inner instanceof z2.ZodDefault) {
182
+ inner = inner.unwrap();
183
+ }
184
+ if (inner instanceof z2.ZodEnum) {
185
+ return inner.options.map((v) => `\`${v}\``).join(" \\| ");
186
+ }
187
+ if (inner instanceof z2.ZodNumber) return "number";
188
+ if (inner instanceof z2.ZodString) return "string";
189
+ if (inner instanceof z2.ZodBoolean) return "boolean";
190
+ if (inner instanceof z2.ZodArray) return "JSON string (array)";
191
+ return "unknown";
192
+ }
193
+ function describeReadmeDesc(schema) {
194
+ const baseDesc = schema.description ?? "";
195
+ let inner = schema;
196
+ let defaultValue;
197
+ let isOptional = false;
198
+ while (inner instanceof z2.ZodOptional || inner instanceof z2.ZodDefault) {
199
+ if (inner instanceof z2.ZodDefault) {
200
+ const raw = inner.def.defaultValue;
201
+ defaultValue = typeof raw === "function" ? raw() : raw;
202
+ }
203
+ if (inner instanceof z2.ZodOptional) isOptional = true;
204
+ inner = inner.unwrap();
205
+ }
206
+ if (defaultValue !== void 0) return `${baseDesc} (default: \`${String(defaultValue)}\`)`;
207
+ if (isOptional) return `${baseDesc} (optional)`;
208
+ return baseDesc;
209
+ }
190
210
 
191
211
  // src/tools/index.ts
192
212
  import { z as z3 } from "zod";
@@ -243,22 +263,15 @@ var envTool = defineTool(tools.envTool);
243
263
  var uuidTool = defineTool(tools.uuidTool);
244
264
 
245
265
  // src/index.ts
246
- if (process.argv.includes("--cli")) {
247
- runCli(tools).catch(handleCliError);
248
- } else {
249
- let createCoreServer = function() {
250
- return createMcpServer({ name: "mono-rele2-core", version: "1.0.0" }, [echoTool, timestampTool, envTool, uuidTool]);
251
- };
252
- createCoreServer2 = createCoreServer;
253
- const server = createCoreServer();
254
- startServer(server).catch((err) => {
255
- console.error("[core] server error:", err);
256
- process.exit(1);
257
- });
266
+ function createCoreServer() {
267
+ return createMcpServer(
268
+ { name: "mono-rele2-core", version: "1.0.0" },
269
+ [echoTool, timestampTool, envTool]
270
+ );
258
271
  }
259
- var createCoreServer2;
260
272
  export {
273
+ createCoreServer,
274
+ generateReadmeSkills,
261
275
  generateSkillMarkdown,
262
- startServer,
263
276
  tools
264
277
  };
package/dist/server.js ADDED
@@ -0,0 +1,107 @@
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 server2 = new McpServer(config);
19
+ for (const tool of tools2) {
20
+ server2.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 server2;
28
+ }
29
+ async function startServer(server2) {
30
+ const transport = new StdioServerTransport();
31
+ await server2.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/index.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(
97
+ { name: "mono-rele2-core", version: "1.0.0" },
98
+ [echoTool, timestampTool, envTool]
99
+ );
100
+ }
101
+
102
+ // src/server.ts
103
+ var server = createCoreServer();
104
+ startServer(server).catch((err) => {
105
+ console.error("[core] server error:", err);
106
+ process.exit(1);
107
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@julong/mono-rele2-core",
3
- "version": "1.9.0",
3
+ "version": "1.10.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,8 @@
11
11
  }
12
12
  },
13
13
  "bin": {
14
- "mono-rele2-core": "./dist/index.js"
14
+ "mcp-core": "./dist/server.js",
15
+ "mono-rele2-core": "./dist/cli.js"
15
16
  },
16
17
  "files": [
17
18
  "dist"