@scoutello/i18n-magic 0.52.0 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
5
  import { z } from "zod";
6
- import { addTranslationKey, getMissingKeys, loadConfig } from "./lib/utils.js";
6
+ import { addTranslationKey, getMissingKeys, loadConfig, loadLocalesFile } from "./lib/utils.js";
7
7
  import path from "path";
8
8
  import fs from "fs";
9
9
  import { fileURLToPath } from "url";
@@ -64,6 +64,27 @@ const ListUntranslatedKeysSchema = z.object({
64
64
  .optional()
65
65
  .describe("Optional namespace to check. If not provided, checks all namespaces."),
66
66
  });
67
+ // Zod schema for the get_translation_key tool parameters
68
+ const GetTranslationKeySchema = z.object({
69
+ key: z.string().describe("The translation key to retrieve (e.g., \"welcomeMessage\")"),
70
+ namespace: z
71
+ .string()
72
+ .optional()
73
+ .describe("Optional namespace to search in. If not provided, searches in default namespace first, then all namespaces."),
74
+ });
75
+ // Zod schema for the update_translation_key tool parameters
76
+ const UpdateTranslationKeySchema = z.object({
77
+ key: z.string().describe("The translation key to update (e.g., \"welcomeMessage\")"),
78
+ value: z.string().describe("The new English text value for this translation key"),
79
+ namespace: z
80
+ .string()
81
+ .optional()
82
+ .describe("Optional namespace to update. If not provided, updates the key in all namespaces where it exists."),
83
+ });
84
+ // Zod schema for the search_translations tool parameters
85
+ const SearchTranslationsSchema = z.object({
86
+ query: z.string().describe("Search term to find in translation keys or values (fuzzy search)"),
87
+ });
67
88
  class I18nMagicServer {
68
89
  constructor() {
69
90
  this.config = null;
@@ -150,6 +171,60 @@ class I18nMagicServer {
150
171
  required: [],
151
172
  },
152
173
  },
174
+ {
175
+ name: "get_translation_key",
176
+ description: "Retrieve the English value for a specific translation key. This tool searches for the key in the locale files and always returns the English translation if it exists.",
177
+ inputSchema: {
178
+ type: "object",
179
+ properties: {
180
+ key: {
181
+ type: "string",
182
+ description: "The translation key to retrieve (e.g., \"welcomeMessage\")",
183
+ },
184
+ namespace: {
185
+ type: "string",
186
+ description: "Optional namespace to search in. If not provided, searches in default namespace first, then all namespaces.",
187
+ },
188
+ },
189
+ required: ["key"],
190
+ },
191
+ },
192
+ {
193
+ name: "update_translation_key",
194
+ description: "Update an existing translation key with a new English value. This will update the key across all locales (translating automatically to other languages) and all namespaces where the key exists. Use this when you need to fix typos, improve wording, or change the text of an existing translation. If you're not sure if a key exists, use get_translation_key or search_translations first.",
195
+ inputSchema: {
196
+ type: "object",
197
+ properties: {
198
+ key: {
199
+ type: "string",
200
+ description: "The translation key to update (e.g., \"welcomeMessage\")",
201
+ },
202
+ value: {
203
+ type: "string",
204
+ description: "The new English text value for this translation key",
205
+ },
206
+ namespace: {
207
+ type: "string",
208
+ description: "Optional namespace to update. If not provided, updates the key in all namespaces where it exists.",
209
+ },
210
+ },
211
+ required: ["key", "value"],
212
+ },
213
+ },
214
+ {
215
+ name: "search_translations",
216
+ description: "Search for translations by keyword or phrase across ALL namespaces. This tool performs fuzzy search across both translation keys AND their English values, making it perfect for finding existing translations before adding new ones. Use this to: 1) Check if similar text already exists to avoid duplicates, 2) Find the key name when you only remember part of the text, 3) Discover related translations. Always returns the key name AND English value for each result.",
217
+ inputSchema: {
218
+ type: "object",
219
+ properties: {
220
+ query: {
221
+ type: "string",
222
+ description: "Search term to find in translation keys or values (e.g., 'password', 'welcome', 'click'). Fuzzy search - doesn't need to be exact. Searches across all namespaces.",
223
+ },
224
+ },
225
+ required: ["query"],
226
+ },
227
+ },
153
228
  ],
154
229
  };
155
230
  });
@@ -319,6 +394,360 @@ class I18nMagicServer {
319
394
  };
320
395
  }
321
396
  }
