it-tools-mcp 3.0.24 → 3.1.1
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/README.dockerhub.md +23 -18
- package/README.md +77 -34
- package/build/index.js +51 -24
- package/build/tools/ansible/ansible-inventory-generator/index.js +212 -0
- package/build/tools/ansible/ansible-playbook-validator/index.js +128 -0
- package/build/tools/ansible/ansible-reference/index.js +393 -0
- package/build/tools/ansible/ansible-vault-decrypt/index.js +137 -0
- package/build/tools/ansible/ansible-vault-encrypt/index.js +79 -0
- package/build/tools/color/color-hex-to-rgb/index.js +29 -0
- package/build/tools/{color.js → color/color-rgb-to-hex/index.js} +1 -27
- package/build/tools/crypto/basic-auth-generator/index.js +45 -0
- package/build/tools/crypto/bcrypt-hash/index.js +67 -0
- package/build/tools/crypto/bip39-generate/index.js +53 -0
- package/build/tools/crypto/hash-md5/index.js +19 -0
- package/build/tools/crypto/hash-sha1/index.js +19 -0
- package/build/tools/crypto/hash-sha256/index.js +19 -0
- package/build/tools/crypto/hash-sha512/index.js +19 -0
- package/build/tools/crypto/hmac-generator/index.js +37 -0
- package/build/tools/crypto/jwt-decode/index.js +41 -0
- package/build/tools/crypto/otp-code-generator/index.js +67 -0
- package/build/tools/crypto/password-generate/index.js +54 -0
- package/build/tools/crypto/token-generator/index.js +75 -0
- package/build/tools/dataFormat/html-to-markdown/index.js +34 -0
- package/build/tools/dataFormat/json-diff/index.js +94 -0
- package/build/tools/dataFormat/json-format/index.js +100 -0
- package/build/tools/dataFormat/json-minify/index.js +29 -0
- package/build/tools/dataFormat/json-to-csv/index.js +34 -0
- package/build/tools/dataFormat/json-to-toml/index.js +30 -0
- package/build/tools/dataFormat/markdown-to-html/index.js +32 -0
- package/build/tools/dataFormat/phone-format/index.js +35 -0
- package/build/tools/dataFormat/sql-format/index.js +37 -0
- package/build/tools/dataFormat/toml-to-json/index.js +29 -0
- package/build/tools/dataFormat/xml-format/index.js +44 -0
- package/build/tools/dataFormat/yaml-format/index.js +58 -0
- package/build/tools/{development.js → development/crontab-generate/index.js} +1 -129
- package/build/tools/development/html-prettifier/index.js +47 -0
- package/build/tools/development/javascript-prettifier/index.js +74 -0
- package/build/tools/development/list-converter/index.js +62 -0
- package/build/tools/development/markdown-toc-generator/index.js +53 -0
- package/build/tools/development/regex-tester/index.js +69 -0
- package/build/tools/docker/docker-compose-to-docker-run/index.js +138 -0
- package/build/tools/docker/docker-compose-validator/index.js +125 -0
- package/build/tools/docker/docker-reference/index.js +188 -0
- package/build/tools/docker/docker-run-to-docker-compose/index.js +117 -0
- package/build/tools/docker/traefik-compose-generator/index.js +98 -0
- package/build/tools/encoding/base64-decode/index.js +28 -0
- package/build/tools/encoding/base64-encode/index.js +16 -0
- package/build/tools/encoding/html-decode/index.js +21 -0
- package/build/tools/encoding/html-encode/index.js +21 -0
- package/build/tools/encoding/html-entities-extended/index.js +72 -0
- package/build/tools/encoding/text-to-binary/index.js +51 -0
- package/build/tools/encoding/url-decode/index.js +28 -0
- package/build/tools/encoding/url-encode/index.js +16 -0
- package/build/tools/forensic/file-type-identifier/index.js +90 -0
- package/build/tools/forensic/safelink-decoder/index.js +54 -0
- package/build/tools/forensic/url-fanger/index.js +52 -0
- package/build/tools/idGenerators/qr-generate/index.js +76 -0
- package/build/tools/idGenerators/svg-placeholder-generator/index.js +59 -0
- package/build/tools/idGenerators/ulid-generate/index.js +34 -0
- package/build/tools/idGenerators/uuid-generate/index.js +14 -0
- package/build/tools/math/math-evaluate/index.js +33 -0
- package/build/tools/math/number-base-converter/index.js +46 -0
- package/build/tools/math/percentage-calculator/index.js +50 -0
- package/build/tools/math/roman-numeral-converter/index.js +76 -0
- package/build/tools/math/temperature-converter/index.js +59 -0
- package/build/tools/math/unix-timestamp-converter/index.js +55 -0
- package/build/tools/network/cat/index.js +15 -0
- package/build/tools/network/cidr-to-ip-range/index.js +108 -0
- package/build/tools/network/curl/index.js +35 -0
- package/build/tools/network/dig/index.js +19 -0
- package/build/tools/network/grep/index.js +18 -0
- package/build/tools/network/head/index.js +17 -0
- package/build/tools/network/iban-validate/index.js +83 -0
- package/build/tools/network/ip-range-to-cidr/index.js +88 -0
- package/build/tools/network/ip-subnet-calculator/index.js +102 -0
- package/build/tools/network/ipv4-subnet-calc/index.js +112 -0
- package/build/tools/network/ipv6-subnet-calculator/index.js +104 -0
- package/build/tools/network/ipv6-ula-generator/index.js +65 -0
- package/build/tools/network/mac-address-generate/index.js +68 -0
- package/build/tools/network/nslookup/index.js +18 -0
- package/build/tools/network/ping/index.js +20 -0
- package/build/tools/network/ps/index.js +22 -0
- package/build/tools/network/random-port/index.js +53 -0
- package/build/tools/network/scp/index.js +134 -0
- package/build/tools/network/ssh/index.js +83 -0
- package/build/tools/network/tail/index.js +16 -0
- package/build/tools/network/telnet/index.js +45 -0
- package/build/tools/network/top/index.js +14 -0
- package/build/tools/network/url-parse/index.js +52 -0
- package/build/tools/physics/angle-converter/index.js +73 -0
- package/build/tools/physics/energy-converter/index.js +72 -0
- package/build/tools/physics/power-converter/index.js +71 -0
- package/build/tools/text/ascii-art-text/index.js +112 -0
- package/build/tools/text/distinct-words/index.js +30 -0
- package/build/tools/text/emoji-search/index.js +76 -0
- package/build/tools/text/lorem-ipsum-generator/index.js +87 -0
- package/build/tools/text/numeronym-generator/index.js +37 -0
- package/build/tools/text/slugify-string/index.js +44 -0
- package/build/tools/text/string-obfuscator/index.js +49 -0
- package/build/tools/text/text-camelcase/index.js +20 -0
- package/build/tools/text/text-capitalize/index.js +16 -0
- package/build/tools/text/text-diff/index.js +72 -0
- package/build/tools/text/text-kebabcase/index.js +20 -0
- package/build/tools/text/text-lowercase/index.js +15 -0
- package/build/tools/text/text-pascalcase/index.js +18 -0
- package/build/tools/text/text-snakecase/index.js +20 -0
- package/build/tools/text/text-stats/index.js +29 -0
- package/build/tools/text/text-to-nato-alphabet/index.js +57 -0
- package/build/tools/text/text-to-unicode/index.js +50 -0
- package/build/tools/text/text-to-unicode-names/index.js +34 -0
- package/build/tools/text/text-uppercase/index.js +15 -0
- package/build/tools/utility/css-prettifier/index.js +70 -0
- package/build/tools/utility/device-info/index.js +44 -0
- package/build/tools/utility/email-normalizer/index.js +73 -0
- package/build/tools/utility/http-status-codes/index.js +173 -0
- package/build/tools/utility/mime-types/index.js +121 -0
- package/build/tools/utility/port-numbers/index.js +106 -0
- package/build/tools/utility/rem-px-converter/index.js +63 -0
- package/package.json +3 -3
- package/build/tools/crypto.js +0 -445
- package/build/tools/dataFormat.js +0 -535
- package/build/tools/encoding.js +0 -240
- package/build/tools/idGenerators.js +0 -180
- package/build/tools/math.js +0 -310
- package/build/tools/network.js +0 -939
- package/build/tools/text.js +0 -678
- package/build/tools/utility.js +0 -407
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerJsonFormat(server) {
|
|
3
|
+
server.tool("json-format", "Format and validate JSON", {
|
|
4
|
+
json: z.string().describe("JSON string to format"),
|
|
5
|
+
indent: z.number().describe("Number of spaces for indentation").optional(),
|
|
6
|
+
}, async ({ json, indent = 2 }) => {
|
|
7
|
+
try {
|
|
8
|
+
if (indent < 0 || indent > 10) {
|
|
9
|
+
return {
|
|
10
|
+
content: [
|
|
11
|
+
{
|
|
12
|
+
type: "text",
|
|
13
|
+
text: "Indent must be between 0 and 10.",
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// Try to normalize JavaScript-style object notation to valid JSON
|
|
19
|
+
let normalizedJson = json.trim();
|
|
20
|
+
// Handle single quotes by converting to double quotes
|
|
21
|
+
// This is a simplified approach that works for most common cases
|
|
22
|
+
try {
|
|
23
|
+
// First try parsing as-is
|
|
24
|
+
const parsed = JSON.parse(normalizedJson);
|
|
25
|
+
const formatted = JSON.stringify(parsed, null, indent);
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: "text",
|
|
30
|
+
text: `Formatted JSON:\n${formatted}`,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (firstError) {
|
|
36
|
+
// If parsing fails, try to normalize the format
|
|
37
|
+
try {
|
|
38
|
+
// Convert single quotes to double quotes for property names and string values
|
|
39
|
+
// This handles simple cases like {'name':'John','age':30}
|
|
40
|
+
normalizedJson = normalizedJson
|
|
41
|
+
.replace(/'/g, '"') // Replace single quotes with double quotes
|
|
42
|
+
.replace(/([{,]\s*)([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:/g, '$1"$2":'); // Quote unquoted property names
|
|
43
|
+
const parsed = JSON.parse(normalizedJson);
|
|
44
|
+
const formatted = JSON.stringify(parsed, null, indent);
|
|
45
|
+
return {
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: "text",
|
|
49
|
+
text: `Formatted JSON (normalized from JavaScript object notation):\n${formatted}`,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (secondError) {
|
|
55
|
+
// If normalization fails, try using Function constructor for JavaScript object literals
|
|
56
|
+
try {
|
|
57
|
+
const evaluated = new Function('return ' + json)();
|
|
58
|
+
const formatted = JSON.stringify(evaluated, null, indent);
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: "text",
|
|
63
|
+
text: `Formatted JSON (converted from JavaScript object):\n${formatted}`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (evalError) {
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: "text",
|
|
73
|
+
text: `Error parsing JSON: ${firstError instanceof Error ? firstError.message : 'Unknown error'}
|
|
74
|
+
|
|
75
|
+
Tried to normalize JavaScript object notation but failed.
|
|
76
|
+
Please ensure your input is valid JSON or JavaScript object notation.
|
|
77
|
+
|
|
78
|
+
Examples of supported formats:
|
|
79
|
+
- Valid JSON: {"name":"John","age":30}
|
|
80
|
+
- JavaScript object: {'name':'John','age':30}
|
|
81
|
+
- Unquoted keys: {name:'John',age:30}`,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return {
|
|
91
|
+
content: [
|
|
92
|
+
{
|
|
93
|
+
type: "text",
|
|
94
|
+
text: `Error formatting JSON: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerJsonMinify(server) {
|
|
3
|
+
server.tool("json-minify", "Minify JSON by removing whitespace", {
|
|
4
|
+
json: z.string().describe("JSON string to minify"),
|
|
5
|
+
}, async ({ json }) => {
|
|
6
|
+
try {
|
|
7
|
+
const parsed = JSON.parse(json);
|
|
8
|
+
const minified = JSON.stringify(parsed);
|
|
9
|
+
return {
|
|
10
|
+
content: [
|
|
11
|
+
{
|
|
12
|
+
type: "text",
|
|
13
|
+
text: `Minified JSON: ${minified}`,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return {
|
|
20
|
+
content: [
|
|
21
|
+
{
|
|
22
|
+
type: "text",
|
|
23
|
+
text: `Error parsing JSON: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerJsonToCsv(server) {
|
|
3
|
+
server.tool("json-to-csv", "Convert JSON to CSV format", {
|
|
4
|
+
json: z.string().describe("JSON string to convert to CSV"),
|
|
5
|
+
delimiter: z.string().describe("CSV delimiter").optional(),
|
|
6
|
+
}, async ({ json, delimiter = "," }) => {
|
|
7
|
+
try {
|
|
8
|
+
const Papa = (await import("papaparse")).default;
|
|
9
|
+
const data = JSON.parse(json);
|
|
10
|
+
if (!Array.isArray(data)) {
|
|
11
|
+
throw new Error("JSON must be an array of objects");
|
|
12
|
+
}
|
|
13
|
+
const csv = Papa.unparse(data, { delimiter });
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
{
|
|
17
|
+
type: "text",
|
|
18
|
+
text: `CSV:\n${csv}\n\nConversion Summary:\nRows: ${data.length}\nDelimiter: \"${delimiter}\"`,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return {
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: "text",
|
|
28
|
+
text: `Error converting JSON to CSV: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerJsonToToml(server) {
|
|
3
|
+
server.tool("json-to-toml", "Convert JSON to TOML format", {
|
|
4
|
+
json: z.string().describe("JSON string to convert"),
|
|
5
|
+
}, async ({ json }) => {
|
|
6
|
+
try {
|
|
7
|
+
const toml = await import("@iarna/toml");
|
|
8
|
+
const data = JSON.parse(json);
|
|
9
|
+
const tomlResult = toml.stringify(data);
|
|
10
|
+
return {
|
|
11
|
+
content: [
|
|
12
|
+
{
|
|
13
|
+
type: "text",
|
|
14
|
+
text: `TOML result:\n${tomlResult}`,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return {
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: "text",
|
|
24
|
+
text: `Error converting JSON to TOML: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerMarkdownToHtml(server) {
|
|
3
|
+
server.tool("markdown-to-html", "Convert Markdown to HTML", {
|
|
4
|
+
markdown: z.string().describe("Markdown content to convert to HTML"),
|
|
5
|
+
}, async ({ markdown }) => {
|
|
6
|
+
try {
|
|
7
|
+
const { marked } = await import("marked");
|
|
8
|
+
const html = marked(markdown, {
|
|
9
|
+
breaks: true,
|
|
10
|
+
gfm: true
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
content: [
|
|
14
|
+
{
|
|
15
|
+
type: "text",
|
|
16
|
+
text: `HTML result:\n${html}`,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: "text",
|
|
26
|
+
text: `Error converting Markdown to HTML: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerPhoneFormat(server) {
|
|
3
|
+
server.tool("phone-format", "Parse and format phone numbers", {
|
|
4
|
+
phoneNumber: z.string().describe("Phone number to parse and format"),
|
|
5
|
+
countryCode: z.string().optional().describe("Country code (e.g., 'US', 'GB', 'FR')"),
|
|
6
|
+
}, async ({ phoneNumber, countryCode }) => {
|
|
7
|
+
try {
|
|
8
|
+
const { isValidPhoneNumber, parsePhoneNumber } = await import("libphonenumber-js");
|
|
9
|
+
// First check if it's a valid phone number
|
|
10
|
+
if (!isValidPhoneNumber(phoneNumber, countryCode)) {
|
|
11
|
+
throw new Error("Invalid phone number format");
|
|
12
|
+
}
|
|
13
|
+
// Parse the phone number
|
|
14
|
+
const parsedNumber = parsePhoneNumber(phoneNumber, countryCode);
|
|
15
|
+
return {
|
|
16
|
+
content: [
|
|
17
|
+
{
|
|
18
|
+
type: "text",
|
|
19
|
+
text: `Phone Number Formatting:\n\nOriginal: ${phoneNumber}\nCountry: ${parsedNumber.country || 'Unknown'}\nNational: ${parsedNumber.formatNational()}\nInternational: ${parsedNumber.formatInternational()}\nE.164: ${parsedNumber.format('E.164')}\nURI: ${parsedNumber.getURI()}\n\nDetails:\nType: ${parsedNumber.getType() || 'Unknown'}\nCountry Code: +${parsedNumber.countryCallingCode}\nNational Number: ${parsedNumber.nationalNumber}\nValid: ${parsedNumber.isValid()}\n\n✅ Formatted using libphonenumber-js library for accuracy.`,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: "text",
|
|
29
|
+
text: `Error formatting phone number: ${error instanceof Error ? error.message : 'Unknown error'}\n\n💡 Tips:\n• Include country code (e.g., +1 555-123-4567)\n• Use standard formats (e.g., (555) 123-4567)\n• Specify country code parameter if needed\n• Examples: "+1-555-123-4567", "555-123-4567" with countryCode="US"`,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerSqlFormat(server) {
|
|
3
|
+
server.tool("sql-format", "Format and prettify SQL queries", {
|
|
4
|
+
sql: z.string().describe("SQL query to format"),
|
|
5
|
+
dialect: z.string().optional().describe("SQL dialect to use for formatting (e.g., 'sql', 'mysql', 'postgresql', 'sqlite', 'mariadb', 'db2', 'plsql', 'n1ql', 'redshift', 'spark', 'tsql', 'trino', 'bigquery'). Default is 'sql'."),
|
|
6
|
+
}, async ({ sql, dialect = "sql" }) => {
|
|
7
|
+
try {
|
|
8
|
+
const { format: formatSQL } = await import("sql-formatter");
|
|
9
|
+
// Validate dialect and cast to correct type
|
|
10
|
+
const supportedDialects = [
|
|
11
|
+
"sql", "mysql", "postgresql", "sqlite", "mariadb", "db2", "plsql", "n1ql", "redshift", "spark", "tsql", "trino", "bigquery"
|
|
12
|
+
];
|
|
13
|
+
const language = supportedDialects.includes(dialect) ? dialect : "sql";
|
|
14
|
+
const formatted = formatSQL(sql, {
|
|
15
|
+
language
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
type: "text",
|
|
21
|
+
text: `Formatted SQL (dialect: ${language}):\n\n${formatted}\n\n✅ SQL formatted successfully\n🎯 Features: uppercase keywords, proper indentation, clean structure`,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: "text",
|
|
31
|
+
text: `Error formatting SQL: ${error instanceof Error ? error.message : 'Unknown error'}\n\n💡 Common SQL issues:\n• Check syntax for missing semicolons\n• Ensure proper table and column names\n• Validate string quoting (single quotes for strings)\n• Check for balanced parentheses in subqueries`,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerTomlToJson(server) {
|
|
3
|
+
server.tool("toml-to-json", "Convert TOML to JSON format", {
|
|
4
|
+
toml: z.string().describe("TOML string to convert"),
|
|
5
|
+
}, async ({ toml: tomlString }) => {
|
|
6
|
+
try {
|
|
7
|
+
const toml = await import("@iarna/toml");
|
|
8
|
+
const result = toml.parse(tomlString);
|
|
9
|
+
return {
|
|
10
|
+
content: [
|
|
11
|
+
{
|
|
12
|
+
type: "text",
|
|
13
|
+
text: `JSON result:\n${JSON.stringify(result, null, 2)}`,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return {
|
|
20
|
+
content: [
|
|
21
|
+
{
|
|
22
|
+
type: "text",
|
|
23
|
+
text: `Error converting TOML to JSON: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerXmlFormat(server) {
|
|
3
|
+
server.tool("xml-format", "Format and prettify XML", {
|
|
4
|
+
xml: z.string().describe("XML string to format"),
|
|
5
|
+
indent: z.number().describe("Number of spaces for indentation").optional(),
|
|
6
|
+
}, async ({ xml, indent = 2 }) => {
|
|
7
|
+
try {
|
|
8
|
+
const formatXML = (await import("xml-formatter")).default;
|
|
9
|
+
const formatted = formatXML(xml, {
|
|
10
|
+
indentation: ' '.repeat(indent),
|
|
11
|
+
collapseContent: true,
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
content: [
|
|
15
|
+
{
|
|
16
|
+
type: "text",
|
|
17
|
+
text: `Formatted XML:
|
|
18
|
+
|
|
19
|
+
${formatted}
|
|
20
|
+
|
|
21
|
+
✅ XML formatted successfully
|
|
22
|
+
🎯 Features: ${indent}-space indentation, collapsed content, clean structure`,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return {
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: `Error formatting XML: ${error instanceof Error ? error.message : 'Unknown error'}
|
|
33
|
+
|
|
34
|
+
💡 Common XML issues:
|
|
35
|
+
• Check that all tags are properly closed
|
|
36
|
+
• Ensure proper nesting of elements
|
|
37
|
+
• Validate attribute syntax (key="value")
|
|
38
|
+
• Check for special character encoding`,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerYamlFormat(server) {
|
|
3
|
+
server.tool("yaml-format", "Format and prettify YAML", {
|
|
4
|
+
yaml: z.string().describe("YAML string to format"),
|
|
5
|
+
}, async ({ yaml }) => {
|
|
6
|
+
try {
|
|
7
|
+
const YAML = await import("js-yaml");
|
|
8
|
+
// Parse YAML to validate and then dump with proper formatting
|
|
9
|
+
const parsed = YAML.load(yaml);
|
|
10
|
+
// Format with proper indentation and options
|
|
11
|
+
const formatted = YAML.dump(parsed, {
|
|
12
|
+
indent: 2,
|
|
13
|
+
lineWidth: 80,
|
|
14
|
+
noRefs: false,
|
|
15
|
+
noCompatMode: false,
|
|
16
|
+
condenseFlow: false,
|
|
17
|
+
quotingType: '"',
|
|
18
|
+
forceQuotes: false,
|
|
19
|
+
sortKeys: false,
|
|
20
|
+
skipInvalid: false,
|
|
21
|
+
});
|
|
22
|
+
// Count lines and detect any issues
|
|
23
|
+
const inputLines = yaml.split('\n').length;
|
|
24
|
+
const outputLines = formatted.split('\n').length;
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: "text",
|
|
29
|
+
text: `Formatted YAML:
|
|
30
|
+
|
|
31
|
+
${formatted.trim()}
|
|
32
|
+
|
|
33
|
+
✅ YAML is valid and properly formatted
|
|
34
|
+
📊 Input: ${inputLines} lines → Output: ${outputLines} lines
|
|
35
|
+
🎯 Features: 2-space indentation, proper line width, preserved structure`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: "text",
|
|
45
|
+
text: `Error formatting YAML: ${error instanceof Error ? error.message : 'Unknown error'}
|
|
46
|
+
|
|
47
|
+
💡 Common YAML issues:
|
|
48
|
+
• Check indentation (use spaces, not tabs)
|
|
49
|
+
• Ensure proper key-value syntax (key: value)
|
|
50
|
+
• Validate string quoting
|
|
51
|
+
• Check list formatting (- item)
|
|
52
|
+
• Verify nested structure alignment`,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -1,74 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { CronExpressionParser } from 'cron-parser';
|
|
3
|
-
export function
|
|
4
|
-
// Regex tester
|
|
5
|
-
server.tool("regex-tester", "Test regular expressions against text", {
|
|
6
|
-
pattern: z.string().describe("Regular expression pattern"),
|
|
7
|
-
text: z.string().describe("Text to test against the regex"),
|
|
8
|
-
flags: z.string().optional().describe("Regex flags (g, i, m, s, u, y)"),
|
|
9
|
-
}, async ({ pattern, text, flags }) => {
|
|
10
|
-
try {
|
|
11
|
-
const regex = new RegExp(pattern, flags);
|
|
12
|
-
const matches = text.match(regex);
|
|
13
|
-
const globalMatches = flags?.includes('g') ? [...text.matchAll(new RegExp(pattern, flags))] : null;
|
|
14
|
-
const isMatch = regex.test(text);
|
|
15
|
-
let result = `Regex Test Results:
|
|
16
|
-
|
|
17
|
-
Pattern: ${pattern}
|
|
18
|
-
Flags: ${flags || 'none'}
|
|
19
|
-
Text: ${text}
|
|
20
|
-
|
|
21
|
-
Match: ${isMatch ? '✅ Yes' : '❌ No'}`;
|
|
22
|
-
if (matches) {
|
|
23
|
-
result += `\n\nFirst Match: ${matches[0]}`;
|
|
24
|
-
if (matches.length > 1) {
|
|
25
|
-
result += `\nCapture Groups: ${matches.slice(1).join(', ')}`;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (globalMatches && globalMatches.length > 0) {
|
|
29
|
-
result += `\n\nAll Matches (${globalMatches.length}):`;
|
|
30
|
-
globalMatches.forEach((match, index) => {
|
|
31
|
-
result += `\n${index + 1}. "${match[0]}" at position ${match.index}`;
|
|
32
|
-
if (match.length > 1) {
|
|
33
|
-
result += ` (groups: ${match.slice(1).join(', ')})`;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
result += `\n\nCommon Regex Patterns:
|
|
38
|
-
• Email: ^[\\w\\.-]+@[\\w\\.-]+\\.[a-zA-Z]{2,}$
|
|
39
|
-
• Phone: ^\\+?[1-9]\\d{1,14}$
|
|
40
|
-
• URL: ^https?:\\/\\/.+
|
|
41
|
-
• IPv4: ^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$
|
|
42
|
-
• Date (YYYY-MM-DD): ^\\d{4}-\\d{2}-\\d{2}$`;
|
|
43
|
-
return {
|
|
44
|
-
content: [
|
|
45
|
-
{
|
|
46
|
-
type: "text",
|
|
47
|
-
text: result,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
return {
|
|
54
|
-
content: [
|
|
55
|
-
{
|
|
56
|
-
type: "text",
|
|
57
|
-
text: `Error testing regex: ${error instanceof Error ? error.message : 'Unknown error'}
|
|
58
|
-
|
|
59
|
-
Common regex flags:
|
|
60
|
-
• g - Global (find all matches)
|
|
61
|
-
• i - Case insensitive
|
|
62
|
-
• m - Multiline
|
|
63
|
-
• s - Dot matches newline
|
|
64
|
-
• u - Unicode
|
|
65
|
-
• y - Sticky`,
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
// Crontab generator
|
|
3
|
+
export function registerCrontabGenerate(server) {
|
|
72
4
|
server.tool("crontab-generate", "Generate crontab expressions", {
|
|
73
5
|
minute: z.string().describe("Minute (0-59, *, */n, n-m)").optional(),
|
|
74
6
|
hour: z.string().describe("Hour (0-23, *, */n, n-m)").optional(),
|
|
@@ -204,64 +136,4 @@ Note: Use 'crontab -e' to edit your crontab file.`,
|
|
|
204
136
|
};
|
|
205
137
|
}
|
|
206
138
|
});
|
|
207
|
-
// List converter
|
|
208
|
-
server.tool("list-converter", "Convert between different list formats (comma-separated, line-separated, etc.)", {
|
|
209
|
-
list: z.string().describe("Input list to convert"),
|
|
210
|
-
inputFormat: z.enum(["comma", "semicolon", "newline", "space", "pipe"]).describe("Input format"),
|
|
211
|
-
outputFormat: z.enum(["comma", "semicolon", "newline", "space", "pipe", "json", "quoted"]).describe("Output format"),
|
|
212
|
-
trim: z.boolean().describe("Trim whitespace from items").optional(),
|
|
213
|
-
}, async ({ list, inputFormat, outputFormat, trim = true }) => {
|
|
214
|
-
try {
|
|
215
|
-
const separators = {
|
|
216
|
-
comma: ',',
|
|
217
|
-
semicolon: ';',
|
|
218
|
-
newline: '\n',
|
|
219
|
-
space: ' ',
|
|
220
|
-
pipe: '|'
|
|
221
|
-
};
|
|
222
|
-
// Parse input list
|
|
223
|
-
const inputSeparator = separators[inputFormat];
|
|
224
|
-
let items = list.split(inputSeparator);
|
|
225
|
-
if (trim) {
|
|
226
|
-
items = items.map(item => item.trim()).filter(item => item.length > 0);
|
|
227
|
-
}
|
|
228
|
-
// Convert to output format
|
|
229
|
-
let result = '';
|
|
230
|
-
switch (outputFormat) {
|
|
231
|
-
case 'json':
|
|
232
|
-
result = JSON.stringify(items, null, 2);
|
|
233
|
-
break;
|
|
234
|
-
case 'quoted':
|
|
235
|
-
result = items.map(item => `"${item.replace(/"/g, '\\"')}"`).join(', ');
|
|
236
|
-
break;
|
|
237
|
-
default:
|
|
238
|
-
const outputSeparator = separators[outputFormat];
|
|
239
|
-
result = items.join(outputSeparator);
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
content: [
|
|
244
|
-
{
|
|
245
|
-
type: "text",
|
|
246
|
-
text: `Converted list:
|
|
247
|
-
${result}
|
|
248
|
-
|
|
249
|
-
Items count: ${items.length}
|
|
250
|
-
Input format: ${inputFormat}
|
|
251
|
-
Output format: ${outputFormat}`,
|
|
252
|
-
},
|
|
253
|
-
],
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
catch (error) {
|
|
257
|
-
return {
|
|
258
|
-
content: [
|
|
259
|
-
{
|
|
260
|
-
type: "text",
|
|
261
|
-
text: `Error converting list: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
262
|
-
},
|
|
263
|
-
],
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
139
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerHtmlPrettifier(server) {
|
|
3
|
+
server.tool("html-prettifier", "Format and beautify HTML code", {
|
|
4
|
+
html: z.string().describe("HTML code to prettify"),
|
|
5
|
+
indentSize: z.number().optional().default(2).describe("Number of spaces for indentation")
|
|
6
|
+
}, async ({ html, indentSize }) => {
|
|
7
|
+
try {
|
|
8
|
+
// Simple HTML prettifier
|
|
9
|
+
let formatted = html;
|
|
10
|
+
let indentLevel = 0;
|
|
11
|
+
const indent = ' '.repeat(indentSize);
|
|
12
|
+
// Remove extra whitespace
|
|
13
|
+
formatted = formatted.replace(/>\s*</g, '><');
|
|
14
|
+
// Add line breaks and indentation
|
|
15
|
+
formatted = formatted.replace(/(<\/?[^>]+>)/g, (match) => {
|
|
16
|
+
if (match.startsWith('</') && !match.includes('/>')) {
|
|
17
|
+
indentLevel--;
|
|
18
|
+
}
|
|
19
|
+
const result = '\n' + indent.repeat(indentLevel) + match;
|
|
20
|
+
if (!match.startsWith('</') && !match.includes('/>') && !match.includes('<input') && !match.includes('<img') && !match.includes('<br') && !match.includes('<hr')) {
|
|
21
|
+
indentLevel++;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
});
|
|
25
|
+
// Clean up
|
|
26
|
+
formatted = formatted.trim();
|
|
27
|
+
return {
|
|
28
|
+
content: [{
|
|
29
|
+
type: "text",
|
|
30
|
+
text: `Prettified HTML:
|
|
31
|
+
|
|
32
|
+
\`\`\`html
|
|
33
|
+
${formatted}
|
|
34
|
+
\`\`\``
|
|
35
|
+
}]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
content: [{
|
|
41
|
+
type: "text",
|
|
42
|
+
text: `Error formatting HTML: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
43
|
+
}]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|