@i18n-agent/mcp-client 1.7.4 → 1.7.5
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/mcp-client.js +43 -34
- package/package.json +1 -1
package/mcp-client.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Integrates with Claude Code CLI to provide translation capabilities
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
const MCP_CLIENT_VERSION = '1.7.
|
|
8
|
+
const MCP_CLIENT_VERSION = '1.7.5';
|
|
9
9
|
|
|
10
10
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
11
11
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
@@ -47,7 +47,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
47
47
|
tools: [
|
|
48
48
|
{
|
|
49
49
|
name: 'translate_text',
|
|
50
|
-
description: '⚠️
|
|
50
|
+
description: '⚠️ CRITICAL: For multi-language translation, use targetLanguages parameter (not targetLanguage). Translate text content with cultural adaptation using AI subagents. Supports both single and multi-language translation. For large requests (>100 texts or >50,000 characters), returns a jobId for async processing. Use check_translation_status to monitor progress and download results.',
|
|
51
51
|
inputSchema: {
|
|
52
52
|
type: 'object',
|
|
53
53
|
properties: {
|
|
@@ -56,14 +56,12 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
56
56
|
items: { type: 'string' },
|
|
57
57
|
description: 'Array of source texts to translate (any language)',
|
|
58
58
|
},
|
|
59
|
-
targetLanguage: {
|
|
60
|
-
type: 'string',
|
|
61
|
-
description: '⚠️ REQUIRED (if targetLanguages not provided): Target language code for single language translation (e.g., "es", "fr", "zh-CN")',
|
|
62
|
-
},
|
|
63
59
|
targetLanguages: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
description: '⚠️ REQUIRED: Target language(s) - can be a single string (e.g., "es") OR an array of strings (e.g., ["es", "fr", "zh-CN"]) for multi-language translation',
|
|
61
|
+
oneOf: [
|
|
62
|
+
{ type: 'string' },
|
|
63
|
+
{ type: 'array', items: { type: 'string' } }
|
|
64
|
+
]
|
|
67
65
|
},
|
|
68
66
|
sourceLanguage: {
|
|
69
67
|
type: 'string',
|
|
@@ -86,7 +84,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
86
84
|
description: 'Optional additional context or instructions for the translation (e.g., "Keep technical terms in English", "Use formal tone")',
|
|
87
85
|
},
|
|
88
86
|
},
|
|
89
|
-
required: ['texts'],
|
|
87
|
+
required: ['texts', 'targetLanguages'],
|
|
90
88
|
},
|
|
91
89
|
},
|
|
92
90
|
{
|
|
@@ -105,7 +103,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
105
103
|
},
|
|
106
104
|
{
|
|
107
105
|
name: 'translate_file',
|
|
108
|
-
description: '⚠️
|
|
106
|
+
description: '⚠️ CRITICAL: For multi-language translation, use targetLanguages parameter (not targetLanguage). Translate file content while preserving structure and format. Supports both single and multi-language translation. Supports JSON, YAML, XML, CSV, TXT, MD, and other text files. For large files (>100KB), returns a jobId for async processing. Use check_translation_status to monitor progress and download results.',
|
|
109
107
|
inputSchema: {
|
|
110
108
|
type: 'object',
|
|
111
109
|
properties: {
|
|
@@ -123,14 +121,12 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
123
121
|
enum: ['json', 'yaml', 'yml', 'xml', 'csv', 'txt', 'md', 'html', 'properties', 'auto'],
|
|
124
122
|
default: 'auto',
|
|
125
123
|
},
|
|
126
|
-
targetLanguage: {
|
|
127
|
-
type: 'string',
|
|
128
|
-
description: '⚠️ REQUIRED (if targetLanguages not provided): Target language code or name - for single language translation (e.g., "es", "fr", "de")',
|
|
129
|
-
},
|
|
130
124
|
targetLanguages: {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
description: '⚠️ REQUIRED: Target language(s) - can be a single string (e.g., "es") OR an array of strings (e.g., ["es", "fr", "zh-CN"]) for multi-language translation',
|
|
126
|
+
oneOf: [
|
|
127
|
+
{ type: 'string' },
|
|
128
|
+
{ type: 'array', items: { type: 'string' } }
|
|
129
|
+
]
|
|
134
130
|
},
|
|
135
131
|
targetAudience: {
|
|
136
132
|
type: 'string',
|
|
@@ -165,7 +161,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
165
161
|
description: 'Optional additional context or instructions for the translation (e.g., "Keep technical terms in English", "Use formal tone")',
|
|
166
162
|
},
|
|
167
163
|
},
|
|
168
|
-
required: [],
|
|
164
|
+
required: ['targetLanguages'],
|
|
169
165
|
},
|
|
170
166
|
},
|
|
171
167
|
{
|
|
@@ -289,20 +285,27 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
289
285
|
});
|
|
290
286
|
|
|
291
287
|
async function handleTranslateText(args) {
|
|
292
|
-
const { texts,
|
|
288
|
+
const { texts, targetLanguages: rawTargetLanguages, sourceLanguage, targetAudience = 'general', industry = 'technology', region, context } = args;
|
|
293
289
|
|
|
294
290
|
if (!texts || !Array.isArray(texts) || texts.length === 0) {
|
|
295
291
|
throw new Error('texts must be a non-empty array');
|
|
296
292
|
}
|
|
297
293
|
|
|
298
|
-
//
|
|
299
|
-
|
|
300
|
-
|
|
294
|
+
// Normalize targetLanguages - accept both string and array
|
|
295
|
+
let targetLanguages = rawTargetLanguages;
|
|
296
|
+
let targetLanguage = undefined;
|
|
297
|
+
|
|
298
|
+
if (typeof rawTargetLanguages === 'string') {
|
|
299
|
+
// Single language provided as string - convert to array for internal processing
|
|
300
|
+
targetLanguages = [rawTargetLanguages];
|
|
301
|
+
targetLanguage = rawTargetLanguages;
|
|
302
|
+
} else if (Array.isArray(rawTargetLanguages) && rawTargetLanguages.length === 1) {
|
|
303
|
+
// Single language provided as array - extract for backward compatibility
|
|
304
|
+
targetLanguage = rawTargetLanguages[0];
|
|
301
305
|
}
|
|
302
306
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
throw new Error('Cannot specify both targetLanguage and targetLanguages');
|
|
307
|
+
if (!targetLanguages?.length) {
|
|
308
|
+
throw new Error('targetLanguages parameter is required (can be a string for single language or array for multiple languages)');
|
|
306
309
|
}
|
|
307
310
|
|
|
308
311
|
// Check if this is a large translation request
|
|
@@ -578,8 +581,7 @@ async function handleTranslateFile(args) {
|
|
|
578
581
|
filePath,
|
|
579
582
|
fileContent,
|
|
580
583
|
fileType = 'auto',
|
|
581
|
-
|
|
582
|
-
targetLanguages,
|
|
584
|
+
targetLanguages: rawTargetLanguages,
|
|
583
585
|
targetAudience = 'general',
|
|
584
586
|
industry = 'technology',
|
|
585
587
|
preserveKeys = true,
|
|
@@ -593,14 +595,21 @@ async function handleTranslateFile(args) {
|
|
|
593
595
|
throw new Error('Either filePath or fileContent must be provided');
|
|
594
596
|
}
|
|
595
597
|
|
|
596
|
-
//
|
|
597
|
-
|
|
598
|
-
|
|
598
|
+
// Normalize targetLanguages - accept both string and array
|
|
599
|
+
let targetLanguages = rawTargetLanguages;
|
|
600
|
+
let targetLanguage = undefined;
|
|
601
|
+
|
|
602
|
+
if (typeof rawTargetLanguages === 'string') {
|
|
603
|
+
// Single language provided as string - convert to array for internal processing
|
|
604
|
+
targetLanguages = [rawTargetLanguages];
|
|
605
|
+
targetLanguage = rawTargetLanguages;
|
|
606
|
+
} else if (Array.isArray(rawTargetLanguages) && rawTargetLanguages.length === 1) {
|
|
607
|
+
// Single language provided as array - extract for backward compatibility
|
|
608
|
+
targetLanguage = rawTargetLanguages[0];
|
|
599
609
|
}
|
|
600
610
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
throw new Error('Cannot specify both targetLanguage and targetLanguages');
|
|
611
|
+
if (!targetLanguages?.length) {
|
|
612
|
+
throw new Error('targetLanguages parameter is required (can be a string for single language or array for multiple languages)');
|
|
604
613
|
}
|
|
605
614
|
|
|
606
615
|
// Read file content if path provided and no content given
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i18n-agent/mcp-client",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "MCP client for i18n-agent translation service with async job support and enhanced progress tracking - supports Claude, Cursor, VS Code, and other AI IDEs",
|
|
5
5
|
"main": "mcp-client.js",
|
|
6
6
|
"bin": {
|