@julong/mono-rele2-core 1.7.0 → 1.9.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/index.d.ts +4 -8
- package/dist/index.js +67 -80
- package/dist/skills/{mono-rele2-core-cli → mono-rele2-core}/skill.md +10 -10
- package/package.json +2 -3
- package/dist/cli.js +0 -127
- package/dist/server.js +0 -107
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as _modelcontextprotocol_sdk_server_mcp_js from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
1
|
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
2
|
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,16 +16,14 @@ type AnyToolDef = {
|
|
|
16
16
|
guidelines?: string[];
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
declare function startServer(server: McpServer): Promise<void>;
|
|
20
|
+
|
|
19
21
|
type SkillTools = Record<string, AnyToolDef>;
|
|
20
22
|
declare function generateSkillMarkdown(opts: {
|
|
21
23
|
binName: string;
|
|
22
24
|
description: string;
|
|
23
25
|
tools: SkillTools;
|
|
24
26
|
}): string;
|
|
25
|
-
declare function generateReadmeSkills(opts: {
|
|
26
|
-
binName: string;
|
|
27
|
-
tools: SkillTools;
|
|
28
|
-
}): string;
|
|
29
27
|
|
|
30
28
|
declare const tools: {
|
|
31
29
|
echoTool: {
|
|
@@ -77,6 +75,4 @@ declare const tools: {
|
|
|
77
75
|
};
|
|
78
76
|
};
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export { createCoreServer, generateReadmeSkills, generateSkillMarkdown, tools };
|
|
78
|
+
export { generateSkillMarkdown, startServer, tools };
|
package/dist/index.js
CHANGED
|
@@ -24,9 +24,61 @@ 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
|
+
}
|
|
27
31
|
|
|
28
32
|
// ../common/kit/cli.ts
|
|
29
33
|
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
|
+
}
|
|
30
82
|
|
|
31
83
|
// ../common/kit/skill.ts
|
|
32
84
|
import { z as z2 } from "zod";
|
|
@@ -135,80 +187,8 @@ function containsType(schema, ctor) {
|
|
|
135
187
|
}
|
|
136
188
|
return inner instanceof ctor;
|
|
137
189
|
}
|
|
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
190
|
|
|
162
|
-
|
|
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
|
-
}
|
|
210
|
-
|
|
211
|
-
// src/tools/system.ts
|
|
191
|
+
// src/tools/index.ts
|
|
212
192
|
import { z as z3 } from "zod";
|
|
213
193
|
import { randomUUID } from "crypto";
|
|
214
194
|
var tools = {
|
|
@@ -263,15 +243,22 @@ var envTool = defineTool(tools.envTool);
|
|
|
263
243
|
var uuidTool = defineTool(tools.uuidTool);
|
|
264
244
|
|
|
265
245
|
// src/index.ts
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
+
});
|
|
271
258
|
}
|
|
259
|
+
var createCoreServer2;
|
|
272
260
|
export {
|
|
273
|
-
createCoreServer,
|
|
274
|
-
generateReadmeSkills,
|
|
275
261
|
generateSkillMarkdown,
|
|
262
|
+
startServer,
|
|
276
263
|
tools
|
|
277
264
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: mono-rele2-core
|
|
2
|
+
name: mono-rele2-core
|
|
3
3
|
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.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# mono-rele2-core
|
|
6
|
+
# mono-rele2-core
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
mono-rele2-core
|
|
9
|
+
mono-rele2-core <skillName> [...args]
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
## Skills
|
|
@@ -45,16 +45,16 @@ Generates a random UUID v4
|
|
|
45
45
|
|
|
46
46
|
## Examples
|
|
47
47
|
|
|
48
|
-
- `mono-rele2-core
|
|
49
|
-
- `mono-rele2-core
|
|
50
|
-
- `mono-rele2-core
|
|
51
|
-
- `mono-rele2-core
|
|
52
|
-
- `mono-rele2-core
|
|
53
|
-
- `mono-rele2-core
|
|
48
|
+
- `mono-rele2-core echoTool "hello world"` => `hello world`
|
|
49
|
+
- `mono-rele2-core timestampTool` => `2026-05-02T00:00:00.000Z`
|
|
50
|
+
- `mono-rele2-core timestampTool unix` => `1746144000000`
|
|
51
|
+
- `mono-rele2-core envTool HOME` => `/Users/julong`
|
|
52
|
+
- `mono-rele2-core envTool NODE_ENV` => `development`
|
|
53
|
+
- `mono-rele2-core uuidTool` => `550e8400-e29b-41d4-a716-446655440000`
|
|
54
54
|
|
|
55
55
|
## Guidelines
|
|
56
56
|
|
|
57
57
|
- Arguments are positional — pass them in the order listed in each skill's table
|
|
58
58
|
- Optional args with defaults may be omitted
|
|
59
59
|
- `envTool` returns an empty string when the variable is not set
|
|
60
|
-
- Run `mono-rele2-core
|
|
60
|
+
- Run `mono-rele2-core` with no args to list all available skills
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@julong/mono-rele2-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.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,8 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"bin": {
|
|
14
|
-
"mono-rele2-core": "./dist/
|
|
15
|
-
"mono-rele2-core-cli": "./dist/cli.js"
|
|
14
|
+
"mono-rele2-core": "./dist/index.js"
|
|
16
15
|
},
|
|
17
16
|
"files": [
|
|
18
17
|
"dist"
|
package/dist/cli.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
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 [, , cliName, 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/system.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/server.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
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/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(
|
|
97
|
-
{ name: "mono-rele2-core", version: "1.0.0" },
|
|
98
|
-
[echoTool, timestampTool, envTool, uuidTool]
|
|
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
|
-
});
|