397
+ if (request.params.name === "get_translation_key") {
398
+ try {
399
+ // Validate parameters
400
+ const params = GetTranslationKeySchema.parse(request.params.arguments);
401
+ // Ensure config is loaded
402
+ const config = await this.ensureConfig();
403
+ // Suppress console.log to prevent interference with MCP JSON protocol
404
+ const originalConsoleLog = console.log;
405
+ console.log = () => { };
406
+ let foundValue = null;
407
+ let foundNamespace = null;
408
+ try {
409
+ // If namespace is specified, only check that namespace
410
+ if (params.namespace) {
411
+ const keys = await loadLocalesFile(config.loadPath, "en", params.namespace);
412
+ if (keys[params.key]) {
413
+ foundValue = keys[params.key];
414
+ foundNamespace = params.namespace;
415
+ }
416
+ }
417
+ else {
418
+ // Try default namespace first
419
+ try {
420
+ const keys = await loadLocalesFile(config.loadPath, "en", config.defaultNamespace);
421
+ if (keys[params.key]) {
422
+ foundValue = keys[params.key];
423
+ foundNamespace = config.defaultNamespace;
424
+ }
425
+ }
426
+ catch (error) {
427
+ // Default namespace file doesn't exist or has issues, continue to search other namespaces
428
+ }
429
+ // If not found in default namespace, search all other namespaces
430
+ if (!foundValue) {
431
+ for (const namespace of config.namespaces) {
432
+ if (namespace === config.defaultNamespace)
433
+ continue; // Already checked
434
+ try {
435
+ const keys = await loadLocalesFile(config.loadPath, "en", namespace);
436
+ if (keys[params.key]) {
437
+ foundValue = keys[params.key];
438
+ foundNamespace = namespace;
439
+ break;
440
+ }
441
+ }
442
+ catch (error) {
443
+ // Namespace file doesn't exist or has issues, continue
444
+ }
445
+ }
446
+ }
447
+ }
448
+ }
449
+ finally {
450
+ // Restore console.log
451
+ console.log = originalConsoleLog;
452
+ }
453
+ if (foundValue) {
454
+ return {
455
+ content: [
456
+ {
457
+ type: "text",
458
+ text: JSON.stringify({
459
+ success: true,
460
+ key: params.key,
461
+ value: foundValue,
462
+ namespace: foundNamespace,
463
+ locale: "en",
464
+ }, null, 2),
465
+ },
466
+ ],
467
+ };
468
+ }
469
+ else {
470
+ return {
471
+ content: [
472
+ {
473
+ type: "text",
474
+ text: JSON.stringify({
475
+ success: false,
476
+ error: `Translation key "${params.key}" not found in English locale${params.namespace ? ` (namespace: ${params.namespace})` : ""}`,
477
+ key: params.key,
478
+ searchedNamespace: params.namespace || "all namespaces",
479
+ suggestion: "Use list_untranslated_keys to see all missing keys or add_translation_key to add this key",
480
+ }, null, 2),
481
+ },
482
+ ],
483
+ isError: false,
484
+ };
485
+ }
486
+ }
487
+ catch (error) {
488
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
489
+ // Get more detailed error information
490
+ let errorDetails = errorMessage;
491
+ if (error instanceof Error) {
492
+ const cause = error.cause;
493
+ if (cause instanceof Error) {
494
+ errorDetails = `${errorMessage}\nCause: ${cause.message}\nStack: ${cause.stack}`;
495
+ }
496
+ else if (cause) {
497
+ errorDetails = `${errorMessage}\nCause: ${JSON.stringify(cause)}`;
498
+ }
499
+ if (error.stack) {
500
+ errorDetails = `${errorDetails}\nStack: ${error.stack}`;
501
+ }
502
+ }
503
+ // Log detailed error to stderr for debugging
504
+ console.error(`[i18n-magic MCP] Error getting translation key:`);
505
+ console.error(errorDetails);
506
+ return {
507
+ content: [
508
+ {
509
+ type: "text",
510
+ text: JSON.stringify({
511
+ success: false,
512
+ error: errorMessage,
513
+ details: errorDetails,
514
+ }, null, 2),
515
+ },
516
+ ],
517
+ isError: true,
518
+ };
519
+ }
520
+ }
521
+ if (request.params.name === "update_translation_key") {
522
+ try {
523
+ // Validate parameters
524
+ const params = UpdateTranslationKeySchema.parse(request.params.arguments);
525
+ // Ensure config is loaded
526
+ const config = await this.ensureConfig();
527
+ // Suppress console.log to prevent interference with MCP JSON protocol
528
+ const originalConsoleLog = console.log;
529
+ const logMessages = [];
530
+ console.log = (...args) => {
531
+ const message = args.map(arg => typeof arg === 'object' ? JSON.stringify(arg) : String(arg)).join(' ');
532
+ logMessages.push(message);
533
+ console.error(`[i18n-magic] ${message}`);
534
+ };
535
+ try {
536
+ // Find which namespaces contain this key
537
+ const targetNamespaces = [];
538
+ if (params.namespace) {
539
+ // Check if key exists in specified namespace
540
+ const keys = await loadLocalesFile(config.loadPath, "en", params.namespace);
541
+ if (keys[params.key]) {
542
+ targetNamespaces.push(params.namespace);
543
+ }
544
+ else {
545
+ throw new Error(`Key "${params.key}" does not exist in namespace "${params.namespace}"`);
546
+ }
547
+ }
548
+ else {
549
+ // Find all namespaces where this key exists
550
+ for (const namespace of config.namespaces) {
551
+ try {
552
+ const keys = await loadLocalesFile(config.loadPath, "en", namespace);
553
+ if (keys[params.key]) {
554
+ targetNamespaces.push(namespace);
555
+ }
556
+ }
557
+ catch (error) {
558
+ // Namespace file doesn't exist, continue
559
+ }
560
+ }
561
+ if (targetNamespaces.length === 0) {
562
+ throw new Error(`Key "${params.key}" does not exist in any namespace. Use add_translation_key to create it.`);
563
+ }
564
+ }
565
+ // Build translation cache with new value
566
+ const translationCache = {
567
+ en: params.value,
568
+ };
569
+ // Translate to all other locales
570
+ const nonEnglishLocales = config.locales.filter((l) => l !== "en");
571
+ if (nonEnglishLocales.length > 0 && config.openai) {
572
+ const { translateKey } = await import("./lib/utils.js");
573
+ await Promise.all(nonEnglishLocales.map(async (locale) => {
574
+ const translation = await translateKey({
575
+ context: config.context || "",
576
+ inputLanguage: "en",
577
+ outputLanguage: locale,
578
+ object: {
579
+ [params.key]: params.value,
580
+ },
581
+ openai: config.openai,
582
+ model: config.model,
583
+ });
584
+ translationCache[locale] = translation[params.key];
585
+ }));
586
+ }
587
+ // Update the key in all relevant namespaces and locales
588
+ await Promise.all(targetNamespaces.flatMap((namespace) => config.locales.map(async (locale) => {
589
+ const newValue = translationCache[locale] || params.value;
590
+ const existingKeys = await loadLocalesFile(config.loadPath, locale, namespace);
591
+ existingKeys[params.key] = newValue;
592
+ const { writeLocalesFile } = await import("./lib/utils.js");
593
+ await writeLocalesFile(config.savePath, locale, namespace, existingKeys);
594
+ })));
595
+ return {
596
+ content: [
597
+ {
598
+ type: "text",
599
+ text: JSON.stringify({
600
+ success: true,
601
+ message: `Successfully updated translation key "${params.key}" in ${targetNamespaces.length} namespace(s) and ${config.locales.length} locale(s)`,
602
+ key: params.key,
603
+ newValue: params.value,
604
+ namespaces: targetNamespaces,
605
+ locales: config.locales,
606
+ diagnostics: logMessages.join('\n'),
607
+ }, null, 2),
608
+ },
609
+ ],
610
+ };
611
+ }
612
+ finally {
613
+ // Restore console.log
614
+ console.log = originalConsoleLog;
615
+ }
616
+ }
617
+ catch (error) {
618
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
619
+ let errorDetails = errorMessage;
620
+ if (error instanceof Error && error.stack) {
621
+ errorDetails = `${errorDetails}\nStack: ${error.stack}`;
622
+ }
623
+ console.error(`[i18n-magic MCP] Error updating translation key:`);
624
+ console.error(errorDetails);
625
+ return {
626
+ content: [
627
+ {
628
+ type: "text",
629
+ text: JSON.stringify({
630
+ success: false,
631
+ error: errorMessage,
632
+ details: errorDetails,
633
+ }, null, 2),
634
+ },
635
+ ],
636
+ isError: true,
637
+ };
638
+ }
639
+ }
640
+ if (request.params.name === "search_translations") {
641
+ try {
642
+ // Validate parameters
643
+ const params = SearchTranslationsSchema.parse(request.params.arguments);
644
+ // Ensure config is loaded
645
+ const config = await this.ensureConfig();
646
+ // Suppress console.log
647
+ const originalConsoleLog = console.log;
648
+ console.log = () => { };
649
+ try {
650
+ const searchQuery = params.query.toLowerCase();
651
+ const results = [];
652
+ // Search through all namespaces
653
+ for (const namespace of config.namespaces) {
654
+ try {
655
+ const keys = await loadLocalesFile(config.loadPath, "en", namespace);
656
+ for (const [key, value] of Object.entries(keys)) {
657
+ const keyLower = key.toLowerCase();
658
+ const valueLower = value.toLowerCase();
659
+ // Fuzzy matching: check if search query is contained in key or value
660
+ const keyMatch = keyLower.includes(searchQuery);
661
+ const valueMatch = valueLower.includes(searchQuery);
662
+ if (keyMatch || valueMatch) {
663
+ results.push({
664
+ key,
665
+ value,
666
+ namespace,
667
+ matchType: keyMatch && valueMatch ? "both" : keyMatch ? "key" : "value",
668
+ });
669
+ }
670
+ }
671
+ }
672
+ catch (error) {
673
+ // Namespace file doesn't exist or has issues, continue
674
+ }
675
+ }
676
+ // Sort results: exact matches first, then by match type, then alphabetically
677
+ results.sort((a, b) => {
678
+ // Prioritize exact key matches
679
+ const aExactKey = a.key.toLowerCase() === searchQuery;
680
+ const bExactKey = b.key.toLowerCase() === searchQuery;
681
+ if (aExactKey && !bExactKey)
682
+ return -1;
683
+ if (!aExactKey && bExactKey)
684
+ return 1;
685
+ // Prioritize exact value matches
686
+ const aExactValue = a.value.toLowerCase() === searchQuery;
687
+ const bExactValue = b.value.toLowerCase() === searchQuery;
688
+ if (aExactValue && !bExactValue)
689
+ return -1;
690
+ if (!aExactValue && bExactValue)
691
+ return 1;
692
+ // Then by match type (both > key > value)
693
+ const matchOrder = { both: 0, key: 1, value: 2 };
694
+ const matchCompare = matchOrder[a.matchType] - matchOrder[b.matchType];
695
+ if (matchCompare !== 0)
696
+ return matchCompare;
697
+ // Finally alphabetically by key
698
+ return a.key.localeCompare(b.key);
699
+ });
700
+ // Limit results to prevent overwhelming output
701
+ const maxResults = 50;
702
+ const limitedResults = results.slice(0, maxResults);
703
+ const hasMore = results.length > maxResults;
704
+ return {
705
+ content: [
706
+ {
707
+ type: "text",
708
+ text: JSON.stringify({
709
+ success: true,
710
+ message: results.length === 0
711
+ ? `No translations found matching "${params.query}"`
712
+ : `Found ${results.length} translation${results.length === 1 ? "" : "s"} matching "${params.query}"${hasMore ? ` (showing first ${maxResults})` : ""}`,
713
+ query: params.query,
714
+ totalResults: results.length,
715
+ results: limitedResults,
716
+ hasMore,
717
+ tip: "Each result shows the translation key, English value, namespace, and what matched (key, value, or both). Use these keys directly in your code or use get_translation_key for more details.",
718
+ }, null, 2),
719
+ },
720
+ ],
721
+ };
722
+ }
723
+ finally {
724
+ // Restore console.log
725
+ console.log = originalConsoleLog;
726
+ }
727
+ }
728
+ catch (error) {
729
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
730
+ let errorDetails = errorMessage;
731
+ if (error instanceof Error && error.stack) {
732
+ errorDetails = `${errorDetails}\nStack: ${error.stack}`;
733
+ }
734
+ console.error(`[i18n-magic MCP] Error searching translations:`);
735
+ console.error(errorDetails);
736
+ return {
737
+ content: [
738
+ {
739
+ type: "text",
740
+ text: JSON.stringify({
741
+ success: false,
742
+ error: errorMessage,
743
+ details: errorDetails,
744
+ }, null, 2),
745
+ },
746
+ ],
747
+ isError: true,
748
+ };
749
+ }
750
+ }
322
751
  throw new Error(`Unknown tool: ${request.params.name}`);
