@julong/mono-rele2-utils 1.8.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 +1 -4
- package/dist/index.js +69 -21
- package/dist/skills/{mono-rele2-utils-cli → mono-rele2-utils}/skill.md +10 -10
- package/package.json +2 -3
- package/dist/cli.js +0 -147
- package/dist/server.js +0 -131
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
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';
|
|
4
3
|
|
|
@@ -81,6 +80,4 @@ declare const tools: {
|
|
|
81
80
|
};
|
|
82
81
|
};
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
export { cn, createUtilsServer, generateReadmeSkills, generateSkillMarkdown, tools };
|
|
83
|
+
export { cn, generateReadmeSkills, generateSkillMarkdown, tools };
|
package/dist/index.js
CHANGED
|
@@ -13,24 +13,72 @@ function text(content) {
|
|
|
13
13
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
14
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
15
15
|
function createMcpServer(config, tools2) {
|
|
16
|
-
const
|
|
16
|
+
const server = new McpServer(config);
|
|
17
17
|
for (const tool of tools2) {
|
|
18
|
-
|
|
18
|
+
server.registerTool(
|
|
19
19
|
tool.name,
|
|
20
20
|
{ description: tool.description, inputSchema: tool.inputSchema },
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
tool.handler
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return server;
|
|
26
26
|
}
|
|
27
|
-
async function startServer(
|
|
27
|
+
async function startServer(server) {
|
|
28
28
|
const transport = new StdioServerTransport();
|
|
29
|
-
await
|
|
29
|
+
await server.connect(transport);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// ../common/kit/cli.ts
|
|
33
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
|
+
}
|
|
34
82
|
|
|
35
83
|
// ../common/kit/skill.ts
|
|
36
84
|
import { z as z2 } from "zod";
|
|
@@ -212,7 +260,7 @@ function describeReadmeDesc(schema) {
|
|
|
212
260
|
return baseDesc;
|
|
213
261
|
}
|
|
214
262
|
|
|
215
|
-
// src/tools/
|
|
263
|
+
// src/tools/index.ts
|
|
216
264
|
import { z as z3 } from "zod";
|
|
217
265
|
|
|
218
266
|
// src/cn.ts
|
|
@@ -220,7 +268,7 @@ function cn(...classes) {
|
|
|
220
268
|
return classes.filter(Boolean).join(" ");
|
|
221
269
|
}
|
|
222
270
|
|
|
223
|
-
// src/tools/
|
|
271
|
+
// src/tools/index.ts
|
|
224
272
|
var tools = {
|
|
225
273
|
cnTool: toolDef({
|
|
226
274
|
name: "cn",
|
|
@@ -229,9 +277,7 @@ var tools = {
|
|
|
229
277
|
classes: z3.array(z3.string()).describe("List of class names to merge")
|
|
230
278
|
},
|
|
231
279
|
handler: async ({ classes }) => text(cn(...classes)),
|
|
232
|
-
examples: [
|
|
233
|
-
{ args: [`'["btn","active","large"]'`], result: "btn active large" }
|
|
234
|
-
]
|
|
280
|
+
examples: [{ args: [`'["btn","active","large"]'`], result: "btn active large" }]
|
|
235
281
|
}),
|
|
236
282
|
caseConvertTool: toolDef({
|
|
237
283
|
name: "case_convert",
|
|
@@ -286,20 +332,22 @@ function convert(input, to) {
|
|
|
286
332
|
}
|
|
287
333
|
|
|
288
334
|
// src/index.ts
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
335
|
+
if (process.argv.includes("--cli")) {
|
|
336
|
+
runCli(tools).catch(handleCliError);
|
|
337
|
+
} else {
|
|
338
|
+
let createUtilsServer = function() {
|
|
339
|
+
return createMcpServer({ name: "mono-rele2-utils", version: "1.0.0" }, [cnTool, caseConvertTool, truncateTool]);
|
|
340
|
+
};
|
|
341
|
+
createUtilsServer2 = createUtilsServer;
|
|
342
|
+
const server = createUtilsServer();
|
|
343
|
+
startServer(server).catch((err) => {
|
|
344
|
+
console.error("[utils] server error:", err);
|
|
345
|
+
process.exit(1);
|
|
346
|
+
});
|
|
294
347
|
}
|
|
295
|
-
var
|
|
296
|
-
startServer(server).catch((err) => {
|
|
297
|
-
console.error("[utils] server error:", err);
|
|
298
|
-
process.exit(1);
|
|
299
|
-
});
|
|
348
|
+
var createUtilsServer2;
|
|
300
349
|
export {
|
|
301
350
|
cn,
|
|
302
|
-
createUtilsServer,
|
|
303
351
|
generateReadmeSkills,
|
|
304
352
|
generateSkillMarkdown,
|
|
305
353
|
tools
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: mono-rele2-utils
|
|
2
|
+
name: mono-rele2-utils
|
|
3
3
|
description: Use this skill to invoke text utility functions via the mono-rele2-utils CLI. Handles class name merging, case conversion, and text truncation.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# mono-rele2-utils
|
|
6
|
+
# mono-rele2-utils
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
mono-rele2-utils
|
|
9
|
+
mono-rele2-utils <skillName> [...args]
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
## Skills
|
|
@@ -40,12 +40,12 @@ Truncates text to a maximum length and appends a suffix
|
|
|
40
40
|
|
|
41
41
|
## Examples
|
|
42
42
|
|
|
43
|
-
- `mono-rele2-utils
|
|
44
|
-
- `mono-rele2-utils
|
|
45
|
-
- `mono-rele2-utils
|
|
46
|
-
- `mono-rele2-utils
|
|
47
|
-
- `mono-rele2-utils
|
|
48
|
-
- `mono-rele2-utils
|
|
43
|
+
- `mono-rele2-utils cnTool '["btn","active","large"]'` => `btn active large`
|
|
44
|
+
- `mono-rele2-utils caseConvertTool "hello world" camel` => `helloWorld`
|
|
45
|
+
- `mono-rele2-utils caseConvertTool "helloWorld" snake` => `hello_world`
|
|
46
|
+
- `mono-rele2-utils caseConvertTool "hello world" kebab` => `hello-world`
|
|
47
|
+
- `mono-rele2-utils truncateTool "hello world long text" 10` => `hello w...`
|
|
48
|
+
- `mono-rele2-utils truncateTool "hello world" 8 "…"` => `hello w…`
|
|
49
49
|
|
|
50
50
|
## Guidelines
|
|
51
51
|
|
|
@@ -53,4 +53,4 @@ Truncates text to a maximum length and appends a suffix
|
|
|
53
53
|
- Numeric args are auto-parsed — pass as plain numbers (e.g. `10`)
|
|
54
54
|
- Array args must be valid JSON — wrap in single quotes on Unix shells (e.g. `'["a","b"]'`)
|
|
55
55
|
- Optional args with defaults may be omitted
|
|
56
|
-
- Run `mono-rele2-utils
|
|
56
|
+
- Run `mono-rele2-utils` with no args to list all available skills
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@julong/mono-rele2-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Use this skill to invoke text utility functions via the mono-rele2-utils CLI. Handles class name merging, case conversion, and text truncation.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"type": "module",
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"bin": {
|
|
14
|
-
"mono-rele2-utils": "./dist/
|
|
15
|
-
"mono-rele2-utils-cli": "./dist/cli.js"
|
|
14
|
+
"mono-rele2-utils": "./dist/index.js"
|
|
16
15
|
},
|
|
17
16
|
"files": [
|
|
18
17
|
"dist"
|
package/dist/cli.js
DELETED
|
@@ -1,147 +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
|
-
console.log(process.argv);
|
|
37
|
-
if (!toolName || !(toolName in tools2)) {
|
|
38
|
-
if (toolName) console.error(`Unknown skill: "${toolName}"
|
|
39
|
-
`);
|
|
40
|
-
console.log(formatSkills(tools2));
|
|
41
|
-
process.exit(toolName ? 1 : 0);
|
|
42
|
-
}
|
|
43
|
-
const tool = tools2[toolName];
|
|
44
|
-
const fieldNames = Object.keys(tool.inputSchema);
|
|
45
|
-
const rawInput = {};
|
|
46
|
-
for (let i = 0; i < fieldNames.length; i++) {
|
|
47
|
-
const raw = rawArgs[i];
|
|
48
|
-
if (raw === void 0) continue;
|
|
49
|
-
try {
|
|
50
|
-
rawInput[fieldNames[i]] = JSON.parse(raw);
|
|
51
|
-
} catch {
|
|
52
|
-
rawInput[fieldNames[i]] = raw;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const parsed = z.object(tool.inputSchema).parse(rawInput);
|
|
56
|
-
const result = await tool.handler(parsed);
|
|
57
|
-
for (const part of result.content) {
|
|
58
|
-
if (part.type === "text") console.log(part.text);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function handleCliError(err) {
|
|
62
|
-
if (err instanceof z.ZodError) {
|
|
63
|
-
console.error("Validation error:", err.issues.map((e) => `${e.path.join(".")}: ${e.message}`).join(", "));
|
|
64
|
-
} else {
|
|
65
|
-
console.error("Error:", err instanceof Error ? err.message : String(err));
|
|
66
|
-
}
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// ../common/kit/skill.ts
|
|
71
|
-
import { z as z2 } from "zod";
|
|
72
|
-
|
|
73
|
-
// src/tools/text.ts
|
|
74
|
-
import { z as z3 } from "zod";
|
|
75
|
-
|
|
76
|
-
// src/cn.ts
|
|
77
|
-
function cn(...classes) {
|
|
78
|
-
return classes.filter(Boolean).join(" ");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// src/tools/text.ts
|
|
82
|
-
var tools = {
|
|
83
|
-
cnTool: toolDef({
|
|
84
|
-
name: "cn",
|
|
85
|
-
description: "Merges class names, filtering out falsy values",
|
|
86
|
-
inputSchema: {
|
|
87
|
-
classes: z3.array(z3.string()).describe("List of class names to merge")
|
|
88
|
-
},
|
|
89
|
-
handler: async ({ classes }) => text(cn(...classes)),
|
|
90
|
-
examples: [
|
|
91
|
-
{ args: [`'["btn","active","large"]'`], result: "btn active large" }
|
|
92
|
-
]
|
|
93
|
-
}),
|
|
94
|
-
caseConvertTool: toolDef({
|
|
95
|
-
name: "case_convert",
|
|
96
|
-
description: "Converts text to the specified case format",
|
|
97
|
-
inputSchema: {
|
|
98
|
-
input: z3.string().describe("Text to convert"),
|
|
99
|
-
to: z3.enum(["upper", "lower", "capitalize", "camel", "snake", "kebab"]).describe("Target case format")
|
|
100
|
-
},
|
|
101
|
-
handler: async ({ input, to }) => text(convert(input, to)),
|
|
102
|
-
examples: [
|
|
103
|
-
{ args: [`"hello world"`, "camel"], result: "helloWorld" },
|
|
104
|
-
{ args: [`"helloWorld"`, "snake"], result: "hello_world" },
|
|
105
|
-
{ args: [`"hello world"`, "kebab"], result: "hello-world" }
|
|
106
|
-
]
|
|
107
|
-
}),
|
|
108
|
-
truncateTool: toolDef({
|
|
109
|
-
name: "truncate",
|
|
110
|
-
description: "Truncates text to a maximum length and appends a suffix",
|
|
111
|
-
inputSchema: {
|
|
112
|
-
input: z3.string().describe("Text to truncate"),
|
|
113
|
-
maxLength: z3.number().int().positive().describe("Maximum character length"),
|
|
114
|
-
suffix: z3.string().default("...").describe("Suffix to append when truncated")
|
|
115
|
-
},
|
|
116
|
-
handler: async ({ input, maxLength, suffix }) => {
|
|
117
|
-
const result = input.length <= maxLength ? input : input.slice(0, maxLength - suffix.length) + suffix;
|
|
118
|
-
return text(result);
|
|
119
|
-
},
|
|
120
|
-
examples: [
|
|
121
|
-
{ args: [`"hello world long text"`, "10"], result: "hello w..." },
|
|
122
|
-
{ args: [`"hello world"`, "8", `"\u2026"`], result: "hello w\u2026" }
|
|
123
|
-
]
|
|
124
|
-
})
|
|
125
|
-
};
|
|
126
|
-
var cnTool = defineTool(tools.cnTool);
|
|
127
|
-
var caseConvertTool = defineTool(tools.caseConvertTool);
|
|
128
|
-
var truncateTool = defineTool(tools.truncateTool);
|
|
129
|
-
function convert(input, to) {
|
|
130
|
-
switch (to) {
|
|
131
|
-
case "upper":
|
|
132
|
-
return input.toUpperCase();
|
|
133
|
-
case "lower":
|
|
134
|
-
return input.toLowerCase();
|
|
135
|
-
case "capitalize":
|
|
136
|
-
return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
|
|
137
|
-
case "camel":
|
|
138
|
-
return input.replace(/[-_\s]+(.)/g, (_, c) => c.toUpperCase()).replace(/^(.)/, (c) => c.toLowerCase());
|
|
139
|
-
case "snake":
|
|
140
|
-
return input.replace(/([A-Z])/g, "_$1").replace(/[-\s]+/g, "_").toLowerCase().replace(/^_/, "");
|
|
141
|
-
case "kebab":
|
|
142
|
-
return input.replace(/([A-Z])/g, "-$1").replace(/[_\s]+/g, "-").toLowerCase().replace(/^-/, "");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// src/cli.ts
|
|
147
|
-
runCli(tools).catch(handleCliError);
|
package/dist/server.js
DELETED
|
@@ -1,131 +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 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/text.ts
|
|
41
|
-
import { z as z3 } from "zod";
|
|
42
|
-
|
|
43
|
-
// src/cn.ts
|
|
44
|
-
function cn(...classes) {
|
|
45
|
-
return classes.filter(Boolean).join(" ");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// src/tools/text.ts
|
|
49
|
-
var tools = {
|
|
50
|
-
cnTool: toolDef({
|
|
51
|
-
name: "cn",
|
|
52
|
-
description: "Merges class names, filtering out falsy values",
|
|
53
|
-
inputSchema: {
|
|
54
|
-
classes: z3.array(z3.string()).describe("List of class names to merge")
|
|
55
|
-
},
|
|
56
|
-
handler: async ({ classes }) => text(cn(...classes)),
|
|
57
|
-
examples: [
|
|
58
|
-
{ args: [`'["btn","active","large"]'`], result: "btn active large" }
|
|
59
|
-
]
|
|
60
|
-
}),
|
|
61
|
-
caseConvertTool: toolDef({
|
|
62
|
-
name: "case_convert",
|
|
63
|
-
description: "Converts text to the specified case format",
|
|
64
|
-
inputSchema: {
|
|
65
|
-
input: z3.string().describe("Text to convert"),
|
|
66
|
-
to: z3.enum(["upper", "lower", "capitalize", "camel", "snake", "kebab"]).describe("Target case format")
|
|
67
|
-
},
|
|
68
|
-
handler: async ({ input, to }) => text(convert(input, to)),
|
|
69
|
-
examples: [
|
|
70
|
-
{ args: [`"hello world"`, "camel"], result: "helloWorld" },
|
|
71
|
-
{ args: [`"helloWorld"`, "snake"], result: "hello_world" },
|
|
72
|
-
{ args: [`"hello world"`, "kebab"], result: "hello-world" }
|
|
73
|
-
]
|
|
74
|
-
}),
|
|
75
|
-
truncateTool: toolDef({
|
|
76
|
-
name: "truncate",
|
|
77
|
-
description: "Truncates text to a maximum length and appends a suffix",
|
|
78
|
-
inputSchema: {
|
|
79
|
-
input: z3.string().describe("Text to truncate"),
|
|
80
|
-
maxLength: z3.number().int().positive().describe("Maximum character length"),
|
|
81
|
-
suffix: z3.string().default("...").describe("Suffix to append when truncated")
|
|
82
|
-
},
|
|
83
|
-
handler: async ({ input, maxLength, suffix }) => {
|
|
84
|
-
const result = input.length <= maxLength ? input : input.slice(0, maxLength - suffix.length) + suffix;
|
|
85
|
-
return text(result);
|
|
86
|
-
},
|
|
87
|
-
examples: [
|
|
88
|
-
{ args: [`"hello world long text"`, "10"], result: "hello w..." },
|
|
89
|
-
{ args: [`"hello world"`, "8", `"\u2026"`], result: "hello w\u2026" }
|
|
90
|
-
]
|
|
91
|
-
})
|
|
92
|
-
};
|
|
93
|
-
var cnTool = defineTool(tools.cnTool);
|
|
94
|
-
var caseConvertTool = defineTool(tools.caseConvertTool);
|
|
95
|
-
var truncateTool = defineTool(tools.truncateTool);
|
|
96
|
-
function convert(input, to) {
|
|
97
|
-
switch (to) {
|
|
98
|
-
case "upper":
|
|
99
|
-
return input.toUpperCase();
|
|
100
|
-
case "lower":
|
|
101
|
-
return input.toLowerCase();
|
|
102
|
-
case "capitalize":
|
|
103
|
-
return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
|
|
104
|
-
case "camel":
|
|
105
|
-
return input.replace(/[-_\s]+(.)/g, (_, c) => c.toUpperCase()).replace(/^(.)/, (c) => c.toLowerCase());
|
|
106
|
-
case "snake":
|
|
107
|
-
return input.replace(/([A-Z])/g, "_$1").replace(/[-\s]+/g, "_").toLowerCase().replace(/^_/, "");
|
|
108
|
-
case "kebab":
|
|
109
|
-
return input.replace(/([A-Z])/g, "-$1").replace(/[_\s]+/g, "-").toLowerCase().replace(/^-/, "");
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// src/index.ts
|
|
114
|
-
function createUtilsServer() {
|
|
115
|
-
return createMcpServer(
|
|
116
|
-
{ name: "mono-rele2-utils", version: "1.0.0" },
|
|
117
|
-
[cnTool, caseConvertTool, truncateTool]
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
var server = createUtilsServer();
|
|
121
|
-
startServer(server).catch((err) => {
|
|
122
|
-
console.error("[utils] server error:", err);
|
|
123
|
-
process.exit(1);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// src/server.ts
|
|
127
|
-
var server2 = createUtilsServer();
|
|
128
|
-
startServer(server2).catch((err) => {
|
|
129
|
-
console.error("[utils] server error:", err);
|
|
130
|
-
process.exit(1);
|
|
131
|
-
});
|