@intlayer/mcp 8.9.3 → 8.9.4
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/esm/client/client.mjs +13 -9
- package/dist/esm/client/client.mjs.map +1 -1
- package/dist/esm/client/sse.mjs +17 -50
- package/dist/esm/client/sse.mjs.map +1 -1
- package/dist/esm/server/server.mjs +115 -4
- package/dist/esm/server/server.mjs.map +1 -1
- package/dist/esm/server/sse.mjs +33 -20
- package/dist/esm/server/sse.mjs.map +1 -1
- package/dist/esm/server/stdio.mjs +35 -3
- package/dist/esm/server/stdio.mjs.map +1 -1
- package/dist/esm/tools/api.mjs +340 -0
- package/dist/esm/tools/api.mjs.map +1 -0
- package/dist/esm/tools/cli.mjs +37 -46
- package/dist/esm/tools/cli.mjs.map +1 -1
- package/dist/esm/tools/docs.mjs +1 -1
- package/dist/esm/tools/docs.mjs.map +1 -1
- package/dist/esm/tools/index.mjs +6 -0
- package/dist/esm/tools/installSkills.mjs +2 -2
- package/dist/esm/tools/installSkills.mjs.map +1 -1
- package/dist/types/client/client.d.ts +6 -4
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/server/server.d.ts +27 -3
- package/dist/types/server/server.d.ts.map +1 -1
- package/dist/types/tools/api.d.ts +8 -0
- package/dist/types/tools/api.d.ts.map +1 -0
- package/dist/types/tools/cli.d.ts +1 -1
- package/dist/types/tools/cli.d.ts.map +1 -1
- package/dist/types/tools/docs.d.ts +11 -3
- package/dist/types/tools/docs.d.ts.map +1 -1
- package/dist/types/tools/index.d.ts +5 -0
- package/dist/types/tools/installSkills.d.ts +1 -1
- package/package.json +25 -11
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { getIntlayerAPI } from "@intlayer/api";
|
|
3
|
+
import config from "@intlayer/config/built";
|
|
4
|
+
|
|
5
|
+
//#region src/tools/api.ts
|
|
6
|
+
const authSchema = {
|
|
7
|
+
clientId: z.string().optional().describe("Intlayer OAuth2 client ID (access key). Falls back to INTLAYER_CLIENT_ID env var."),
|
|
8
|
+
clientSecret: z.string().optional().describe("Intlayer OAuth2 client secret. Falls back to INTLAYER_CLIENT_SECRET env var.")
|
|
9
|
+
};
|
|
10
|
+
const getAPI = async (clientId, clientSecret) => {
|
|
11
|
+
const resolvedClientId = clientId ?? config.editor.clientId;
|
|
12
|
+
const resolvedClientSecret = clientSecret ?? config.editor.clientSecret;
|
|
13
|
+
if (!resolvedClientId || !resolvedClientSecret) throw new Error("Intlayer credentials not found. Provide clientId/clientSecret or set INTLAYER_CLIENT_ID/INTLAYER_CLIENT_SECRET.");
|
|
14
|
+
const token = (await getIntlayerAPI({}, {
|
|
15
|
+
...config,
|
|
16
|
+
editor: {
|
|
17
|
+
...config.editor,
|
|
18
|
+
clientId: resolvedClientId,
|
|
19
|
+
clientSecret: resolvedClientSecret
|
|
20
|
+
}
|
|
21
|
+
}).oAuth.getOAuth2AccessToken())?.data?.access_token;
|
|
22
|
+
if (!token) throw new Error("Failed to obtain OAuth2 access token. Check your credentials.");
|
|
23
|
+
return getIntlayerAPI({ headers: { Authorization: `Bearer ${token}` } }, config);
|
|
24
|
+
};
|
|
25
|
+
const ok = (data) => ({ content: [{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: JSON.stringify(data, null, 2)
|
|
28
|
+
}] });
|
|
29
|
+
const fail = (label, error) => ({
|
|
30
|
+
content: [{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: `${label} failed: ${error instanceof Error ? error.message : String(error)}`
|
|
33
|
+
}],
|
|
34
|
+
isError: true
|
|
35
|
+
});
|
|
36
|
+
const loadAPITools = (server) => {
|
|
37
|
+
server.registerTool("intlayer-dictionaries-list", {
|
|
38
|
+
title: "List Dictionaries",
|
|
39
|
+
description: "List all dictionaries for the selected project. Returns keys, IDs, and metadata.",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
...authSchema,
|
|
42
|
+
page: z.number().optional().describe("Page number (1-based)"),
|
|
43
|
+
pageSize: z.number().optional().describe("Items per page")
|
|
44
|
+
},
|
|
45
|
+
annotations: { readOnlyHint: true }
|
|
46
|
+
}, async ({ clientId, clientSecret, page, pageSize }) => {
|
|
47
|
+
try {
|
|
48
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.getDictionaries({
|
|
49
|
+
page,
|
|
50
|
+
pageSize
|
|
51
|
+
}));
|
|
52
|
+
} catch (error) {
|
|
53
|
+
return fail("List dictionaries", error);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
server.registerTool("intlayer-dictionary-get", {
|
|
57
|
+
title: "Get Dictionary",
|
|
58
|
+
description: "Get a dictionary by its key, including its full content.",
|
|
59
|
+
inputSchema: {
|
|
60
|
+
...authSchema,
|
|
61
|
+
dictionaryKey: z.string().describe("The dictionary key")
|
|
62
|
+
},
|
|
63
|
+
annotations: { readOnlyHint: true }
|
|
64
|
+
}, async ({ clientId, clientSecret, dictionaryKey }) => {
|
|
65
|
+
try {
|
|
66
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.getDictionary(dictionaryKey));
|
|
67
|
+
} catch (error) {
|
|
68
|
+
return fail("Get dictionary", error);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
server.registerTool("intlayer-dictionary-create", {
|
|
72
|
+
title: "Create Dictionary",
|
|
73
|
+
description: "Create a new dictionary in the selected project.",
|
|
74
|
+
inputSchema: {
|
|
75
|
+
...authSchema,
|
|
76
|
+
key: z.string().describe("Unique key for the dictionary"),
|
|
77
|
+
title: z.string().optional().describe("Human-readable title"),
|
|
78
|
+
description: z.string().optional().describe("Description of the dictionary"),
|
|
79
|
+
content: z.record(z.string(), z.unknown()).optional().describe("Initial content as JSON object")
|
|
80
|
+
},
|
|
81
|
+
annotations: { destructiveHint: false }
|
|
82
|
+
}, async ({ clientId, clientSecret, key, title, description, content }) => {
|
|
83
|
+
try {
|
|
84
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.addDictionary({
|
|
85
|
+
key,
|
|
86
|
+
title,
|
|
87
|
+
description,
|
|
88
|
+
content
|
|
89
|
+
}));
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return fail("Create dictionary", error);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
server.registerTool("intlayer-dictionary-update", {
|
|
95
|
+
title: "Update Dictionary",
|
|
96
|
+
description: "Update an existing dictionary content or metadata.",
|
|
97
|
+
inputSchema: {
|
|
98
|
+
...authSchema,
|
|
99
|
+
id: z.string().describe("Dictionary ID"),
|
|
100
|
+
key: z.string().optional().describe("New key for the dictionary"),
|
|
101
|
+
title: z.string().optional().describe("New title"),
|
|
102
|
+
description: z.string().optional().describe("New description"),
|
|
103
|
+
content: z.record(z.string(), z.unknown()).optional().describe("Updated content as JSON object")
|
|
104
|
+
},
|
|
105
|
+
annotations: { destructiveHint: true }
|
|
106
|
+
}, async ({ clientId, clientSecret, id, key, title, description, content }) => {
|
|
107
|
+
try {
|
|
108
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.updateDictionary({
|
|
109
|
+
id,
|
|
110
|
+
key,
|
|
111
|
+
title,
|
|
112
|
+
description,
|
|
113
|
+
content
|
|
114
|
+
}));
|
|
115
|
+
} catch (error) {
|
|
116
|
+
return fail("Update dictionary", error);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
server.registerTool("intlayer-dictionary-delete", {
|
|
120
|
+
title: "Delete Dictionary",
|
|
121
|
+
description: "Delete a dictionary by its ID. This action is irreversible.",
|
|
122
|
+
inputSchema: {
|
|
123
|
+
...authSchema,
|
|
124
|
+
dictionaryId: z.string().describe("Dictionary ID to delete")
|
|
125
|
+
},
|
|
126
|
+
annotations: { destructiveHint: true }
|
|
127
|
+
}, async ({ clientId, clientSecret, dictionaryId }) => {
|
|
128
|
+
try {
|
|
129
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.deleteDictionary(dictionaryId));
|
|
130
|
+
} catch (error) {
|
|
131
|
+
return fail("Delete dictionary", error);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
server.registerTool("intlayer-tags-list", {
|
|
135
|
+
title: "List Tags",
|
|
136
|
+
description: "List all tags for the selected organization.",
|
|
137
|
+
inputSchema: {
|
|
138
|
+
...authSchema,
|
|
139
|
+
page: z.number().optional().describe("Page number (1-based)"),
|
|
140
|
+
pageSize: z.number().optional().describe("Items per page")
|
|
141
|
+
},
|
|
142
|
+
annotations: { readOnlyHint: true }
|
|
143
|
+
}, async ({ clientId, clientSecret, page, pageSize }) => {
|
|
144
|
+
try {
|
|
145
|
+
return ok(await (await getAPI(clientId, clientSecret)).tag.getTags({
|
|
146
|
+
page,
|
|
147
|
+
pageSize
|
|
148
|
+
}));
|
|
149
|
+
} catch (error) {
|
|
150
|
+
return fail("List tags", error);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
server.registerTool("intlayer-tag-create", {
|
|
154
|
+
title: "Create Tag",
|
|
155
|
+
description: "Create a new tag in the organization. Tags can be used to group dictionaries and provide AI context.",
|
|
156
|
+
inputSchema: {
|
|
157
|
+
...authSchema,
|
|
158
|
+
key: z.string().describe("Unique tag key"),
|
|
159
|
+
name: z.string().optional().describe("Display name for the tag"),
|
|
160
|
+
description: z.string().optional().describe("Description of the tag"),
|
|
161
|
+
color: z.string().optional().describe("Tag color (hex code)"),
|
|
162
|
+
instructions: z.string().optional().describe("AI instructions to apply when this tag is used")
|
|
163
|
+
},
|
|
164
|
+
annotations: { destructiveHint: false }
|
|
165
|
+
}, async ({ clientId, clientSecret, key, name, description, color, instructions }) => {
|
|
166
|
+
try {
|
|
167
|
+
return ok(await (await getAPI(clientId, clientSecret)).tag.addTag({
|
|
168
|
+
key,
|
|
169
|
+
name,
|
|
170
|
+
description,
|
|
171
|
+
color,
|
|
172
|
+
instructions
|
|
173
|
+
}));
|
|
174
|
+
} catch (error) {
|
|
175
|
+
return fail("Create tag", error);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
server.registerTool("intlayer-tag-update", {
|
|
179
|
+
title: "Update Tag",
|
|
180
|
+
description: "Update an existing tag.",
|
|
181
|
+
inputSchema: {
|
|
182
|
+
...authSchema,
|
|
183
|
+
tagId: z.string().describe("Tag ID to update"),
|
|
184
|
+
key: z.string().optional().describe("New key"),
|
|
185
|
+
name: z.string().optional().describe("New display name"),
|
|
186
|
+
description: z.string().optional().describe("New description"),
|
|
187
|
+
color: z.string().optional().describe("New color (hex code)"),
|
|
188
|
+
instructions: z.string().optional().describe("New AI instructions")
|
|
189
|
+
},
|
|
190
|
+
annotations: { destructiveHint: true }
|
|
191
|
+
}, async ({ clientId, clientSecret, tagId, key, name, description, color, instructions }) => {
|
|
192
|
+
try {
|
|
193
|
+
return ok(await (await getAPI(clientId, clientSecret)).tag.updateTag(tagId, {
|
|
194
|
+
key,
|
|
195
|
+
name,
|
|
196
|
+
description,
|
|
197
|
+
color,
|
|
198
|
+
instructions
|
|
199
|
+
}));
|
|
200
|
+
} catch (error) {
|
|
201
|
+
return fail("Update tag", error);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
server.registerTool("intlayer-tag-delete", {
|
|
205
|
+
title: "Delete Tag",
|
|
206
|
+
description: "Delete a tag by its ID.",
|
|
207
|
+
inputSchema: {
|
|
208
|
+
...authSchema,
|
|
209
|
+
tagId: z.string().describe("Tag ID to delete")
|
|
210
|
+
},
|
|
211
|
+
annotations: { destructiveHint: true }
|
|
212
|
+
}, async ({ clientId, clientSecret, tagId }) => {
|
|
213
|
+
try {
|
|
214
|
+
return ok(await (await getAPI(clientId, clientSecret)).tag.deleteTag(tagId));
|
|
215
|
+
} catch (error) {
|
|
216
|
+
return fail("Delete tag", error);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
server.registerTool("intlayer-organizations-list", {
|
|
220
|
+
title: "List Organizations",
|
|
221
|
+
description: "List all organizations the authenticated user belongs to.",
|
|
222
|
+
inputSchema: {
|
|
223
|
+
...authSchema,
|
|
224
|
+
page: z.number().optional().describe("Page number (1-based)"),
|
|
225
|
+
pageSize: z.number().optional().describe("Items per page")
|
|
226
|
+
},
|
|
227
|
+
annotations: { readOnlyHint: true }
|
|
228
|
+
}, async ({ clientId, clientSecret, page, pageSize }) => {
|
|
229
|
+
try {
|
|
230
|
+
return ok(await (await getAPI(clientId, clientSecret)).organization.getOrganizations({
|
|
231
|
+
page,
|
|
232
|
+
pageSize
|
|
233
|
+
}));
|
|
234
|
+
} catch (error) {
|
|
235
|
+
return fail("List organizations", error);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
server.registerTool("intlayer-organization-select", {
|
|
239
|
+
title: "Select Organization",
|
|
240
|
+
description: "Select an organization as the current active organization. Required before accessing organization-specific resources.",
|
|
241
|
+
inputSchema: {
|
|
242
|
+
...authSchema,
|
|
243
|
+
organizationId: z.string().describe("Organization ID to select")
|
|
244
|
+
},
|
|
245
|
+
annotations: { destructiveHint: false }
|
|
246
|
+
}, async ({ clientId, clientSecret, organizationId }) => {
|
|
247
|
+
try {
|
|
248
|
+
return ok(await (await getAPI(clientId, clientSecret)).organization.selectOrganization(organizationId));
|
|
249
|
+
} catch (error) {
|
|
250
|
+
return fail("Select organization", error);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
server.registerTool("intlayer-organization-update", {
|
|
254
|
+
title: "Update Organization",
|
|
255
|
+
description: "Update the selected organization name or settings.",
|
|
256
|
+
inputSchema: {
|
|
257
|
+
...authSchema,
|
|
258
|
+
name: z.string().optional().describe("New organization name"),
|
|
259
|
+
customInstructions: z.string().optional().describe("Custom AI instructions for this organization")
|
|
260
|
+
},
|
|
261
|
+
annotations: { destructiveHint: true }
|
|
262
|
+
}, async ({ clientId, clientSecret, name, customInstructions }) => {
|
|
263
|
+
try {
|
|
264
|
+
return ok(await (await getAPI(clientId, clientSecret)).organization.updateOrganization({
|
|
265
|
+
name,
|
|
266
|
+
customInstructions
|
|
267
|
+
}));
|
|
268
|
+
} catch (error) {
|
|
269
|
+
return fail("Update organization", error);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
server.registerTool("intlayer-cms-projects-list", {
|
|
273
|
+
title: "List CMS Projects",
|
|
274
|
+
description: "List all Intlayer CMS projects for the selected organization. These are server-side projects, not local project directories.",
|
|
275
|
+
inputSchema: {
|
|
276
|
+
...authSchema,
|
|
277
|
+
page: z.number().optional().describe("Page number (1-based)"),
|
|
278
|
+
pageSize: z.number().optional().describe("Items per page")
|
|
279
|
+
},
|
|
280
|
+
annotations: { readOnlyHint: true }
|
|
281
|
+
}, async ({ clientId, clientSecret, page, pageSize }) => {
|
|
282
|
+
try {
|
|
283
|
+
return ok(await (await getAPI(clientId, clientSecret)).project.getProjects({
|
|
284
|
+
page,
|
|
285
|
+
pageSize
|
|
286
|
+
}));
|
|
287
|
+
} catch (error) {
|
|
288
|
+
return fail("List CMS projects", error);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
server.registerTool("intlayer-cms-project-select", {
|
|
292
|
+
title: "Select CMS Project",
|
|
293
|
+
description: "Select a CMS project as the current active project. Required before accessing project-specific dictionaries.",
|
|
294
|
+
inputSchema: {
|
|
295
|
+
...authSchema,
|
|
296
|
+
projectId: z.string().describe("Project ID to select")
|
|
297
|
+
},
|
|
298
|
+
annotations: { destructiveHint: false }
|
|
299
|
+
}, async ({ clientId, clientSecret, projectId }) => {
|
|
300
|
+
try {
|
|
301
|
+
return ok(await (await getAPI(clientId, clientSecret)).project.selectProject(projectId));
|
|
302
|
+
} catch (error) {
|
|
303
|
+
return fail("Select CMS project", error);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
server.registerTool("intlayer-cms-project-create", {
|
|
307
|
+
title: "Create CMS Project",
|
|
308
|
+
description: "Create a new CMS project in the selected organization.",
|
|
309
|
+
inputSchema: {
|
|
310
|
+
...authSchema,
|
|
311
|
+
name: z.string().describe("Project name")
|
|
312
|
+
},
|
|
313
|
+
annotations: { destructiveHint: false }
|
|
314
|
+
}, async ({ clientId, clientSecret, name }) => {
|
|
315
|
+
try {
|
|
316
|
+
return ok(await (await getAPI(clientId, clientSecret)).project.addProject({ name }));
|
|
317
|
+
} catch (error) {
|
|
318
|
+
return fail("Create CMS project", error);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
server.registerTool("intlayer-cms-project-update", {
|
|
322
|
+
title: "Update CMS Project",
|
|
323
|
+
description: "Update the selected CMS project settings.",
|
|
324
|
+
inputSchema: {
|
|
325
|
+
...authSchema,
|
|
326
|
+
name: z.string().optional().describe("New project name")
|
|
327
|
+
},
|
|
328
|
+
annotations: { destructiveHint: true }
|
|
329
|
+
}, async ({ clientId, clientSecret, name }) => {
|
|
330
|
+
try {
|
|
331
|
+
return ok(await (await getAPI(clientId, clientSecret)).project.updateProject({ name }));
|
|
332
|
+
} catch (error) {
|
|
333
|
+
return fail("Update CMS project", error);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
//#endregion
|
|
339
|
+
export { loadAPITools };
|
|
340
|
+
//# sourceMappingURL=api.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.mjs","names":[],"sources":["../../../src/tools/api.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\nimport { default as config } from '@intlayer/config/built';\nimport z from 'zod';\nimport type { McpServer } from './docs';\n\ntype LoadAPITools = (server: McpServer) => void;\n\nconst authSchema = {\n clientId: z\n .string()\n .optional()\n .describe(\n 'Intlayer OAuth2 client ID (access key). Falls back to INTLAYER_CLIENT_ID env var.'\n ),\n clientSecret: z\n .string()\n .optional()\n .describe(\n 'Intlayer OAuth2 client secret. Falls back to INTLAYER_CLIENT_SECRET env var.'\n ),\n};\n\nconst getAPI = async (clientId?: string, clientSecret?: string) => {\n const resolvedClientId = clientId ?? config.editor.clientId;\n const resolvedClientSecret = clientSecret ?? config.editor.clientSecret;\n\n if (!resolvedClientId || !resolvedClientSecret) {\n throw new Error(\n 'Intlayer credentials not found. Provide clientId/clientSecret or set INTLAYER_CLIENT_ID/INTLAYER_CLIENT_SECRET.'\n );\n }\n\n const configWithCreds = {\n ...config,\n editor: {\n ...config.editor,\n clientId: resolvedClientId,\n clientSecret: resolvedClientSecret,\n },\n };\n\n const tempAPI = getIntlayerAPI({}, configWithCreds);\n const tokenResult = await tempAPI.oAuth.getOAuth2AccessToken();\n const token = (tokenResult as any)?.data?.access_token as string | undefined;\n\n if (!token) {\n throw new Error(\n 'Failed to obtain OAuth2 access token. Check your credentials.'\n );\n }\n\n return getIntlayerAPI(\n { headers: { Authorization: `Bearer ${token}` } },\n config\n );\n};\n\nconst ok = (data: unknown) => ({\n content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],\n});\n\nconst fail = (label: string, error: unknown) => ({\n content: [\n {\n type: 'text' as const,\n text: `${label} failed: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n isError: true as const,\n});\n\nexport const loadAPITools: LoadAPITools = (server) => {\n // ── Dictionaries ──────────────────────────────────────────────────────────\n\n server.registerTool(\n 'intlayer-dictionaries-list',\n {\n title: 'List Dictionaries',\n description:\n 'List all dictionaries for the selected project. Returns keys, IDs, and metadata.',\n inputSchema: {\n ...authSchema,\n page: z.number().optional().describe('Page number (1-based)'),\n pageSize: z.number().optional().describe('Items per page'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, page, pageSize }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.getDictionaries({\n page,\n pageSize,\n });\n return ok(result);\n } catch (error) {\n return fail('List dictionaries', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-dictionary-get',\n {\n title: 'Get Dictionary',\n description: 'Get a dictionary by its key, including its full content.',\n inputSchema: {\n ...authSchema,\n dictionaryKey: z.string().describe('The dictionary key'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, dictionaryKey }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.getDictionary(dictionaryKey);\n return ok(result);\n } catch (error) {\n return fail('Get dictionary', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-dictionary-create',\n {\n title: 'Create Dictionary',\n description: 'Create a new dictionary in the selected project.',\n inputSchema: {\n ...authSchema,\n key: z.string().describe('Unique key for the dictionary'),\n title: z.string().optional().describe('Human-readable title'),\n description: z\n .string()\n .optional()\n .describe('Description of the dictionary'),\n content: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Initial content as JSON object'),\n },\n annotations: { destructiveHint: false },\n },\n async ({ clientId, clientSecret, key, title, description, content }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.addDictionary({\n key,\n title,\n description,\n content,\n });\n return ok(result);\n } catch (error) {\n return fail('Create dictionary', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-dictionary-update',\n {\n title: 'Update Dictionary',\n description: 'Update an existing dictionary content or metadata.',\n inputSchema: {\n ...authSchema,\n id: z.string().describe('Dictionary ID'),\n key: z.string().optional().describe('New key for the dictionary'),\n title: z.string().optional().describe('New title'),\n description: z.string().optional().describe('New description'),\n content: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Updated content as JSON object'),\n },\n annotations: { destructiveHint: true },\n },\n async ({\n clientId,\n clientSecret,\n id,\n key,\n title,\n description,\n content,\n }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.updateDictionary({\n id,\n key,\n title,\n description,\n content,\n });\n return ok(result);\n } catch (error) {\n return fail('Update dictionary', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-dictionary-delete',\n {\n title: 'Delete Dictionary',\n description:\n 'Delete a dictionary by its ID. This action is irreversible.',\n inputSchema: {\n ...authSchema,\n dictionaryId: z.string().describe('Dictionary ID to delete'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, dictionaryId }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.deleteDictionary(dictionaryId);\n return ok(result);\n } catch (error) {\n return fail('Delete dictionary', error);\n }\n }\n );\n\n // ── Tags ──────────────────────────────────────────────────────────────────\n\n server.registerTool(\n 'intlayer-tags-list',\n {\n title: 'List Tags',\n description: 'List all tags for the selected organization.',\n inputSchema: {\n ...authSchema,\n page: z.number().optional().describe('Page number (1-based)'),\n pageSize: z.number().optional().describe('Items per page'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, page, pageSize }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.tag.getTags({ page, pageSize });\n return ok(result);\n } catch (error) {\n return fail('List tags', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-tag-create',\n {\n title: 'Create Tag',\n description:\n 'Create a new tag in the organization. Tags can be used to group dictionaries and provide AI context.',\n inputSchema: {\n ...authSchema,\n key: z.string().describe('Unique tag key'),\n name: z.string().optional().describe('Display name for the tag'),\n description: z.string().optional().describe('Description of the tag'),\n color: z.string().optional().describe('Tag color (hex code)'),\n instructions: z\n .string()\n .optional()\n .describe('AI instructions to apply when this tag is used'),\n },\n annotations: { destructiveHint: false },\n },\n async ({\n clientId,\n clientSecret,\n key,\n name,\n description,\n color,\n instructions,\n }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.tag.addTag({\n key,\n name,\n description,\n color,\n instructions,\n });\n return ok(result);\n } catch (error) {\n return fail('Create tag', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-tag-update',\n {\n title: 'Update Tag',\n description: 'Update an existing tag.',\n inputSchema: {\n ...authSchema,\n tagId: z.string().describe('Tag ID to update'),\n key: z.string().optional().describe('New key'),\n name: z.string().optional().describe('New display name'),\n description: z.string().optional().describe('New description'),\n color: z.string().optional().describe('New color (hex code)'),\n instructions: z.string().optional().describe('New AI instructions'),\n },\n annotations: { destructiveHint: true },\n },\n async ({\n clientId,\n clientSecret,\n tagId,\n key,\n name,\n description,\n color,\n instructions,\n }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.tag.updateTag(tagId, {\n key,\n name,\n description,\n color,\n instructions,\n });\n return ok(result);\n } catch (error) {\n return fail('Update tag', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-tag-delete',\n {\n title: 'Delete Tag',\n description: 'Delete a tag by its ID.',\n inputSchema: {\n ...authSchema,\n tagId: z.string().describe('Tag ID to delete'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, tagId }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.tag.deleteTag(tagId);\n return ok(result);\n } catch (error) {\n return fail('Delete tag', error);\n }\n }\n );\n\n // ── Organizations ─────────────────────────────────────────────────────────\n\n server.registerTool(\n 'intlayer-organizations-list',\n {\n title: 'List Organizations',\n description: 'List all organizations the authenticated user belongs to.',\n inputSchema: {\n ...authSchema,\n page: z.number().optional().describe('Page number (1-based)'),\n pageSize: z.number().optional().describe('Items per page'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, page, pageSize }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.organization.getOrganizations({\n page,\n pageSize,\n });\n return ok(result);\n } catch (error) {\n return fail('List organizations', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-organization-select',\n {\n title: 'Select Organization',\n description:\n 'Select an organization as the current active organization. Required before accessing organization-specific resources.',\n inputSchema: {\n ...authSchema,\n organizationId: z.string().describe('Organization ID to select'),\n },\n annotations: { destructiveHint: false },\n },\n async ({ clientId, clientSecret, organizationId }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result =\n await api.organization.selectOrganization(organizationId);\n return ok(result);\n } catch (error) {\n return fail('Select organization', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-organization-update',\n {\n title: 'Update Organization',\n description: 'Update the selected organization name or settings.',\n inputSchema: {\n ...authSchema,\n name: z.string().optional().describe('New organization name'),\n customInstructions: z\n .string()\n .optional()\n .describe('Custom AI instructions for this organization'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, name, customInstructions }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.organization.updateOrganization({\n name,\n customInstructions,\n });\n return ok(result);\n } catch (error) {\n return fail('Update organization', error);\n }\n }\n );\n\n // ── Projects ──────────────────────────────────────────────────────────────\n\n server.registerTool(\n 'intlayer-cms-projects-list',\n {\n title: 'List CMS Projects',\n description:\n 'List all Intlayer CMS projects for the selected organization. These are server-side projects, not local project directories.',\n inputSchema: {\n ...authSchema,\n page: z.number().optional().describe('Page number (1-based)'),\n pageSize: z.number().optional().describe('Items per page'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, page, pageSize }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.project.getProjects({ page, pageSize });\n return ok(result);\n } catch (error) {\n return fail('List CMS projects', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-cms-project-select',\n {\n title: 'Select CMS Project',\n description:\n 'Select a CMS project as the current active project. Required before accessing project-specific dictionaries.',\n inputSchema: {\n ...authSchema,\n projectId: z.string().describe('Project ID to select'),\n },\n annotations: { destructiveHint: false },\n },\n async ({ clientId, clientSecret, projectId }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.project.selectProject(projectId);\n return ok(result);\n } catch (error) {\n return fail('Select CMS project', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-cms-project-create',\n {\n title: 'Create CMS Project',\n description: 'Create a new CMS project in the selected organization.',\n inputSchema: {\n ...authSchema,\n name: z.string().describe('Project name'),\n },\n annotations: { destructiveHint: false },\n },\n async ({ clientId, clientSecret, name }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.project.addProject({ name });\n return ok(result);\n } catch (error) {\n return fail('Create CMS project', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-cms-project-update',\n {\n title: 'Update CMS Project',\n description: 'Update the selected CMS project settings.',\n inputSchema: {\n ...authSchema,\n name: z.string().optional().describe('New project name'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, name }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.project.updateProject({ name });\n return ok(result);\n } catch (error) {\n return fail('Update CMS project', error);\n }\n }\n );\n};\n"],"mappings":";;;;;AAOA,MAAM,aAAa;CACjB,UAAU,EACP,QAAQ,CACR,UAAU,CACV,SACC,oFACD;CACH,cAAc,EACX,QAAQ,CACR,UAAU,CACV,SACC,+EACD;CACJ;AAED,MAAM,SAAS,OAAO,UAAmB,iBAA0B;CACjE,MAAM,mBAAmB,YAAY,OAAO,OAAO;CACnD,MAAM,uBAAuB,gBAAgB,OAAO,OAAO;CAE3D,IAAI,CAAC,oBAAoB,CAAC,sBACxB,MAAM,IAAI,MACR,kHACD;CAcH,MAAM,SAAS,MAFC,eAAe,EAAE,EAAE;EARjC,GAAG;EACH,QAAQ;GACN,GAAG,OAAO;GACV,UAAU;GACV,cAAc;GACf;EAG+C,CACjB,CAAC,MAAM,sBAAsB,GAC1B,MAAM;CAE1C,IAAI,CAAC,OACH,MAAM,IAAI,MACR,gEACD;CAGH,OAAO,eACL,EAAE,SAAS,EAAE,eAAe,UAAU,SAAS,EAAE,EACjD,OACD;;AAGH,MAAM,MAAM,UAAmB,EAC7B,SAAS,CAAC;CAAE,MAAM;CAAiB,MAAM,KAAK,UAAU,MAAM,MAAM,EAAE;CAAE,CAAC,EAC1E;AAED,MAAM,QAAQ,OAAe,WAAoB;CAC/C,SAAS,CACP;EACE,MAAM;EACN,MAAM,GAAG,MAAM,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;EACjF,CACF;CACD,SAAS;CACV;AAED,MAAa,gBAA8B,WAAW;CAGpD,OAAO,aACL,8BACA;EACE,OAAO;EACP,aACE;EACF,aAAa;GACX,GAAG;GACH,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,wBAAwB;GAC7D,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,iBAAiB;G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AAe;GAC1C;EACD,aAAa,EAAE,iBAAiB,OAAO;EACxC,EACD,OAAO,EAAE,UAAU,cAAc,WAAW;EAC1C,IAAI;GAGF,OAAO,GAAG,OADW,MADH,OAAO,UAAU,aAAa,EACvB,QAAQ,WAAW,EAAE,MAAM,CAAC,CACpC;WACV,OAAO;GACd,OAAO,KAAK,sBAAsB,MAAM;;GAG7C;CAED,OAAO,aACL,+BACA;EACE,OAAO;EACP,aAAa;EACb,aAAa;GACX,GAAG;GACH,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,mBAAmB;GACzD;EACD,aAAa,EAAE,iBAAiB,MAAM;EACvC,EACD,OAAO,EAAE,UAAU,cAAc,WAAW;EAC1C,IAAI;GAGF,OAAO,GAAG,OADW,MADH,OAAO,UAAU,aAAa,EACvB,QAAQ,cAAc,EAAE,MAAM,CAAC,CACvC;WACV,OAAO;GACd,OAAO,KAAK,sBAAsB,MAAM;;GAG7C"}
|
package/dist/esm/tools/cli.mjs
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
import { relative } from "node:path";
|
|
2
|
+
import z from "zod";
|
|
2
3
|
import { listProjects } from "@intlayer/chokidar/cli";
|
|
3
4
|
import { build, extract, fill, init, listContentDeclarationRows, listMissingTranslations, pull, push } from "@intlayer/cli";
|
|
4
5
|
import { ALL_LOCALES } from "@intlayer/types/allLocales";
|
|
5
|
-
import z from "zod";
|
|
6
6
|
|
|
7
7
|
//#region src/tools/cli.ts
|
|
8
|
+
const configOptionsSchema = z.object({
|
|
9
|
+
baseDir: z.string().optional().describe("Base directory for the project"),
|
|
10
|
+
env: z.string().optional().describe("Environment name"),
|
|
11
|
+
envFile: z.string().optional().describe("Path to the environment file"),
|
|
12
|
+
override: z.object({
|
|
13
|
+
editor: z.object({
|
|
14
|
+
clientId: z.string().optional().describe("Intlayer CMS client ID"),
|
|
15
|
+
clientSecret: z.string().optional().describe("Intlayer CMS client secret"),
|
|
16
|
+
backendURL: z.string().optional().describe("Intlayer CMS backend URL")
|
|
17
|
+
}).optional(),
|
|
18
|
+
internationalization: z.object({
|
|
19
|
+
locales: z.array(z.nativeEnum(ALL_LOCALES)).optional().describe("Available locales"),
|
|
20
|
+
defaultLocale: z.nativeEnum(ALL_LOCALES).optional().describe("Default locale")
|
|
21
|
+
}).optional(),
|
|
22
|
+
log: z.object({
|
|
23
|
+
mode: z.enum([
|
|
24
|
+
"default",
|
|
25
|
+
"verbose",
|
|
26
|
+
"disabled"
|
|
27
|
+
]).optional().describe("Log mode"),
|
|
28
|
+
prefix: z.string().optional().describe("Log prefix")
|
|
29
|
+
}).optional()
|
|
30
|
+
}).optional().describe("Config override - use when running remotely or without a local config file")
|
|
31
|
+
}).optional().describe("Configuration options. Required when running remotely or when no intlayer config file is present");
|
|
8
32
|
const loadCLITools = async (server) => {
|
|
9
33
|
server.registerTool("intlayer-init", {
|
|
10
34
|
title: "Initialize Intlayer",
|
|
@@ -30,26 +54,14 @@ const loadCLITools = async (server) => {
|
|
|
30
54
|
description: "Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.",
|
|
31
55
|
inputSchema: {
|
|
32
56
|
watch: z.boolean().optional().describe("Watch for changes"),
|
|
33
|
-
|
|
34
|
-
env: z.string().optional().describe("Environment"),
|
|
35
|
-
envFile: z.string().optional().describe("Environment file"),
|
|
36
|
-
verbose: z.boolean().optional().describe("Verbose output"),
|
|
37
|
-
prefix: z.string().optional().describe("Log prefix")
|
|
57
|
+
configOptions: configOptionsSchema
|
|
38
58
|
},
|
|
39
59
|
annotations: { destructiveHint: true }
|
|
40
|
-
}, async ({ watch,
|
|
60
|
+
}, async ({ watch, configOptions }) => {
|
|
41
61
|
try {
|
|
42
|
-
const log = {};
|
|
43
|
-
if (verbose) log.mode = "verbose";
|
|
44
|
-
if (prefix) log.prefix = prefix;
|
|
45
62
|
await build({
|
|
46
63
|
watch,
|
|
47
|
-
configOptions
|
|
48
|
-
baseDir,
|
|
49
|
-
env,
|
|
50
|
-
envFile,
|
|
51
|
-
override: { log }
|
|
52
|
-
}
|
|
64
|
+
configOptions
|
|
53
65
|
});
|
|
54
66
|
return { content: [{
|
|
55
67
|
type: "text",
|
|
@@ -88,7 +100,8 @@ const loadCLITools = async (server) => {
|
|
|
88
100
|
apiKey: z.string().optional(),
|
|
89
101
|
customPrompt: z.string().optional(),
|
|
90
102
|
applicationContext: z.string().optional()
|
|
91
|
-
}).optional().describe("AI options")
|
|
103
|
+
}).optional().describe("AI options"),
|
|
104
|
+
configOptions: configOptionsSchema
|
|
92
105
|
},
|
|
93
106
|
annotations: { destructiveHint: true }
|
|
94
107
|
}, async (props) => {
|
|
@@ -136,7 +149,8 @@ const loadCLITools = async (server) => {
|
|
|
136
149
|
uncommitted: z.boolean().optional(),
|
|
137
150
|
unpushed: z.boolean().optional(),
|
|
138
151
|
untracked: z.boolean().optional()
|
|
139
|
-
}).optional().describe("Git options")
|
|
152
|
+
}).optional().describe("Git options"),
|
|
153
|
+
configOptions: configOptionsSchema
|
|
140
154
|
},
|
|
141
155
|
annotations: { destructiveHint: true }
|
|
142
156
|
}, async (props) => {
|
|
@@ -175,7 +189,8 @@ const loadCLITools = async (server) => {
|
|
|
175
189
|
description: "Pull dictionaries from the CMS",
|
|
176
190
|
inputSchema: {
|
|
177
191
|
dictionaries: z.array(z.string()).optional().describe("List of dictionaries to pull"),
|
|
178
|
-
newDictionariesPath: z.string().optional().describe("Path to save new dictionaries")
|
|
192
|
+
newDictionariesPath: z.string().optional().describe("Path to save new dictionaries"),
|
|
193
|
+
configOptions: configOptionsSchema
|
|
179
194
|
},
|
|
180
195
|
annotations: { destructiveHint: true }
|
|
181
196
|
}, async (props) => {
|
|
@@ -196,15 +211,7 @@ const loadCLITools = async (server) => {
|
|
|
196
211
|
title: "List Content Declarations",
|
|
197
212
|
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.",
|
|
198
213
|
inputSchema: {
|
|
199
|
-
configOptions:
|
|
200
|
-
baseDir: z.string().optional(),
|
|
201
|
-
env: z.string().optional(),
|
|
202
|
-
envFile: z.string().optional(),
|
|
203
|
-
override: z.object({ log: z.object({
|
|
204
|
-
prefix: z.string().optional(),
|
|
205
|
-
verbose: z.boolean().optional()
|
|
206
|
-
}).optional() }).optional()
|
|
207
|
-
}).optional().describe("Configuration options"),
|
|
214
|
+
configOptions: configOptionsSchema,
|
|
208
215
|
absolute: z.boolean().optional().describe("Output the results as absolute paths instead of relative paths"),
|
|
209
216
|
json: z.boolean().optional().describe("Output the results as JSON instead of formatted text")
|
|
210
217
|
},
|
|
@@ -226,15 +233,7 @@ const loadCLITools = async (server) => {
|
|
|
226
233
|
server.registerTool("intlayer-content-test", {
|
|
227
234
|
title: "Test Translations",
|
|
228
235
|
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.",
|
|
229
|
-
inputSchema: { configOptions:
|
|
230
|
-
baseDir: z.string().optional(),
|
|
231
|
-
env: z.string().optional(),
|
|
232
|
-
envFile: z.string().optional(),
|
|
233
|
-
override: z.object({ log: z.object({
|
|
234
|
-
prefix: z.string().optional(),
|
|
235
|
-
verbose: z.boolean().optional()
|
|
236
|
-
}).optional() }).optional()
|
|
237
|
-
}).optional().describe("Configuration options") },
|
|
236
|
+
inputSchema: { configOptions: configOptionsSchema },
|
|
238
237
|
annotations: { readOnlyHint: true }
|
|
239
238
|
}, async (props) => {
|
|
240
239
|
try {
|
|
@@ -256,15 +255,7 @@ const loadCLITools = async (server) => {
|
|
|
256
255
|
inputSchema: {
|
|
257
256
|
file: z.union([z.string(), z.array(z.string())]).optional().describe("List of files to extract"),
|
|
258
257
|
outputContentDeclarations: z.string().optional().describe("Path to output content declaration files"),
|
|
259
|
-
configOptions:
|
|
260
|
-
baseDir: z.string().optional(),
|
|
261
|
-
env: z.string().optional(),
|
|
262
|
-
envFile: z.string().optional(),
|
|
263
|
-
override: z.object({ log: z.object({
|
|
264
|
-
prefix: z.string().optional(),
|
|
265
|
-
verbose: z.boolean().optional()
|
|
266
|
-
}).optional() }).optional()
|
|
267
|
-
}).optional().describe("Configuration options")
|
|
258
|
+
configOptions: configOptionsSchema
|
|
268
259
|
},
|
|
269
260
|
annotations: { destructiveHint: true }
|
|
270
261
|
}, async (props) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { listProjects } from '@intlayer/chokidar/cli';\nimport {\n build,\n extract,\n fill,\n init,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n} from '@intlayer/cli';\nimport { ALL_LOCALES } from '@intlayer/types/allLocales';\nimport type { LogConfig } from '@intlayer/types/config';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.registerTool(\n 'intlayer-init',\n {\n title: 'Initialize Intlayer',\n description: 'Initialize Intlayer in the project',\n inputSchema: {\n projectRoot: z.string().describe('Project root directory'),\n },\n annotations: {\n destructiveHint: true,\n },\n },\n async ({ projectRoot }) => {\n try {\n await init(projectRoot);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Initialization 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: `Initialization failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-build',\n {\n title: 'Build Dictionaries',\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 annotations: {\n destructiveHint: true,\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 title: 'Fill Translations',\n description:\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n inputSchema: {\n sourceLocale: z\n .nativeEnum(ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(ALL_LOCALES),\n z.array(z.nativeEnum(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 annotations: {\n destructiveHint: true,\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 title: 'Push Dictionaries',\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 annotations: {\n destructiveHint: true,\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 title: 'Pull Dictionaries',\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 annotations: {\n destructiveHint: true,\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 title: 'List Content Declarations',\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 absolute: z\n .boolean()\n .optional()\n .describe(\n 'Output the results as absolute paths instead of relative paths'\n ),\n json: z\n .boolean()\n .optional()\n .describe('Output the results as JSON instead of formatted text'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: props.json\n ? JSON.stringify(rows)\n : 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 title: 'Test Translations',\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 annotations: {\n readOnlyHint: true,\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-extract',\n {\n title: 'Extract strings from Component',\n description:\n 'Extract strings from an existing component to be placed in a .content file close to the component. Trigger this action to make an existing component multilingual. If the component does not exist, create a normal component including text in JSX, and then trigger this tool to extract it.',\n inputSchema: {\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('List of files to extract'),\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 annotations: {\n destructiveHint: true,\n },\n },\n async (props) => {\n try {\n await extract({\n files: Array.isArray(props.file)\n ? props.file\n : props.file\n ? [props.file]\n : undefined,\n configOptions: props.configOptions,\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Extract 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: `Extract failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-projects-list',\n {\n title: 'List Projects',\n description:\n 'List all Intlayer projects in the directory. Search for configuration files to find all Intlayer projects.',\n inputSchema: {\n baseDir: z\n .string()\n .optional()\n .describe('Base directory to search from'),\n gitRoot: z\n .boolean()\n .optional()\n .describe(\n 'Search from the git root directory instead of the base directory'\n ),\n absolute: z\n .boolean()\n .optional()\n .describe(\n 'Output the results as absolute paths instead of relative paths'\n ),\n json: z\n .boolean()\n .optional()\n .describe('Output the results as JSON instead of formatted text'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async (props) => {\n try {\n const { searchDir, projectsPath } = await listProjects({\n baseDir: props.baseDir,\n gitRoot: props.gitRoot,\n });\n\n // Handle absolute option similar to CLI command\n const projectsRelativePath = projectsPath\n .map((projectPath) =>\n props.absolute ? projectPath : relative(searchDir, projectPath)\n )\n .map((projectPath) => (projectPath === '' ? '.' : projectPath));\n\n const outputPaths = props.absolute\n ? projectsPath\n : projectsRelativePath;\n\n return {\n content: [\n {\n type: 'text',\n text: props.json\n ? JSON.stringify(outputPaths)\n : JSON.stringify(\n { searchDir, projectsPath: outputPaths },\n null,\n 2\n ),\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: `Projects list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;AAmBA,MAAa,eAA6B,OAAO,WAAW;CAC1D,OAAO,aACL,iBACA;EACE,OAAO;EACP,aAAa;EACb,aAAa,EACX,aAAa,EAAE,QAAQ,CAAC,SAAS,yBAAyB,EAC3D;EACD,aAAa,EACX,iBAAiB,M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GAC5C,SAAS,EACN,SAAS,CACT,UAAU,CACV,SACC,mEACD;GACH,UAAU,EACP,SAAS,CACT,UAAU,CACV,SACC,iEACD;GACH,MAAM,EACH,SAAS,CACT,UAAU,CACV,SAAS,uDAAuD;GACpE;EACD,aAAa,EACX,cAAc,MACf;EACF,EACD,OAAO,UAAU;EACf,IAAI;GACF,MAAM,EAAE,WAAW,iBAAiB,MAAM,aAAa;IACrD,SAAS,MAAM;IACf,SAAS,MAAM;IAChB,CAAC;GAGF,MAAM,uBAAuB,aAC1B,KAAK,gBACJ,MAAM,WAAW,cAAc,SAAS,WAAW,YAAY,CAChE,CACA,KAAK,gBAAiB,gBAAgB,KAAK,MAAM,YAAa;GAEjE,MAAM,cAAc,MAAM,WACtB,eACA;GAEJ,OAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,MAAM,OACR,KAAK,UAAU,YAAY,GAC3B,KAAK,UACH;KAAE;KAAW,cAAc;KAAa,EACxC,MACA,EACD;IACN,CACF,EACF;WACM,OAAO;GAGd,OAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,yBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { listProjects } from '@intlayer/chokidar/cli';\nimport {\n build,\n extract,\n fill,\n init,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n} from '@intlayer/cli';\nimport { ALL_LOCALES } from '@intlayer/types/allLocales';\nimport z from 'zod';\nimport type { McpServer } from './docs';\n\nconst configOptionsSchema = z\n .object({\n baseDir: z.string().optional().describe('Base directory for the project'),\n env: z.string().optional().describe('Environment name'),\n envFile: z.string().optional().describe('Path to the environment file'),\n override: z\n .object({\n editor: z\n .object({\n clientId: z.string().optional().describe('Intlayer CMS client ID'),\n clientSecret: z\n .string()\n .optional()\n .describe('Intlayer CMS client secret'),\n backendURL: z\n .string()\n .optional()\n .describe('Intlayer CMS backend URL'),\n })\n .optional(),\n internationalization: z\n .object({\n locales: z\n .array(z.nativeEnum(ALL_LOCALES))\n .optional()\n .describe('Available locales'),\n defaultLocale: z\n .nativeEnum(ALL_LOCALES)\n .optional()\n .describe('Default locale'),\n })\n .optional(),\n log: z\n .object({\n mode: z\n .enum(['default', 'verbose', 'disabled'])\n .optional()\n .describe('Log mode'),\n prefix: z.string().optional().describe('Log prefix'),\n })\n .optional(),\n })\n .optional()\n .describe(\n 'Config override - use when running remotely or without a local config file'\n ),\n })\n .optional()\n .describe(\n 'Configuration options. Required when running remotely or when no intlayer config file is present'\n );\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.registerTool(\n 'intlayer-init',\n {\n title: 'Initialize Intlayer',\n description: 'Initialize Intlayer in the project',\n inputSchema: {\n projectRoot: z.string().describe('Project root directory'),\n },\n annotations: {\n destructiveHint: true,\n },\n },\n async ({ projectRoot }) => {\n try {\n await init(projectRoot);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Initialization 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: `Initialization failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-build',\n {\n title: 'Build Dictionaries',\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 configOptions: configOptionsSchema,\n },\n annotations: {\n destructiveHint: true,\n },\n },\n async ({ watch, configOptions }) => {\n try {\n await build({ watch, configOptions });\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 title: 'Fill Translations',\n description:\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n inputSchema: {\n sourceLocale: z\n .nativeEnum(ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(ALL_LOCALES),\n z.array(z.nativeEnum(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 configOptions: configOptionsSchema,\n },\n annotations: {\n destructiveHint: true,\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 title: 'Push Dictionaries',\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 configOptions: configOptionsSchema,\n },\n annotations: {\n destructiveHint: true,\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 title: 'Pull Dictionaries',\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 configOptions: configOptionsSchema,\n },\n annotations: {\n destructiveHint: true,\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 title: 'List Content Declarations',\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: configOptionsSchema,\n absolute: z\n .boolean()\n .optional()\n .describe(\n 'Output the results as absolute paths instead of relative paths'\n ),\n json: z\n .boolean()\n .optional()\n .describe('Output the results as JSON instead of formatted text'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: props.json\n ? JSON.stringify(rows)\n : 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 title: 'Test Translations',\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: configOptionsSchema,\n },\n annotations: {\n readOnlyHint: true,\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-extract',\n {\n title: 'Extract strings from Component',\n description:\n 'Extract strings from an existing component to be placed in a .content file close to the component. Trigger this action to make an existing component multilingual. If the component does not exist, create a normal component including text in JSX, and then trigger this tool to extract it.',\n inputSchema: {\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('List of files to extract'),\n outputContentDeclarations: z\n .string()\n .optional()\n .describe('Path to output content declaration files'),\n configOptions: configOptionsSchema,\n },\n annotations: {\n destructiveHint: true,\n },\n },\n async (props) => {\n try {\n await extract({\n files: Array.isArray(props.file)\n ? props.file\n : props.file\n ? [props.file]\n : undefined,\n configOptions: props.configOptions,\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Extract 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: `Extract failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-projects-list',\n {\n title: 'List Projects',\n description:\n 'List all Intlayer projects in the directory. Search for configuration files to find all Intlayer projects.',\n inputSchema: {\n baseDir: z\n .string()\n .optional()\n .describe('Base directory to search from'),\n gitRoot: z\n .boolean()\n .optional()\n .describe(\n 'Search from the git root directory instead of the base directory'\n ),\n absolute: z\n .boolean()\n .optional()\n .describe(\n 'Output the results as absolute paths instead of relative paths'\n ),\n json: z\n .boolean()\n .optional()\n .describe('Output the results as JSON instead of formatted text'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async (props) => {\n try {\n const { searchDir, projectsPath } = await listProjects({\n baseDir: props.baseDir,\n gitRoot: props.gitRoot,\n });\n\n const projectsRelativePath = projectsPath\n .map((projectPath) =>\n props.absolute ? projectPath : relative(searchDir, projectPath)\n )\n .map((projectPath) => (projectPath === '' ? '.' : projectPath));\n\n const outputPaths = props.absolute\n ? projectsPath\n : projectsRelativePath;\n\n return {\n content: [\n {\n type: 'text',\n text: props.json\n ? JSON.stringify(outputPaths)\n : JSON.stringify(\n { searchDir, projectsPath: outputPaths },\n null,\n 2\n ),\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: `Projects list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;AAgBA,MAAM,sBAAsB,EACzB,OAAO;CACN,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,iCAAiC;CACzE,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,mBAAmB;CACvD,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,+BAA+B;CACvE,UAAU,EACP,OAAO;EACN,QAAQ,EACL,OAAO;GACN,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,yBAAyB;GAClE,cAAc,EACX,QAAQ,CACR,UAAU,CACV,SAAS,6BAA6B;GACzC,YAAY,EACT,QAAQ,CACR,UAAU,CACV,SAAS,2BAA2B;GACxC,CAAC,CACD,UAAU;EACb,sBAAsB,EACnB,OAAO;GACN,SAAS,EACN,MAAM,EAAE,WAAW,YAAY,CAAC,CAChC,UAAU,CACV,SAAS,oBAAoB;GAChC,eAAe,EACZ,WAAW,YAAY,CACvB,UAAU,CACV,SAAS,iBAAiB;GAC9B,CAAC,CACD,UAAU;EACb,KAAK,EACF,OAAO;GACN,MAAM,EACH,KAAK;IAAC;IAAW;IAAW;IAAW,CAAC,CACxC,UAAU,CACV,SAAS,WAAW;GACvB,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,aAAa;GACrD,CAAC,CACD,UAAU;EACd,CAAC,CACD,UAAU,CACV,SACC,6EACD;CACJ,CAAC,CACD,UAAU,CACV,SACC,mGACD;AAIH,MAAa,eAA6B,OAAO,WAAW;CAC1D,OAAO,aACL,iBACA;EACE,OAAO;EACP,aAAa;EACb,aAAa,EACX,aAAa,EAAE,QAAQ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