323
752
  });
324
753
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE9E,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,yCAAyC;AACzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C,oEAAoE;AACpE,SAAS,eAAe,CAAC,QAAgB;IACvC,IAAI,UAAU,GAAG,QAAQ,CAAA;IACzB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAA;IAExC,OAAO,UAAU,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,e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3
+ "version": "0.53.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Intelligent CLI toolkit that automates internationalization workflows with AI-powered translations for JavaScript/TypeScript projects",
package/src/mcp-server.ts CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  ListToolsRequestSchema,
6
6
  } from "@modelcontextprotocol/sdk/types.js"
7
7
  import { z } from "zod"
8
- import { addTranslationKey, getMissingKeys, loadConfig } from "./lib/utils.js"
8
+ import { addTranslationKey, getMissingKeys, loadConfig, loadLocalesFile } from "./lib/utils.js"
9
9
  import type { Configuration } from "./lib/types.js"
10
10
  import path from "path"
11
11
  import fs from "fs"
@@ -80,6 +80,34 @@ const ListUntranslatedKeysSchema = z.object({
80
80
  ),
81
81
  })
82
82
 
83
+ // Zod schema for the get_translation_key tool parameters
84
+ const GetTranslationKeySchema = z.object({
85
+ key: z.string().describe("The translation key to retrieve (e.g., \"welcomeMessage\")"),
86
+ namespace: z
87
+ .string()
88
+ .optional()
89
+ .describe(
90
+ "Optional namespace to search in. If not provided, searches in default namespace first, then all namespaces.",
91
+ ),
92
+ })
93
+
94
+ // Zod schema for the update_translation_key tool parameters
95
+ const UpdateTranslationKeySchema = z.object({
96
+ key: z.string().describe("The translation key to update (e.g., \"welcomeMessage\")"),
97
+ value: z.string().describe("The new English text value for this translation key"),
98
+ namespace: z
99
+ .string()
100
+ .optional()
101
+ .describe(
102
+ "Optional namespace to update. If not provided, updates the key in all namespaces where it exists.",
103
+ ),
104
+ })
105
+
106
+ // Zod schema for the search_translations tool parameters
107
+ const SearchTranslationsSchema = z.object({
108
+ query: z.string().describe("Search term to find in translation keys or values (fuzzy search)"),
109
+ })
110
+
83
111
  class I18nMagicServer {
84
112
  private server: Server
85
113
  private config: Configuration | null = null
@@ -188,6 +216,69 @@ class I18nMagicServer {
188
216
  required: [],
189
217
  },
190
218
  },
