@i18n-agent/mcp-client 1.8.20 → 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 +1 -1
- package/mcp-client.js +25 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -346,7 +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,
|
|
349
|
+
- `namespace` (string, optional): Optional namespace identifier for backend tracking and project organization
|
|
350
350
|
- `sourceLanguage` (string, optional): Source language (auto-detected if not provided)
|
|
351
351
|
- `region` (string, optional): Specific region for localization
|
|
352
352
|
|
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
|
{
|
|
@@ -115,10 +116,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
115
116
|
},
|
|
116
117
|
namespace: {
|
|
117
118
|
type: 'string',
|
|
118
|
-
description: '
|
|
119
|
+
description: 'Optional namespace identifier for backend tracking and project organization (recommended for file-based workflows)',
|
|
119
120
|
},
|
|
120
121
|
},
|
|
121
|
-
required: ['texts', 'targetLanguages'
|
|
122
|
+
required: ['texts', 'targetLanguages'],
|
|
122
123
|
},
|
|
123
124
|
},
|
|
124
125
|
{
|
|
@@ -450,9 +451,7 @@ async function handleTranslateText(args) {
|
|
|
450
451
|
throw new Error('texts must be a non-empty array');
|
|
451
452
|
}
|
|
452
453
|
|
|
453
|
-
|
|
454
|
-
throw new Error('namespace is required for translation tracking and project organization');
|
|
455
|
-
}
|
|
454
|
+
// Namespace is optional for text translation, but recommended for organizational tracking
|
|
456
455
|
|
|
457
456
|
// Normalize targetLanguages - accept both string and array
|
|
458
457
|
let targetLanguages = rawTargetLanguages;
|
|
@@ -769,8 +768,26 @@ async function handleTranslateFile(args) {
|
|
|
769
768
|
throw new Error('Either filePath or fileContent must be provided');
|
|
770
769
|
}
|
|
771
770
|
|
|
772
|
-
|
|
773
|
-
|
|
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}`);
|
|
774
791
|
}
|
|
775
792
|
|
|
776
793
|
// Normalize targetLanguages - accept both string and array
|
|
@@ -815,7 +832,7 @@ async function handleTranslateFile(args) {
|
|
|
815
832
|
industry,
|
|
816
833
|
preserveKeys,
|
|
817
834
|
outputFormat,
|
|
818
|
-
namespace
|
|
835
|
+
namespace: finalNamespace
|
|
819
836
|
};
|
|
820
837
|
|
|
821
838
|
// Add optional parameters only if defined
|
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": {
|