@intlayer/mcp 7.2.0 → 7.2.3
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/cjs/_virtual/rolldown_runtime.cjs +10 -6
- package/dist/cjs/tools/cli.cjs +115 -64
- package/dist/cjs/tools/cli.cjs.map +1 -1
- package/dist/cjs/tools/docs.cjs +14 -6
- package/dist/cjs/tools/docs.cjs.map +1 -1
- package/dist/esm/tools/cli.mjs +116 -65
- package/dist/esm/tools/cli.mjs.map +1 -1
- package/dist/esm/tools/docs.mjs +14 -6
- package/dist/esm/tools/docs.mjs.map +1 -1
- package/dist/types/tools/cli.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
return to;
|
|
17
21
|
};
|
package/dist/cjs/tools/cli.cjs
CHANGED
|
@@ -6,13 +6,16 @@ zod_v3 = require_rolldown_runtime.__toESM(zod_v3);
|
|
|
6
6
|
|
|
7
7
|
//#region src/tools/cli.ts
|
|
8
8
|
const loadCLITools = async (server) => {
|
|
9
|
-
server.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
server.registerTool("intlayer-build", {
|
|
10
|
+
description: "Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
watch: zod_v3.default.boolean().optional().describe("Watch for changes"),
|
|
13
|
+
baseDir: zod_v3.default.string().optional().describe("Base directory"),
|
|
14
|
+
env: zod_v3.default.string().optional().describe("Environment"),
|
|
15
|
+
envFile: zod_v3.default.string().optional().describe("Environment file"),
|
|
16
|
+
verbose: zod_v3.default.boolean().optional().describe("Verbose output"),
|
|
17
|
+
prefix: zod_v3.default.string().optional().describe("Log prefix")
|
|
18
|
+
}
|
|
16
19
|
}, async ({ watch, baseDir, env, envFile, verbose, prefix }) => {
|
|
17
20
|
try {
|
|
18
21
|
const log = {};
|
|
@@ -38,30 +41,33 @@ const loadCLITools = async (server) => {
|
|
|
38
41
|
}] };
|
|
39
42
|
}
|
|
40
43
|
});
|
|
41
|
-
server.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
server.registerTool("intlayer-fill", {
|
|
45
|
+
description: "Fill the dictionaries with missing translations / review translations using Intlayer servers",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
sourceLocale: zod_v3.default.nativeEnum(__intlayer_types.Locales.ALL_LOCALES).optional().describe("Source locale"),
|
|
48
|
+
outputLocales: zod_v3.default.union([zod_v3.default.nativeEnum(__intlayer_types.Locales.ALL_LOCALES), zod_v3.default.array(zod_v3.default.nativeEnum(__intlayer_types.Locales.ALL_LOCALES))]).optional().describe("Output locales"),
|
|
49
|
+
file: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("File path"),
|
|
50
|
+
mode: zod_v3.default.enum(["complete", "review"]).optional().describe("Fill mode"),
|
|
51
|
+
keys: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("Keys to include"),
|
|
52
|
+
excludedKeys: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("Keys to exclude"),
|
|
53
|
+
pathFilter: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("Path filter"),
|
|
54
|
+
gitOptions: zod_v3.default.object({
|
|
55
|
+
gitDiff: zod_v3.default.boolean().optional(),
|
|
56
|
+
gitDiffBase: zod_v3.default.string().optional(),
|
|
57
|
+
gitDiffCurrent: zod_v3.default.string().optional(),
|
|
58
|
+
uncommitted: zod_v3.default.boolean().optional(),
|
|
59
|
+
unpushed: zod_v3.default.boolean().optional(),
|
|
60
|
+
untracked: zod_v3.default.boolean().optional()
|
|
61
|
+
}).optional().describe("Git options"),
|
|
62
|
+
aiOptions: zod_v3.default.object({
|
|
63
|
+
provider: zod_v3.default.string().optional(),
|
|
64
|
+
temperature: zod_v3.default.number().optional(),
|
|
65
|
+
model: zod_v3.default.string().optional(),
|
|
66
|
+
apiKey: zod_v3.default.string().optional(),
|
|
67
|
+
customPrompt: zod_v3.default.string().optional(),
|
|
68
|
+
applicationContext: zod_v3.default.string().optional()
|
|
69
|
+
}).optional().describe("AI options")
|
|
70
|
+
}
|
|
65
71
|
}, async (props) => {
|
|
66
72
|
try {
|
|
67
73
|
const { gitOptions, ...rest } = props;
|
|
@@ -93,18 +99,21 @@ const loadCLITools = async (server) => {
|
|
|
93
99
|
}] };
|
|
94
100
|
}
|
|
95
101
|
});
|
|
96
|
-
server.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
server.registerTool("intlayer-push", {
|
|
103
|
+
description: "Push local dictionaries to the server",
|
|
104
|
+
inputSchema: {
|
|
105
|
+
deleteLocaleDictionary: zod_v3.default.boolean().optional().describe("Delete local dictionary after push"),
|
|
106
|
+
keepLocaleDictionary: zod_v3.default.boolean().optional().describe("Keep local dictionary after push"),
|
|
107
|
+
dictionaries: zod_v3.default.array(zod_v3.default.string()).optional().describe("List of dictionaries to push"),
|
|
108
|
+
gitOptions: zod_v3.default.object({
|
|
109
|
+
gitDiff: zod_v3.default.boolean().optional(),
|
|
110
|
+
gitDiffBase: zod_v3.default.string().optional(),
|
|
111
|
+
gitDiffCurrent: zod_v3.default.string().optional(),
|
|
112
|
+
uncommitted: zod_v3.default.boolean().optional(),
|
|
113
|
+
unpushed: zod_v3.default.boolean().optional(),
|
|
114
|
+
untracked: zod_v3.default.boolean().optional()
|
|
115
|
+
}).optional().describe("Git options")
|
|
116
|
+
}
|
|
108
117
|
}, async (props) => {
|
|
109
118
|
try {
|
|
110
119
|
const { gitOptions, ...rest } = props;
|
|
@@ -136,9 +145,12 @@ const loadCLITools = async (server) => {
|
|
|
136
145
|
}] };
|
|
137
146
|
}
|
|
138
147
|
});
|
|
139
|
-
server.
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
server.registerTool("intlayer-pull", {
|
|
149
|
+
description: "Pull dictionaries from the CMS",
|
|
150
|
+
inputSchema: {
|
|
151
|
+
dictionaries: zod_v3.default.array(zod_v3.default.string()).optional().describe("List of dictionaries to pull"),
|
|
152
|
+
newDictionariesPath: zod_v3.default.string().optional().describe("Path to save new dictionaries")
|
|
153
|
+
}
|
|
142
154
|
}, async (props) => {
|
|
143
155
|
try {
|
|
144
156
|
await (0, __intlayer_cli.pull)(props);
|
|
@@ -153,15 +165,18 @@ const loadCLITools = async (server) => {
|
|
|
153
165
|
}] };
|
|
154
166
|
}
|
|
155
167
|
});
|
|
156
|
-
server.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
168
|
+
server.registerTool("intlayer-content-list", {
|
|
169
|
+
description: "List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.",
|
|
170
|
+
inputSchema: { configOptions: zod_v3.default.object({
|
|
171
|
+
baseDir: zod_v3.default.string().optional(),
|
|
172
|
+
env: zod_v3.default.string().optional(),
|
|
173
|
+
envFile: zod_v3.default.string().optional(),
|
|
174
|
+
override: zod_v3.default.object({ log: zod_v3.default.object({
|
|
175
|
+
prefix: zod_v3.default.string().optional(),
|
|
176
|
+
verbose: zod_v3.default.boolean().optional()
|
|
177
|
+
}).optional() }).optional()
|
|
178
|
+
}).optional().describe("Configuration options") }
|
|
179
|
+
}, async (props) => {
|
|
165
180
|
try {
|
|
166
181
|
const rows = (0, __intlayer_cli.listContentDeclarationRows)(props);
|
|
167
182
|
return { content: [{
|
|
@@ -175,15 +190,18 @@ const loadCLITools = async (server) => {
|
|
|
175
190
|
}] };
|
|
176
191
|
}
|
|
177
192
|
});
|
|
178
|
-
server.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
193
|
+
server.registerTool("intlayer-content-test", {
|
|
194
|
+
description: "Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.",
|
|
195
|
+
inputSchema: { configOptions: zod_v3.default.object({
|
|
196
|
+
baseDir: zod_v3.default.string().optional(),
|
|
197
|
+
env: zod_v3.default.string().optional(),
|
|
198
|
+
envFile: zod_v3.default.string().optional(),
|
|
199
|
+
override: zod_v3.default.object({ log: zod_v3.default.object({
|
|
200
|
+
prefix: zod_v3.default.string().optional(),
|
|
201
|
+
verbose: zod_v3.default.boolean().optional()
|
|
202
|
+
}).optional() }).optional()
|
|
203
|
+
}).optional().describe("Configuration options") }
|
|
204
|
+
}, async (props) => {
|
|
187
205
|
try {
|
|
188
206
|
const missingTranslations = (0, __intlayer_cli.listMissingTranslations)(props?.configOptions);
|
|
189
207
|
return { content: [{
|
|
@@ -197,6 +215,39 @@ const loadCLITools = async (server) => {
|
|
|
197
215
|
}] };
|
|
198
216
|
}
|
|
199
217
|
});
|
|
218
|
+
server.registerTool("intlayer-transform", {
|
|
219
|
+
description: "Transform an existing component to use Intlayer. Trigger this action to transform an existing component to be multilingual. If the component does not exist, create a normal React component including text in JSX, and then trigger this tool to transform it.",
|
|
220
|
+
inputSchema: {
|
|
221
|
+
file: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("List of files to transform"),
|
|
222
|
+
outputContentDeclarations: zod_v3.default.string().optional().describe("Path to output content declaration files"),
|
|
223
|
+
configOptions: zod_v3.default.object({
|
|
224
|
+
baseDir: zod_v3.default.string().optional(),
|
|
225
|
+
env: zod_v3.default.string().optional(),
|
|
226
|
+
envFile: zod_v3.default.string().optional(),
|
|
227
|
+
override: zod_v3.default.object({ log: zod_v3.default.object({
|
|
228
|
+
prefix: zod_v3.default.string().optional(),
|
|
229
|
+
verbose: zod_v3.default.boolean().optional()
|
|
230
|
+
}).optional() }).optional()
|
|
231
|
+
}).optional().describe("Configuration options")
|
|
232
|
+
}
|
|
233
|
+
}, async (props) => {
|
|
234
|
+
try {
|
|
235
|
+
await (0, __intlayer_cli.transform)({
|
|
236
|
+
files: Array.isArray(props.file) ? props.file : props.file ? [props.file] : void 0,
|
|
237
|
+
outputContentDeclarations: props.outputContentDeclarations,
|
|
238
|
+
configOptions: props.configOptions
|
|
239
|
+
});
|
|
240
|
+
return { content: [{
|
|
241
|
+
type: "text",
|
|
242
|
+
text: "Transform successful."
|
|
243
|
+
}] };
|
|
244
|
+
} catch (error) {
|
|
245
|
+
return { content: [{
|
|
246
|
+
type: "text",
|
|
247
|
+
text: `Transform failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
|
|
248
|
+
}] };
|
|
249
|
+
}
|
|
250
|
+
});
|
|
200
251
|
};
|
|
201
252
|
|
|
202
253
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":["loadCLITools: LoadCLITools","z","log: Partial<LogConfig>","Locales","fillOptions: any","pushOptions: any"],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import {\n build,\n fill,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n} from '@intlayer/cli';\nimport { Locales, type LogConfig } from '@intlayer/types';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.tool(\n 'intlayer-build',\n 'Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.',\n {\n watch: z.boolean().optional().describe('Watch for changes'),\n baseDir: z.string().optional().describe('Base directory'),\n env: z.string().optional().describe('Environment'),\n envFile: z.string().optional().describe('Environment file'),\n verbose: z.boolean().optional().describe('Verbose output'),\n prefix: z.string().optional().describe('Log prefix'),\n },\n async ({ watch, baseDir, env, envFile, verbose, prefix }) => {\n try {\n const log: Partial<LogConfig> = {};\n if (verbose) {\n log.mode = 'verbose';\n }\n if (prefix) {\n log.prefix = prefix;\n }\n\n await build({\n watch,\n configOptions: {\n baseDir,\n env,\n envFile,\n override: {\n log,\n },\n },\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Build successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Build failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-fill',\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n {\n sourceLocale: z\n .nativeEnum(Locales.ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(Locales.ALL_LOCALES),\n z.array(z.nativeEnum(Locales.ALL_LOCALES)),\n ])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-push',\n 'Push local dictionaries to the server',\n {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-pull',\n 'Pull dictionaries from the CMS',\n {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n },\n async (props) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-content-list',\n 'List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.',\n {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(rows, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-content-test',\n 'Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.',\n {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n async (props) => {\n try {\n const missingTranslations = listMissingTranslations(\n props?.configOptions\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(missingTranslations, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content test failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;AAcA,MAAaA,eAA6B,OAAO,WAAW;AAC1D,QAAO,KACL,kBACA,4JACA;EACE,OAAOC,eAAE,SAAS,CAAC,UAAU,CAAC,SAAS,oBAAoB;EAC3D,SAASA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAA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E,QAAQ,CAAC,UAAU;EAC9B,KAAKA,eAAE,QAAQ,CAAC,UAAU;EAC1B,SAASA,eAAE,QAAQ,CAAC,UAAU;EAC9B,UAAUA,eACP,OAAO,EACN,KAAKA,eACF,OAAO;GACN,QAAQA,eAAE,QAAQ,CAAC,UAAU;GAC7B,SAASA,eAAE,SAAS,CAAC,UAAU;GAChC,CAAC,CACD,UAAU,EACd,CAAC,CACD,UAAU;EACd,CAAC,CACD,UAAU,CACV,SAAS,wBAAwB,EACrC,EACD,OAAO,UAAU;AACf,MAAI;GACF,MAAM,kEACJ,OAAO,cACR;AACD,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,KAAK,UAAU,qBAAqB,MAAM,EAAE;IACnD,CACF,EACF;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,wBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN"}
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":["loadCLITools: LoadCLITools","z","log: Partial<LogConfig>","Locales","fillOptions: any","pushOptions: any"],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import {\n build,\n fill,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n transform,\n} from '@intlayer/cli';\nimport { Locales, type LogConfig } from '@intlayer/types';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.registerTool(\n 'intlayer-build',\n {\n description:\n 'Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.',\n inputSchema: {\n watch: z.boolean().optional().describe('Watch for changes'),\n baseDir: z.string().optional().describe('Base directory'),\n env: z.string().optional().describe('Environment'),\n envFile: z.string().optional().describe('Environment file'),\n verbose: z.boolean().optional().describe('Verbose output'),\n prefix: z.string().optional().describe('Log prefix'),\n },\n },\n async ({ watch, baseDir, env, envFile, verbose, prefix }) => {\n try {\n const log: Partial<LogConfig> = {};\n if (verbose) {\n log.mode = 'verbose';\n }\n if (prefix) {\n log.prefix = prefix;\n }\n\n await build({\n watch,\n configOptions: {\n baseDir,\n env,\n envFile,\n override: {\n log,\n },\n },\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Build successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Build failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-fill',\n {\n description:\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n inputSchema: {\n sourceLocale: z\n .nativeEnum(Locales.ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(Locales.ALL_LOCALES),\n z.array(z.nativeEnum(Locales.ALL_LOCALES)),\n ])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n },\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-push',\n {\n description: 'Push local dictionaries to the server',\n inputSchema: {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n },\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-pull',\n {\n description: 'Pull dictionaries from the CMS',\n inputSchema: {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n },\n },\n async (props) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-content-list',\n {\n description:\n 'List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.',\n inputSchema: {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(rows, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-content-test',\n {\n description:\n 'Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.',\n inputSchema: {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n const missingTranslations = listMissingTranslations(\n props?.configOptions\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(missingTranslations, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content test failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-transform',\n {\n description:\n 'Transform an existing component to use Intlayer. Trigger this action to transform an existing component to be multilingual. If the component does not exist, create a normal React component including text in JSX, and then trigger this tool to transform it.',\n inputSchema: {\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('List of files to transform'),\n outputContentDeclarations: z\n .string()\n .optional()\n .describe('Path to output content declaration files'),\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n await transform({\n files: Array.isArray(props.file)\n ? props.file\n : props.file\n ? [props.file]\n : undefined,\n outputContentDeclarations: props.outputContentDeclarations,\n configOptions: props.configOptions,\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Transform successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Transform failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;AAeA,MAAaA,eAA6B,OAAO,WAAW;AAC1D,QAAO,aACL,kBACA;EACE,aACE;EACF,aAAa;GACX,OAAOC,eAAE,SAAS,CAAC,UAAU,CAAC,SAAS,oBAAoB;GAC3D,SAASA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,iBAAiB;GACzD,KAAKA,eAAE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;GACrC;EACF,EACD,OAAO,UAAU;AACf,MAAI;AACF,uCAAgB;IACd,OAAO,MAAM,QAAQ,MAAM,KAAK,GAC5B,MAAM,OACN,MAAM,OACJ,CAAC,MAAM,KAAK,GACZ;IACN,2BAA2B,MAAM;IACjC,eAAe,MAAM;IACtB,CAAC;AAEF,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM;IACP,CACF,EACF;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,qBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN"}
|
package/dist/cjs/tools/docs.cjs
CHANGED
|
@@ -6,7 +6,10 @@ let __intlayer_docs = require("@intlayer/docs");
|
|
|
6
6
|
//#region src/tools/docs.ts
|
|
7
7
|
const loadDocsTools = async (server) => {
|
|
8
8
|
const docsKeys = (0, __intlayer_docs.getDocsKeys)();
|
|
9
|
-
server.
|
|
9
|
+
server.registerTool("get-doc-list", {
|
|
10
|
+
description: "Get the list of docs names and their metadata to get more details about what doc to retrieve",
|
|
11
|
+
inputSchema: {}
|
|
12
|
+
}, async () => {
|
|
10
13
|
try {
|
|
11
14
|
const docsMetadataRecord = await (0, __intlayer_docs.getDocMetadataRecord)();
|
|
12
15
|
return { content: [{
|
|
@@ -20,7 +23,10 @@ const loadDocsTools = async (server) => {
|
|
|
20
23
|
}] };
|
|
21
24
|
}
|
|
22
25
|
});
|
|
23
|
-
server.
|
|
26
|
+
server.registerTool("get-doc", {
|
|
27
|
+
description: "Get a doc by his key. Example: `./docs/en/getting-started.md`. List all docs metadata first to get more details about what doc key to retrieve.",
|
|
28
|
+
inputSchema: { docKey: zod_v3.default.enum(docsKeys) }
|
|
29
|
+
}, async ({ docKey }) => {
|
|
24
30
|
try {
|
|
25
31
|
return { content: [{
|
|
26
32
|
type: "text",
|
|
@@ -33,10 +39,12 @@ const loadDocsTools = async (server) => {
|
|
|
33
39
|
}] };
|
|
34
40
|
}
|
|
35
41
|
});
|
|
36
|
-
server.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
server.registerTool("get-doc-by-slug", {
|
|
43
|
+
description: "Get an array of docs by their slugs. If not slug is provided, return all docs (1.2Mb). List all docs metadata first to get more details about what doc to retrieve.",
|
|
44
|
+
inputSchema: {
|
|
45
|
+
slug: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("Slug of the docs. If not provided, return all docs. If not provided, return all docs."),
|
|
46
|
+
strict: zod_v3.default.boolean().optional().describe("Strict mode - only return docs that match all slugs, by excluding additional slugs")
|
|
47
|
+
}
|
|
40
48
|
}, async ({ slug, strict }) => {
|
|
41
49
|
try {
|
|
42
50
|
return { content: (await (0, __intlayer_docs.getDocBySlug)(slug, void 0, strict)).map((d) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.cjs","names":["loadDocsTools: LoadDocsTools","z"],"sources":["../../../src/tools/docs.ts"],"sourcesContent":["import type { DocKey } from '@intlayer/docs';\nimport {\n getDoc,\n getDocBySlug,\n getDocMetadataRecord,\n getDocsKeys,\n} from '@intlayer/docs';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadDocsTools = (server: McpServer) => Promise<void>;\n\nexport const loadDocsTools: LoadDocsTools = async (server) => {\n const docsKeys = getDocsKeys();\n\n server.
|
|
1
|
+
{"version":3,"file":"docs.cjs","names":["loadDocsTools: LoadDocsTools","z"],"sources":["../../../src/tools/docs.ts"],"sourcesContent":["import type { DocKey } from '@intlayer/docs';\nimport {\n getDoc,\n getDocBySlug,\n getDocMetadataRecord,\n getDocsKeys,\n} from '@intlayer/docs';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadDocsTools = (server: McpServer) => Promise<void>;\n\nexport const loadDocsTools: LoadDocsTools = async (server) => {\n const docsKeys = getDocsKeys();\n\n server.registerTool(\n 'get-doc-list',\n {\n description:\n 'Get the list of docs names and their metadata to get more details about what doc to retrieve',\n inputSchema: {},\n },\n async () => {\n try {\n const docsMetadataRecord = await getDocMetadataRecord();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(docsMetadataRecord, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n { type: 'text', text: `Get doc list failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'get-doc',\n {\n description:\n 'Get a doc by his key. Example: `./docs/en/getting-started.md`. List all docs metadata first to get more details about what doc key to retrieve.',\n inputSchema: {\n docKey: z.enum(docsKeys as [string, ...string[]]),\n },\n },\n async ({ docKey }) => {\n try {\n const doc = await getDoc(docKey as DocKey);\n return {\n content: [{ type: 'text', text: doc }],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [{ type: 'text', text: `Get doc failed: ${errorMessage}` }],\n };\n }\n }\n );\n\n server.registerTool(\n 'get-doc-by-slug',\n {\n description:\n 'Get an array of docs by their slugs. If not slug is provided, return all docs (1.2Mb). List all docs metadata first to get more details about what doc to retrieve.',\n inputSchema: {\n slug: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe(\n 'Slug of the docs. If not provided, return all docs. If not provided, return all docs.'\n ),\n strict: z\n .boolean()\n .optional()\n .describe(\n 'Strict mode - only return docs that match all slugs, by excluding additional slugs'\n ),\n },\n },\n async ({ slug, strict }) => {\n try {\n const doc = await getDocBySlug(slug, undefined, strict);\n return {\n content: doc.map((d) => ({ type: 'text', text: d })),\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n { type: 'text', text: `Get doc by slug failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;AAYA,MAAaA,gBAA+B,OAAO,WAAW;CAC5D,MAAM,6CAAwB;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
-
import { build, fill, listContentDeclarationRows, listMissingTranslations, pull, push } from "@intlayer/cli";
|
|
1
|
+
import { build, fill, listContentDeclarationRows, listMissingTranslations, pull, push, transform } from "@intlayer/cli";
|
|
2
2
|
import { Locales } from "@intlayer/types";
|
|
3
3
|
import z from "zod/v3";
|
|
4
4
|
|
|
5
5
|
//#region src/tools/cli.ts
|
|
6
6
|
const loadCLITools = async (server) => {
|
|
7
|
-
server.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
server.registerTool("intlayer-build", {
|
|
8
|
+
description: "Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
watch: z.boolean().optional().describe("Watch for changes"),
|
|
11
|
+
baseDir: z.string().optional().describe("Base directory"),
|
|
12
|
+
env: z.string().optional().describe("Environment"),
|
|
13
|
+
envFile: z.string().optional().describe("Environment file"),
|
|
14
|
+
verbose: z.boolean().optional().describe("Verbose output"),
|
|
15
|
+
prefix: z.string().optional().describe("Log prefix")
|
|
16
|
+
}
|
|
14
17
|
}, async ({ watch, baseDir, env, envFile, verbose, prefix }) => {
|
|
15
18
|
try {
|
|
16
19
|
const log = {};
|
|
@@ -36,30 +39,33 @@ const loadCLITools = async (server) => {
|
|
|
36
39
|
}] };
|
|
37
40
|
}
|
|
38
41
|
});
|
|
39
|
-
server.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
42
|
+
server.registerTool("intlayer-fill", {
|
|
43
|
+
description: "Fill the dictionaries with missing translations / review translations using Intlayer servers",
|
|
44
|
+
inputSchema: {
|
|
45
|
+
sourceLocale: z.nativeEnum(Locales.ALL_LOCALES).optional().describe("Source locale"),
|
|
46
|
+
outputLocales: z.union([z.nativeEnum(Locales.ALL_LOCALES), z.array(z.nativeEnum(Locales.ALL_LOCALES))]).optional().describe("Output locales"),
|
|
47
|
+
file: z.union([z.string(), z.array(z.string())]).optional().describe("File path"),
|
|
48
|
+
mode: z.enum(["complete", "review"]).optional().describe("Fill mode"),
|
|
49
|
+
keys: z.union([z.string(), z.array(z.string())]).optional().describe("Keys to include"),
|
|
50
|
+
excludedKeys: z.union([z.string(), z.array(z.string())]).optional().describe("Keys to exclude"),
|
|
51
|
+
pathFilter: z.union([z.string(), z.array(z.string())]).optional().describe("Path filter"),
|
|
52
|
+
gitOptions: z.object({
|
|
53
|
+
gitDiff: z.boolean().optional(),
|
|
54
|
+
gitDiffBase: z.string().optional(),
|
|
55
|
+
gitDiffCurrent: z.string().optional(),
|
|
56
|
+
uncommitted: z.boolean().optional(),
|
|
57
|
+
unpushed: z.boolean().optional(),
|
|
58
|
+
untracked: z.boolean().optional()
|
|
59
|
+
}).optional().describe("Git options"),
|
|
60
|
+
aiOptions: z.object({
|
|
61
|
+
provider: z.string().optional(),
|
|
62
|
+
temperature: z.number().optional(),
|
|
63
|
+
model: z.string().optional(),
|
|
64
|
+
apiKey: z.string().optional(),
|
|
65
|
+
customPrompt: z.string().optional(),
|
|
66
|
+
applicationContext: z.string().optional()
|
|
67
|
+
}).optional().describe("AI options")
|
|
68
|
+
}
|
|
63
69
|
}, async (props) => {
|
|
64
70
|
try {
|
|
65
71
|
const { gitOptions, ...rest } = props;
|
|
@@ -91,18 +97,21 @@ const loadCLITools = async (server) => {
|
|
|
91
97
|
}] };
|
|
92
98
|
}
|
|
93
99
|
});
|
|
94
|
-
server.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
server.registerTool("intlayer-push", {
|
|
101
|
+
description: "Push local dictionaries to the server",
|
|
102
|
+
inputSchema: {
|
|
103
|
+
deleteLocaleDictionary: z.boolean().optional().describe("Delete local dictionary after push"),
|
|
104
|
+
keepLocaleDictionary: z.boolean().optional().describe("Keep local dictionary after push"),
|
|
105
|
+
dictionaries: z.array(z.string()).optional().describe("List of dictionaries to push"),
|
|
106
|
+
gitOptions: z.object({
|
|
107
|
+
gitDiff: z.boolean().optional(),
|
|
108
|
+
gitDiffBase: z.string().optional(),
|
|
109
|
+
gitDiffCurrent: z.string().optional(),
|
|
110
|
+
uncommitted: z.boolean().optional(),
|
|
111
|
+
unpushed: z.boolean().optional(),
|
|
112
|
+
untracked: z.boolean().optional()
|
|
113
|
+
}).optional().describe("Git options")
|
|
114
|
+
}
|
|
106
115
|
}, async (props) => {
|
|
107
116
|
try {
|
|
108
117
|
const { gitOptions, ...rest } = props;
|
|
@@ -134,9 +143,12 @@ const loadCLITools = async (server) => {
|
|
|
134
143
|
}] };
|
|
135
144
|
}
|
|
136
145
|
});
|
|
137
|
-
server.
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
server.registerTool("intlayer-pull", {
|
|
147
|
+
description: "Pull dictionaries from the CMS",
|
|
148
|
+
inputSchema: {
|
|
149
|
+
dictionaries: z.array(z.string()).optional().describe("List of dictionaries to pull"),
|
|
150
|
+
newDictionariesPath: z.string().optional().describe("Path to save new dictionaries")
|
|
151
|
+
}
|
|
140
152
|
}, async (props) => {
|
|
141
153
|
try {
|
|
142
154
|
await pull(props);
|
|
@@ -151,15 +163,18 @@ const loadCLITools = async (server) => {
|
|
|
151
163
|
}] };
|
|
152
164
|
}
|
|
153
165
|
});
|
|
154
|
-
server.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
server.registerTool("intlayer-content-list", {
|
|
167
|
+
description: "List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.",
|
|
168
|
+
inputSchema: { configOptions: z.object({
|
|
169
|
+
baseDir: z.string().optional(),
|
|
170
|
+
env: z.string().optional(),
|
|
171
|
+
envFile: z.string().optional(),
|
|
172
|
+
override: z.object({ log: z.object({
|
|
173
|
+
prefix: z.string().optional(),
|
|
174
|
+
verbose: z.boolean().optional()
|
|
175
|
+
}).optional() }).optional()
|
|
176
|
+
}).optional().describe("Configuration options") }
|
|
177
|
+
}, async (props) => {
|
|
163
178
|
try {
|
|
164
179
|
const rows = listContentDeclarationRows(props);
|
|
165
180
|
return { content: [{
|
|
@@ -173,15 +188,18 @@ const loadCLITools = async (server) => {
|
|
|
173
188
|
}] };
|
|
174
189
|
}
|
|
175
190
|
});
|
|
176
|
-
server.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
191
|
+
server.registerTool("intlayer-content-test", {
|
|
192
|
+
description: "Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.",
|
|
193
|
+
inputSchema: { configOptions: z.object({
|
|
194
|
+
baseDir: z.string().optional(),
|
|
195
|
+
env: z.string().optional(),
|
|
196
|
+
envFile: z.string().optional(),
|
|
197
|
+
override: z.object({ log: z.object({
|
|
198
|
+
prefix: z.string().optional(),
|
|
199
|
+
verbose: z.boolean().optional()
|
|
200
|
+
}).optional() }).optional()
|
|
201
|
+
}).optional().describe("Configuration options") }
|
|
202
|
+
}, async (props) => {
|
|
185
203
|
try {
|
|
186
204
|
const missingTranslations = listMissingTranslations(props?.configOptions);
|
|
187
205
|
return { content: [{
|
|
@@ -195,6 +213,39 @@ const loadCLITools = async (server) => {
|
|
|
195
213
|
}] };
|
|
196
214
|
}
|
|
197
215
|
});
|
|
216
|
+
server.registerTool("intlayer-transform", {
|
|
217
|
+
description: "Transform an existing component to use Intlayer. Trigger this action to transform an existing component to be multilingual. If the component does not exist, create a normal React component including text in JSX, and then trigger this tool to transform it.",
|
|
218
|
+
inputSchema: {
|
|
219
|
+
file: z.union([z.string(), z.array(z.string())]).optional().describe("List of files to transform"),
|
|
220
|
+
outputContentDeclarations: z.string().optional().describe("Path to output content declaration files"),
|
|
221
|
+
configOptions: z.object({
|
|
222
|
+
baseDir: z.string().optional(),
|
|
223
|
+
env: z.string().optional(),
|
|
224
|
+
envFile: z.string().optional(),
|
|
225
|
+
override: z.object({ log: z.object({
|
|
226
|
+
prefix: z.string().optional(),
|
|
227
|
+
verbose: z.boolean().optional()
|
|
228
|
+
}).optional() }).optional()
|
|
229
|
+
}).optional().describe("Configuration options")
|
|
230
|
+
}
|
|
231
|
+
}, async (props) => {
|
|
232
|
+
try {
|
|
233
|
+
await transform({
|
|
234
|
+
files: Array.isArray(props.file) ? props.file : props.file ? [props.file] : void 0,
|
|
235
|
+
outputContentDeclarations: props.outputContentDeclarations,
|
|
236
|
+
configOptions: props.configOptions
|
|
237
|
+
});
|
|
238
|
+
return { content: [{
|
|
239
|
+
type: "text",
|
|
240
|
+
text: "Transform successful."
|
|
241
|
+
}] };
|
|
242
|
+
} catch (error) {
|
|
243
|
+
return { content: [{
|
|
244
|
+
type: "text",
|
|
245
|
+
text: `Transform failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
|
|
246
|
+
}] };
|
|
247
|
+
}
|
|
248
|
+
});
|
|
198
249
|
};
|
|
199
250
|
|
|
200
251
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":["loadCLITools: LoadCLITools","log: Partial<LogConfig>","fillOptions: any","pushOptions: any"],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import {\n build,\n fill,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n} from '@intlayer/cli';\nimport { Locales, type LogConfig } from '@intlayer/types';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.tool(\n 'intlayer-build',\n 'Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.',\n {\n watch: z.boolean().optional().describe('Watch for changes'),\n baseDir: z.string().optional().describe('Base directory'),\n env: z.string().optional().describe('Environment'),\n envFile: z.string().optional().describe('Environment file'),\n verbose: z.boolean().optional().describe('Verbose output'),\n prefix: z.string().optional().describe('Log prefix'),\n },\n async ({ watch, baseDir, env, envFile, verbose, prefix }) => {\n try {\n const log: Partial<LogConfig> = {};\n if (verbose) {\n log.mode = 'verbose';\n }\n if (prefix) {\n log.prefix = prefix;\n }\n\n await build({\n watch,\n configOptions: {\n baseDir,\n env,\n envFile,\n override: {\n log,\n },\n },\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Build successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Build failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-fill',\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n {\n sourceLocale: z\n .nativeEnum(Locales.ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(Locales.ALL_LOCALES),\n z.array(z.nativeEnum(Locales.ALL_LOCALES)),\n ])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-push',\n 'Push local dictionaries to the server',\n {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-pull',\n 'Pull dictionaries from the CMS',\n {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n },\n async (props) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-content-list',\n 'List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.',\n {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(rows, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-content-test',\n 'Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.',\n {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n async (props) => {\n try {\n const missingTranslations = listMissingTranslations(\n props?.configOptions\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(missingTranslations, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content test failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;AAcA,MAAaA,eAA6B,OAAO,WAAW;AAC1D,QAAO,KACL,kBACA,4JACA;EACE,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,oBAAoB;EAC3D,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,iBAAiB;EACzD,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,cAAc;EAClD,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,mBAAmB;EAC3D,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,iBAAiB;EAC1D,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,aAAa;EACrD,EACD,OAAO,EAAE,OAAO,SAAS,KAAK,SAAS,SAAS,aAAa;AAC3D,MAAI;GACF,MAAMC,MAA0B,EAAE;AAClC,OAAI,QACF,KAAI,OAAO;AAEb,OAAI,OACF,KAAI,SAAS;AAGf,SAAM,MAAM;IACV;IACA,eAAe;KACb;KACA;KACA;KACA,UAAU,EACR,KACD;KACF;IACF,CAAC;A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IACN,MAAM,wBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["loadCLITools: LoadCLITools","log: Partial<LogConfig>","fillOptions: any","pushOptions: any"],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import {\n build,\n fill,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n transform,\n} from '@intlayer/cli';\nimport { Locales, type LogConfig } from '@intlayer/types';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.registerTool(\n 'intlayer-build',\n {\n description:\n 'Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.',\n inputSchema: {\n watch: z.boolean().optional().describe('Watch for changes'),\n baseDir: z.string().optional().describe('Base directory'),\n env: z.string().optional().describe('Environment'),\n envFile: z.string().optional().describe('Environment file'),\n verbose: z.boolean().optional().describe('Verbose output'),\n prefix: z.string().optional().describe('Log prefix'),\n },\n },\n async ({ watch, baseDir, env, envFile, verbose, prefix }) => {\n try {\n const log: Partial<LogConfig> = {};\n if (verbose) {\n log.mode = 'verbose';\n }\n if (prefix) {\n log.prefix = prefix;\n }\n\n await build({\n watch,\n configOptions: {\n baseDir,\n env,\n envFile,\n override: {\n log,\n },\n },\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Build successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Build failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-fill',\n {\n description:\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n inputSchema: {\n sourceLocale: z\n .nativeEnum(Locales.ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(Locales.ALL_LOCALES),\n z.array(z.nativeEnum(Locales.ALL_LOCALES)),\n ])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n },\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-push',\n {\n description: 'Push local dictionaries to the server',\n inputSchema: {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n },\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-pull',\n {\n description: 'Pull dictionaries from the CMS',\n inputSchema: {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n },\n },\n async (props) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-content-list',\n {\n description:\n 'List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.',\n inputSchema: {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(rows, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-content-test',\n {\n description:\n 'Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.',\n inputSchema: {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n const missingTranslations = listMissingTranslations(\n props?.configOptions\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(missingTranslations, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content test failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-transform',\n {\n description:\n 'Transform an existing component to use Intlayer. Trigger this action to transform an existing component to be multilingual. If the component does not exist, create a normal React component including text in JSX, and then trigger this tool to transform it.',\n inputSchema: {\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('List of files to transform'),\n outputContentDeclarations: z\n .string()\n .optional()\n .describe('Path to output content declaration files'),\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n await transform({\n files: Array.isArray(props.file)\n ? props.file\n : props.file\n ? [props.file]\n : undefined,\n outputContentDeclarations: props.outputContentDeclarations,\n configOptions: props.configOptions,\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Transform successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Transform failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;AAeA,MAAaA,eAA6B,OAAO,WAAW;AAC1D,QAAO,aACL,kBACA;EACE,aACE;EACF,aAAa;GACX,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,oBAAoB;GAC3D,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,iBAAiB;GACzD,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,cAAc;GAClD,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,mBAAmB;GAC3D,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,iBAAiB;GAC1D,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,aAAa;GACrD;EACF,EACD,OAAO,EAAE,OAAO,SAAS,KAAK,SAAS,SAAS,aAAa;AAC3D,MAAI;GACF,MAAMC,MAA0B,EAAE;AAClC,OAAI,QACF,KAAI,OAAO;AAEb,OAAI,OACF,KAAI,SAAS;AAGf,SAAM,MAAM;IACV;IACA,eAAe;KACb;KACA;KACA;KACA,UAAU,EACR,KACD;KACF;IACF,CAAC;AAEF,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM;IACP,CACF,EACF;WACM,OAA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,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,wBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN;AAED,QAAO,aACL,sBACA;EACE,aACE;EACF,aAAa;GACX,MAAM,EACH,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CACxC,UAAU,CACV,SAAS,6BAA6B;GACzC,2BAA2B,EACxB,QAAQ,CACR,UAAU,CACV,SAAS,2CAA2C;GACvD,eAAe,EACZ,OAAO;IACN,SAAS,EAAE,QAAQ,CAAC,UAAU;IAC9B,KAAK,EAAE,QAAQ,CAAC,UAAU;IAC1B,SAAS,EAAE,QAAQ,CAAC,UAAU;IAC9B,UAAU,EACP,OAAO,EACN,KAAK,EACF,OAAO;KACN,QAAQ,EAAE,QAAQ,CAAC,UAAU;KAC7B,SAAS,EAAE,SAAS,CAAC,UAAU;KAChC,CAAC,CACD,UAAU,EACd,CAAC,CACD,UAAU;IACd,CAAC,CACD,UAAU,CACV,SAAS,wBAAwB;GACrC;EACF,EACD,OAAO,UAAU;AACf,MAAI;AACF,SAAM,UAAU;IACd,OAAO,MAAM,QAAQ,MAAM,KAAK,GAC5B,MAAM,OACN,MAAM,OACJ,CAAC,MAAM,KAAK,GACZ;IACN,2BAA2B,MAAM;IACjC,eAAe,MAAM;IACtB,CAAC;AAEF,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM;IACP,CACF,EACF;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,qBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN"}
|
package/dist/esm/tools/docs.mjs
CHANGED
|
@@ -4,7 +4,10 @@ import { getDoc, getDocBySlug, getDocMetadataRecord, getDocsKeys } from "@intlay
|
|
|
4
4
|
//#region src/tools/docs.ts
|
|
5
5
|
const loadDocsTools = async (server) => {
|
|
6
6
|
const docsKeys = getDocsKeys();
|
|
7
|
-
server.
|
|
7
|
+
server.registerTool("get-doc-list", {
|
|
8
|
+
description: "Get the list of docs names and their metadata to get more details about what doc to retrieve",
|
|
9
|
+
inputSchema: {}
|
|
10
|
+
}, async () => {
|
|
8
11
|
try {
|
|
9
12
|
const docsMetadataRecord = await getDocMetadataRecord();
|
|
10
13
|
return { content: [{
|
|
@@ -18,7 +21,10 @@ const loadDocsTools = async (server) => {
|
|
|
18
21
|
}] };
|
|
19
22
|
}
|
|
20
23
|
});
|
|
21
|
-
server.
|
|
24
|
+
server.registerTool("get-doc", {
|
|
25
|
+
description: "Get a doc by his key. Example: `./docs/en/getting-started.md`. List all docs metadata first to get more details about what doc key to retrieve.",
|
|
26
|
+
inputSchema: { docKey: z.enum(docsKeys) }
|
|
27
|
+
}, async ({ docKey }) => {
|
|
22
28
|
try {
|
|
23
29
|
return { content: [{
|
|
24
30
|
type: "text",
|
|
@@ -31,10 +37,12 @@ const loadDocsTools = async (server) => {
|
|
|
31
37
|
}] };
|
|
32
38
|
}
|
|
33
39
|
});
|
|
34
|
-
server.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
server.registerTool("get-doc-by-slug", {
|
|
41
|
+
description: "Get an array of docs by their slugs. If not slug is provided, return all docs (1.2Mb). List all docs metadata first to get more details about what doc to retrieve.",
|
|
42
|
+
inputSchema: {
|
|
43
|
+
slug: z.union([z.string(), z.array(z.string())]).optional().describe("Slug of the docs. If not provided, return all docs. If not provided, return all docs."),
|
|
44
|
+
strict: z.boolean().optional().describe("Strict mode - only return docs that match all slugs, by excluding additional slugs")
|
|
45
|
+
}
|
|
38
46
|
}, async ({ slug, strict }) => {
|
|
39
47
|
try {
|
|
40
48
|
return { content: (await getDocBySlug(slug, void 0, strict)).map((d) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.mjs","names":["loadDocsTools: LoadDocsTools"],"sources":["../../../src/tools/docs.ts"],"sourcesContent":["import type { DocKey } from '@intlayer/docs';\nimport {\n getDoc,\n getDocBySlug,\n getDocMetadataRecord,\n getDocsKeys,\n} from '@intlayer/docs';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadDocsTools = (server: McpServer) => Promise<void>;\n\nexport const loadDocsTools: LoadDocsTools = async (server) => {\n const docsKeys = getDocsKeys();\n\n server.
|
|
1
|
+
{"version":3,"file":"docs.mjs","names":["loadDocsTools: LoadDocsTools"],"sources":["../../../src/tools/docs.ts"],"sourcesContent":["import type { DocKey } from '@intlayer/docs';\nimport {\n getDoc,\n getDocBySlug,\n getDocMetadataRecord,\n getDocsKeys,\n} from '@intlayer/docs';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadDocsTools = (server: McpServer) => Promise<void>;\n\nexport const loadDocsTools: LoadDocsTools = async (server) => {\n const docsKeys = getDocsKeys();\n\n server.registerTool(\n 'get-doc-list',\n {\n description:\n 'Get the list of docs names and their metadata to get more details about what doc to retrieve',\n inputSchema: {},\n },\n async () => {\n try {\n const docsMetadataRecord = await getDocMetadataRecord();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(docsMetadataRecord, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n { type: 'text', text: `Get doc list failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'get-doc',\n {\n description:\n 'Get a doc by his key. Example: `./docs/en/getting-started.md`. List all docs metadata first to get more details about what doc key to retrieve.',\n inputSchema: {\n docKey: z.enum(docsKeys as [string, ...string[]]),\n },\n },\n async ({ docKey }) => {\n try {\n const doc = await getDoc(docKey as DocKey);\n return {\n content: [{ type: 'text', text: doc }],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [{ type: 'text', text: `Get doc failed: ${errorMessage}` }],\n };\n }\n }\n );\n\n server.registerTool(\n 'get-doc-by-slug',\n {\n description:\n 'Get an array of docs by their slugs. If not slug is provided, return all docs (1.2Mb). List all docs metadata first to get more details about what doc to retrieve.',\n inputSchema: {\n slug: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe(\n 'Slug of the docs. If not provided, return all docs. If not provided, return all docs.'\n ),\n strict: z\n .boolean()\n .optional()\n .describe(\n 'Strict mode - only return docs that match all slugs, by excluding additional slugs'\n ),\n },\n },\n async ({ slug, strict }) => {\n try {\n const doc = await getDocBySlug(slug, undefined, strict);\n return {\n content: doc.map((d) => ({ type: 'text', text: d })),\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n { type: 'text', text: `Get doc by slug failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;AAYA,MAAaA,gBAA+B,OAAO,WAAW;CAC5D,MAAM,WAAW,aAAa;AAE9B,QAAO,aACL,gBACA;EACE,aACE;EACF,aAAa,EAAE;EAChB,EACD,YAAY;AACV,MAAI;GACF,MAAM,qBAAqB,MAAM,sBAAsB;AAEvD,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,KAAK,UAAU,oBAAoB,MAAM,EAAE;IAClD,CACF,EACF;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IAAE,MAAM;IAAQ,MAAM,wBAHxB,iBAAiB,QAAQ,MAAM,UAAU;IAGuB,CAC/D,EACF;;GAGN;AAED,QAAO,aACL,WACA;EACE,aACE;EACF,aAAa,EACX,QAAQ,EAAE,KAAK,SAAkC,EAClD;EACF,EACD,OAAO,EAAE,aAAa;AACpB,MAAI;AAEF,UAAO,EACL,SAAS,CAAC;IAAE,MAAM;IAAQ,MAFhB,MAAM,OAAO,OAAiB;IAEH,CAAC,EACvC;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CAAC;IAAE,MAAM;IAAQ,MAAM,mBAFhC,iBAAiB,QAAQ,MAAM,UAAU;IAE0B,CAAC,EACrE;;GAGN;AAED,QAAO,aACL,mBACA;EACE,aACE;EACF,aAAa;GACX,MAAM,EACH,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CACxC,UAAU,CACV,SACC,wFACD;GACH,QAAQ,EACL,SAAS,CACT,UAAU,CACV,SACC,qFACD;GACJ;EACF,EACD,OAAO,EAAE,MAAM,aAAa;AAC1B,MAAI;AAEF,UAAO,EACL,UAFU,MAAM,aAAa,MAAM,QAAW,OAAO,EAExC,KAAK,OAAO;IAAE,MAAM;IAAQ,MAAM;IAAG,EAAE,EACrD;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IAAE,MAAM;IAAQ,MAAM,2BAHxB,iBAAiB,QAAQ,MAAM,UAAU;IAG0B,CAClE,EACF;;GAGN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","names":["loadCLITools: LoadCLITools"],"sources":["../../../src/tools/cli.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","names":["loadCLITools: LoadCLITools"],"sources":["../../../src/tools/cli.ts"],"sourcesContent":[],"mappings":";;;KAaK,YAAA,YAAwB,cAAc;cAE9BA,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/mcp",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Intlayer MCP server. Handle MCP to help IDE to use Intlayer. It build, fill, pull, push, dictionaries",
|
|
6
6
|
"keywords": [
|
|
@@ -95,27 +95,27 @@
|
|
|
95
95
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@intlayer/cli": "7.2.
|
|
99
|
-
"@intlayer/config": "7.2.
|
|
100
|
-
"@intlayer/docs": "7.2.
|
|
101
|
-
"@intlayer/types": "7.2.
|
|
98
|
+
"@intlayer/cli": "7.2.3",
|
|
99
|
+
"@intlayer/config": "7.2.3",
|
|
100
|
+
"@intlayer/docs": "7.2.3",
|
|
101
|
+
"@intlayer/types": "7.2.3",
|
|
102
102
|
"@modelcontextprotocol/sdk": "1.21.1",
|
|
103
103
|
"dotenv": "16.6.1",
|
|
104
104
|
"express": "5.1.0",
|
|
105
105
|
"zod": "3.25.76"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@intlayer/types": "7.2.
|
|
108
|
+
"@intlayer/types": "7.2.3",
|
|
109
109
|
"@modelcontextprotocol/inspector": "0.17.2",
|
|
110
110
|
"@types/express": "5.0.5",
|
|
111
111
|
"@types/node": "24.10.1",
|
|
112
112
|
"@utils/ts-config": "1.0.4",
|
|
113
113
|
"@utils/ts-config-types": "1.0.4",
|
|
114
114
|
"@utils/tsdown-config": "1.0.4",
|
|
115
|
-
"rimraf": "6.1.
|
|
116
|
-
"tsdown": "0.16.
|
|
115
|
+
"rimraf": "6.1.2",
|
|
116
|
+
"tsdown": "0.16.6",
|
|
117
117
|
"typescript": "5.9.3",
|
|
118
|
-
"vitest": "4.0.
|
|
118
|
+
"vitest": "4.0.12"
|
|
119
119
|
},
|
|
120
120
|
"engines": {
|
|
121
121
|
"node": ">=14.18"
|