219
+ {
220
+ name: "get_translation_key",
221
+ description:
222
+ "Retrieve the English value for a specific translation key. This tool searches for the key in the locale files and always returns the English translation if it exists.",
223
+ inputSchema: {
224
+ type: "object",
225
+ properties: {
226
+ key: {
227
+ type: "string",
228
+ description:
229
+ "The translation key to retrieve (e.g., \"welcomeMessage\")",
230
+ },
231
+ namespace: {
232
+ type: "string",
233
+ description:
234
+ "Optional namespace to search in. If not provided, searches in default namespace first, then all namespaces.",
235
+ },
236
+ },
237
+ required: ["key"],
238
+ },
239
+ },
240
+ {
241
+ name: "update_translation_key",
242
+ description:
243
+ "Update an existing translation key with a new English value. This will update the key across all locales (translating automatically to other languages) and all namespaces where the key exists. Use this when you need to fix typos, improve wording, or change the text of an existing translation. If you're not sure if a key exists, use get_translation_key or search_translations first.",
244
+ inputSchema: {
245
+ type: "object",
246
+ properties: {
247
+ key: {
248
+ type: "string",
249
+ description:
250
+ "The translation key to update (e.g., \"welcomeMessage\")",
251
+ },
252
+ value: {
253
+ type: "string",
254
+ description:
255
+ "The new English text value for this translation key",
256
+ },
257
+ namespace: {
258
+ type: "string",
259
+ description:
260
+ "Optional namespace to update. If not provided, updates the key in all namespaces where it exists.",
261
+ },
262
+ },
263
+ required: ["key", "value"],
264
+ },
265
+ },
266
+ {
267
+ name: "search_translations",
268
+ description:
269
+ "Search for translations by keyword or phrase across ALL namespaces. This tool performs fuzzy search across both translation keys AND their English values, making it perfect for finding existing translations before adding new ones. Use this to: 1) Check if similar text already exists to avoid duplicates, 2) Find the key name when you only remember part of the text, 3) Discover related translations. Always returns the key name AND English value for each result.",
270
+ inputSchema: {
271
+ type: "object",
272
+ properties: {
273
+ query: {
274
+ type: "string",
275
+ description:
276
+ "Search term to find in translation keys or values (e.g., 'password', 'welcome', 'click'). Fuzzy search - doesn't need to be exact. Searches across all namespaces.",
277
+ },
278
+ },
279
+ required: ["query"],
280
+ },
281
+ },
191
282
  ],
