@i18n-agent/mcp-client 1.8.19 → 1.8.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/mcp-client.js +41 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -346,6 +346,7 @@ Translate text content with cultural adaptation and context awareness.
|
|
|
346
346
|
- `targetLanguage` (string): Target language code
|
|
347
347
|
- `targetAudience` (string): Target audience context
|
|
348
348
|
- `industry` (string): Industry context
|
|
349
|
+
- `namespace` (string, optional): Optional namespace identifier for backend tracking and project organization
|
|
349
350
|
- `sourceLanguage` (string, optional): Source language (auto-detected if not provided)
|
|
350
351
|
- `region` (string, optional): Specific region for localization
|
|
351
352
|
|
|
@@ -356,6 +357,7 @@ Translate files while preserving structure and format.
|
|
|
356
357
|
- `filePath` or `fileContent` (string): File path or content to translate
|
|
357
358
|
- `fileType` (string): File format (json, yaml, xml, csv, txt, md, etc.)
|
|
358
359
|
- `targetLanguage` (string): Target language code
|
|
360
|
+
- `namespace` (string, **required**): Unique namespace identifier for backend tracking and project organization
|
|
359
361
|
- `preserveKeys` (boolean): Whether to preserve object keys/structure
|
|
360
362
|
- `outputFormat` (string): Output format (same, json, yaml, txt)
|
|
361
363
|
|
package/mcp-client.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import axios from 'axios';
|
|
19
19
|
import fs from 'fs';
|
|
20
20
|
import path from 'path';
|
|
21
|
+
import { detectNamespaceFromPath, generateNamespaceSuggestions, getNamespaceSuggestionText } from './namespace-detector.js';
|
|
21
22
|
|
|
22
23
|
const server = new Server(
|
|
23
24
|
{
|
|
@@ -113,6 +114,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
113
114
|
},
|
|
114
115
|
description: 'Configuration options for pseudo-translation',
|
|
115
116
|
},
|
|
117
|
+
namespace: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
description: 'Optional namespace identifier for backend tracking and project organization (recommended for file-based workflows)',
|
|
120
|
+
},
|
|
116
121
|
},
|
|
117
122
|
required: ['texts', 'targetLanguages'],
|
|
118
123
|
},
|
|
@@ -220,8 +225,12 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
220
225
|
},
|
|
221
226
|
description: 'Configuration options for pseudo-translation',
|
|
222
227
|
},
|
|
228
|
+
namespace: {
|
|
229
|
+
type: 'string',
|
|
230
|
+
description: 'Unique namespace identifier for backend tracking and project organization (required for production use)',
|
|
231
|
+
},
|
|
223
232
|
},
|
|
224
|
-
required: ['targetLanguages'],
|
|
233
|
+
required: ['targetLanguages', 'namespace'],
|
|
225
234
|
},
|
|
226
235
|
},
|
|
227
236
|
{
|
|
@@ -436,12 +445,14 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
436
445
|
});
|
|
437
446
|
|
|
438
447
|
async function handleTranslateText(args) {
|
|
439
|
-
const { texts, targetLanguages: rawTargetLanguages, sourceLanguage, targetAudience = 'general', industry = 'technology', region, context, pseudoTranslation, pseudoOptions } = args;
|
|
448
|
+
const { texts, targetLanguages: rawTargetLanguages, sourceLanguage, targetAudience = 'general', industry = 'technology', region, context, pseudoTranslation, pseudoOptions, namespace } = args;
|
|
440
449
|
|
|
441
450
|
if (!texts || !Array.isArray(texts) || texts.length === 0) {
|
|
442
451
|
throw new Error('texts must be a non-empty array');
|
|
443
452
|
}
|
|
444
453
|
|
|
454
|
+
// Namespace is optional for text translation, but recommended for organizational tracking
|
|
455
|
+
|
|
445
456
|
// Normalize targetLanguages - accept both string and array
|
|
446
457
|
let targetLanguages = rawTargetLanguages;
|
|
447
458
|
let targetLanguage = undefined;
|
|
@@ -482,6 +493,7 @@ async function handleTranslateText(args) {
|
|
|
482
493
|
context: context,
|
|
483
494
|
pseudoTranslation: pseudoTranslation,
|
|
484
495
|
pseudoOptions: pseudoOptions,
|
|
496
|
+
namespace: namespace,
|
|
485
497
|
}
|
|
486
498
|
}
|
|
487
499
|
};
|
|
@@ -748,13 +760,36 @@ async function handleTranslateFile(args) {
|
|
|
748
760
|
region,
|
|
749
761
|
context,
|
|
750
762
|
pseudoTranslation,
|
|
751
|
-
pseudoOptions
|
|
763
|
+
pseudoOptions,
|
|
764
|
+
namespace
|
|
752
765
|
} = args;
|
|
753
766
|
|
|
754
767
|
if (!filePath && !fileContent) {
|
|
755
768
|
throw new Error('Either filePath or fileContent must be provided');
|
|
756
769
|
}
|
|
757
770
|
|
|
771
|
+
// Auto-detect namespace if not provided and filePath is available
|
|
772
|
+
let finalNamespace = namespace;
|
|
773
|
+
let detectionInfo = null;
|
|
774
|
+
|
|
775
|
+
if (!namespace && filePath) {
|
|
776
|
+
const detection = detectNamespaceFromPath(filePath);
|
|
777
|
+
if (detection.suggestion && detection.confidence > 0.5) {
|
|
778
|
+
finalNamespace = detection.suggestion;
|
|
779
|
+
detectionInfo = detection;
|
|
780
|
+
console.error(`🎯 [MCP CLIENT] Auto-detected namespace: "${finalNamespace}" (confidence: ${Math.round(detection.confidence * 100)}%, source: ${detection.source})`);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
if (!finalNamespace) {
|
|
785
|
+
// Provide helpful suggestions when namespace is missing
|
|
786
|
+
const suggestionText = filePath
|
|
787
|
+
? getNamespaceSuggestionText(filePath, path.basename(filePath))
|
|
788
|
+
: getNamespaceSuggestionText(null, null);
|
|
789
|
+
|
|
790
|
+
throw new Error(`namespace is required for translation tracking and project organization.\n\n${suggestionText}`);
|
|
791
|
+
}
|
|
792
|
+
|
|
758
793
|
// Normalize targetLanguages - accept both string and array
|
|
759
794
|
let targetLanguages = rawTargetLanguages;
|
|
760
795
|
let targetLanguage = undefined;
|
|
@@ -796,7 +831,8 @@ async function handleTranslateFile(args) {
|
|
|
796
831
|
targetAudience,
|
|
797
832
|
industry,
|
|
798
833
|
preserveKeys,
|
|
799
|
-
outputFormat
|
|
834
|
+
outputFormat,
|
|
835
|
+
namespace: finalNamespace
|
|
800
836
|
};
|
|
801
837
|
|
|
802
838
|
// Add optional parameters only if defined
|
|
@@ -981,7 +1017,7 @@ async function pollTranslationJob(jobId, estimatedTime) {
|
|
|
981
1017
|
|
|
982
1018
|
const response = await axios.post(MCP_SERVER_URL, statusRequest, {
|
|
983
1019
|
headers: { 'Content-Type': 'application/json' },
|
|
984
|
-
timeout:
|
|
1020
|
+
timeout: 30000
|
|
985
1021
|
});
|
|
986
1022
|
|
|
987
1023
|
if (response.data.error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i18n-agent/mcp-client",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.21",
|
|
4
4
|
"description": "🌍 i18n-agent MCP Client - 48 languages, AI-powered translation for Claude, Claude Code, Cursor, VS Code, Codex. Get API key at https://app.i18nagent.ai",
|
|
5
5
|
"main": "mcp-client.js",
|
|
6
6
|
"bin": {
|