192
283
  }
193
284
  })
@@ -396,6 +487,431 @@ class I18nMagicServer {
396
487
  }
397
488
  }
398
489
 
490
+ if (request.params.name === "get_translation_key") {
491
+ try {
492
+ // Validate parameters
493
+ const params = GetTranslationKeySchema.parse(
494
+ request.params.arguments,
495
+ )
496
+
497
+ // Ensure config is loaded
498
+ const config = await this.ensureConfig()
499
+
500
+ // Suppress console.log to prevent interference with MCP JSON protocol
501
+ const originalConsoleLog = console.log
502
+ console.log = () => {}
503
+
504
+ let foundValue: string | null = null
505
+ let foundNamespace: string | null = null
506
+
507
+ try {
508
+ // If namespace is specified, only check that namespace
509
+ if (params.namespace) {
510
+ const keys = await loadLocalesFile(config.loadPath, "en", params.namespace)
511
+ if (keys[params.key]) {
512
+ foundValue = keys[params.key]
513
+ foundNamespace = params.namespace
514
+ }
515
+ } else {
516
+ // Try default namespace first
517
+ try {
518
+ const keys = await loadLocalesFile(config.loadPath, "en", config.defaultNamespace)
519
+ if (keys[params.key]) {
520
+ foundValue = keys[params.key]
521
+ foundNamespace = config.defaultNamespace
522
+ }
523
+ } catch (error) {
524
+ // Default namespace file doesn't exist or has issues, continue to search other namespaces
525
+ }
526
+
527
+ // If not found in default namespace, search all other namespaces
528
+ if (!foundValue) {
529
+ for (const namespace of config.namespaces) {
530
+ if (namespace === config.defaultNamespace) continue // Already checked
531
+
532
+ try {
533
+ const keys = await loadLocalesFile(config.loadPath, "en", namespace)
534
+ if (keys[params.key]) {
535
+ foundValue = keys[params.key]
536
+ foundNamespace = namespace
537
+ break
538
+ }
539
+ } catch (error) {
540
+ // Namespace file doesn't exist or has issues, continue
541
+ }
542
+ }
543
+ }
544
+ }
545
+ } finally {
546
+ // Restore console.log
547
+ console.log = originalConsoleLog
548
+ }
549
+
550
+ if (foundValue) {
551
+ return {
552
+ content: [
553
+ {
554
+ type: "text",
555
+ text: JSON.stringify(
556
+ {
557
+ success: true,
558
+ key: params.key,
559
+ value: foundValue,
560
+ namespace: foundNamespace,
561
+ locale: "en",
562
+ },
563
+ null,
564
+ 2,
565
+ ),
566
+ },
567
+ ],
568
+ }
569
+ } else {
570
+ return {
571
+ content: [
572
+ {
573
+ type: "text",
574
+ text: JSON.stringify(
575
+ {
576
+ success: false,
577
+ error: `Translation key "${params.key}" not found in English locale${params.namespace ? ` (namespace: ${params.namespace})` : ""}`,
578
+ key: params.key,
579
+ searchedNamespace: params.namespace || "all namespaces",
580
+ suggestion: "Use list_untranslated_keys to see all missing keys or add_translation_key to add this key",
581
+ },
582
+ null,
583
+ 2,
584
+ ),
585
+ },
586
+ ],
587
+ isError: false,
588
+ }
589
+ }
590
+ } catch (error) {
591
+ const errorMessage =
592
+ error instanceof Error ? error.message : "Unknown error occurred"
593
+
594
+ // Get more detailed error information
595
+ let errorDetails = errorMessage
596
+ if (error instanceof Error) {
597
+ const cause = (error as any).cause
598
+ if (cause instanceof Error) {
599
+ errorDetails = `${errorMessage}\nCause: ${cause.message}\nStack: ${cause.stack}`
600
+ } else if (cause) {
601
+ errorDetails = `${errorMessage}\nCause: ${JSON.stringify(cause)}`
602
+ }
603
+ if (error.stack) {
604
+ errorDetails = `${errorDetails}\nStack: ${error.stack}`
605
+ }
606
+ }
607
+
608
+ // Log detailed error to stderr for debugging
609
+ console.error(`[i18n-magic MCP] Error getting translation key:`)
610
+ console.error(errorDetails)
611
+
612
+ return {
613
+ content: [
614
+ {
615
+ type: "text",
616
+ text: JSON.stringify(
617
+ {
618
+ success: false,
619
+ error: errorMessage,
620
+ details: errorDetails,
621
+ },
622
+ null,
623
+ 2,
624
+ ),
625
+ },
626
+ ],
627
+ isError: true,
628
+ }
629
+ }
630
+ }
631
+
632
+ if (request.params.name === "update_translation_key") {
633
+ try {
634
+ // Validate parameters
635
+ const params = UpdateTranslationKeySchema.parse(
636
+ request.params.arguments,
637
+ )
638
+
639
+ // Ensure config is loaded
640
+ const config = await this.ensureConfig()
641
+
642
+ // Suppress console.log to prevent interference with MCP JSON protocol
643
+ const originalConsoleLog = console.log
644
+ const logMessages: string[] = []
645
+ console.log = (...args: any[]) => {
646
+ const message = args.map(arg =>
647
+ typeof arg === 'object' ? JSON.stringify(arg) : String(arg)
648
+ ).join(' ')
649
+ logMessages.push(message)
650
+ console.error(`[i18n-magic] ${message}`)
651
+ }
652
+
653
+ try {
654
+ // Find which namespaces contain this key
655
+ const targetNamespaces: string[] = []
656
+
657
+ if (params.namespace) {
658
+ // Check if key exists in specified namespace
659
+ const keys = await loadLocalesFile(config.loadPath, "en", params.namespace)
660
+ if (keys[params.key]) {
661
+ targetNamespaces.push(params.namespace)
662
+ } else {
663
+ throw new Error(`Key "${params.key}" does not exist in namespace "${params.namespace}"`)
664
+ }
665
+ } else {
666
+ // Find all namespaces where this key exists
667
+ for (const namespace of config.namespaces) {
668
+ try {
669
+ const keys = await loadLocalesFile(config.loadPath, "en", namespace)
670
+ if (keys[params.key]) {
671
+ targetNamespaces.push(namespace)
672
+ }
673
+ } catch (error) {
674
+ // Namespace file doesn't exist, continue
675
+ }
676
+ }
677
+
678
+ if (targetNamespaces.length === 0) {
679
+ throw new Error(`Key "${params.key}" does not exist in any namespace. Use add_translation_key to create it.`)
680
+ }
681
+ }
682
+
683
+ // Build translation cache with new value
684
+ const translationCache: Record<string, string> = {
685
+ en: params.value,
686
+ }
687
+
688
+ // Translate to all other locales
689
+ const nonEnglishLocales = config.locales.filter((l) => l !== "en")
690
+ if (nonEnglishLocales.length > 0 && config.openai) {
691
+ const { translateKey } = await import("./lib/utils.js")
692
+
693
+ await Promise.all(
694
+ nonEnglishLocales.map(async (locale) => {
695
+ const translation = await translateKey({
696
+ context: config.context || "",
697
+ inputLanguage: "en",
698
+ outputLanguage: locale,
699
+ object: {
700
+ [params.key]: params.value,
701
+ },
702
+ openai: config.openai!,
703
+ model: config.model,
704
+ })
705
+ translationCache[locale] = translation[params.key]
706
+ })
707
+ )
708
+ }
709
+
710
+ // Update the key in all relevant namespaces and locales
711
+ await Promise.all(
712
+ targetNamespaces.flatMap((namespace) =>
713
+ config.locales.map(async (locale) => {
714
+ const newValue = translationCache[locale] || params.value
715
+ const existingKeys = await loadLocalesFile(config.loadPath, locale, namespace)
716
+ existingKeys[params.key] = newValue
717
+ const { writeLocalesFile } = await import("./lib/utils.js")
718
+ await writeLocalesFile(config.savePath, locale, namespace, existingKeys)
719
+ })
720
+ )
721
+ )
722
+
723
+ return {
724
+ content: [
725
+ {
726
+ type: "text",
727
+ text: JSON.stringify(
728
+ {
729
+ success: true,
730
+ message: `Successfully updated translation key "${params.key}" in ${targetNamespaces.length} namespace(s) and ${config.locales.length} locale(s)`,
731
+ key: params.key,
732
+ newValue: params.value,
733
+ namespaces: targetNamespaces,
734
+ locales: config.locales,
735
+ diagnostics: logMessages.join('\n'),
736
+ },
737
+ null,
738
+ 2,
739
+ ),
740
+ },
741
+ ],
742
+ }
743
+ } finally {
744
+ // Restore console.log
745
+ console.log = originalConsoleLog
746
+ }
747
+ } catch (error) {
748
+ const errorMessage =
749
+ error instanceof Error ? error.message : "Unknown error occurred"
750
+
751
+ let errorDetails = errorMessage
752
+ if (error instanceof Error && error.stack) {
753
+ errorDetails = `${errorDetails}\nStack: ${error.stack}`
754
+ }
755
+
756
+ console.error(`[i18n-magic MCP] Error updating translation key:`)
757
+ console.error(errorDetails)
758
+
759
+ return {
760
+ content: [
761
+ {
762
+ type: "text",
763
+ text: JSON.stringify(
764
+ {
765
+ success: false,
766
+ error: errorMessage,
767
+ details: errorDetails,
768
+ },
769
+ null,
770
+ 2,
771
+ ),
772
+ },
773
+ ],
774
+ isError: true,
775
+ }
776
+ }
777
+ }
778
+
779
+ if (request.params.name === "search_translations") {
780
+ try {
781
+ // Validate parameters
782
+ const params = SearchTranslationsSchema.parse(
783
+ request.params.arguments,
784
+ )
785
+
786
+ // Ensure config is loaded
787
+ const config = await this.ensureConfig()
788
+
789
+ // Suppress console.log
790
+ const originalConsoleLog = console.log
791
+ console.log = () => {}
792
+
793
+ try {
794
+ const searchQuery = params.query.toLowerCase()
795
+ const results: Array<{
796
+ key: string
797
+ value: string
798
+ namespace: string
799
+ matchType: "key" | "value" | "both"
800
+ }> = []
801
+
802
+ // Search through all namespaces
803
+ for (const namespace of config.namespaces) {
804
+ try {
805
+ const keys = await loadLocalesFile(config.loadPath, "en", namespace)
806
+
807
+ for (const [key, value] of Object.entries(keys)) {
808
+ const keyLower = key.toLowerCase()
809
+ const valueLower = value.toLowerCase()
810
+
811
+ // Fuzzy matching: check if search query is contained in key or value
812
+ const keyMatch = keyLower.includes(searchQuery)
813
+ const valueMatch = valueLower.includes(searchQuery)
814
+
815
+ if (keyMatch || valueMatch) {
816
+ results.push({
817
+ key,
818
+ value,
819
+ namespace,
820
+ matchType: keyMatch && valueMatch ? "both" : keyMatch ? "key" : "value",
821
+ })
822
+ }
823
+ }
824
+ } catch (error) {
825
+ // Namespace file doesn't exist or has issues, continue
826
+ }
827
+ }
828
+
829
+ // Sort results: exact matches first, then by match type, then alphabetically
830
+ results.sort((a, b) => {
831
+ // Prioritize exact key matches
832
+ const aExactKey = a.key.toLowerCase() === searchQuery
833
+ const bExactKey = b.key.toLowerCase() === searchQuery
834
+ if (aExactKey && !bExactKey) return -1
835
+ if (!aExactKey && bExactKey) return 1
836
+
837
+ // Prioritize exact value matches
838
+ const aExactValue = a.value.toLowerCase() === searchQuery
839
+ const bExactValue = b.value.toLowerCase() === searchQuery
840
+ if (aExactValue && !bExactValue) return -1
841
+ if (!aExactValue && bExactValue) return 1
842
+
843
+ // Then by match type (both > key > value)
844
+ const matchOrder = { both: 0, key: 1, value: 2 }
845
+ const matchCompare = matchOrder[a.matchType] - matchOrder[b.matchType]
846
+ if (matchCompare !== 0) return matchCompare
847
+
848
+ // Finally alphabetically by key
849
+ return a.key.localeCompare(b.key)
850
+ })
851
+
852
+ // Limit results to prevent overwhelming output
853
+ const maxResults = 50
854
+ const limitedResults = results.slice(0, maxResults)
855
+ const hasMore = results.length > maxResults
856
+
857
+ return {
858
+ content: [
859
+ {
860
+ type: "text",
861
+ text: JSON.stringify(
862
+ {
863
+ success: true,
864
+ message: results.length === 0
865
+ ? `No translations found matching "${params.query}"`
866
+ : `Found ${results.length} translation${results.length === 1 ? "" : "s"} matching "${params.query}"${hasMore ? ` (showing first ${maxResults})` : ""}`,
867
+ query: params.query,
868
+ totalResults: results.length,
869
+ results: limitedResults,
870
+ hasMore,
871
+ tip: "Each result shows the translation key, English value, namespace, and what matched (key, value, or both). Use these keys directly in your code or use get_translation_key for more details.",
872
+ },
873
+ null,
874
+ 2,
875
+ ),
876
+ },
877
+ ],
878
+ }
879
+ } finally {
880
+ // Restore console.log
881
+ console.log = originalConsoleLog
882
+ }
883
+ } catch (error) {
884
+ const errorMessage =
885
+ error instanceof Error ? error.message : "Unknown error occurred"
886
+
887
+ let errorDetails = errorMessage
888
+ if (error instanceof Error && error.stack) {
889
+ errorDetails = `${errorDetails}\nStack: ${error.stack}`
890
+ }
891
+
892
+ console.error(`[i18n-magic MCP] Error searching translations:`)
893
+ console.error(errorDetails)
894
+
895
+ return {
896
+ content: [
897
+ {
898
+ type: "text",
899
+ text: JSON.stringify(
900
+ {
901
+ success: false,
902
+ error: errorMessage,
903
+ details: errorDetails,
904
+ },
905
+ null,
906
+ 2,
907
+ ),
908
+ },
909
+ ],
910
+ isError: true,
911
+ }
912
+ }
913
+ }
914
+
399
915
  throw new Error(`Unknown tool: ${request.params.name}`)
400
916
  })
401
917
  }