@i18n-agent/mcp-client 1.6.0 → 1.7.1
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 +33 -24
- 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.
|
|
8
|
+
const MCP_CLIENT_VERSION = '1.7.0';
|
|
9
9
|
|
|
10
10
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
11
11
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
@@ -86,10 +86,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
86
86
|
description: 'Optional additional context or instructions for the translation (e.g., "Keep technical terms in English", "Use formal tone")',
|
|
87
87
|
},
|
|
88
88
|
},
|
|
89
|
-
|
|
90
|
-
{ required: ['texts', 'targetLanguage'] },
|
|
91
|
-
{ required: ['texts', 'targetLanguages'] }
|
|
92
|
-
],
|
|
89
|
+
required: ['texts'],
|
|
93
90
|
},
|
|
94
91
|
},
|
|
95
92
|
{
|
|
@@ -168,10 +165,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
168
165
|
description: 'Optional additional context or instructions for the translation (e.g., "Keep technical terms in English", "Use formal tone")',
|
|
169
166
|
},
|
|
170
167
|
},
|
|
171
|
-
|
|
172
|
-
{ required: ['targetLanguage'] },
|
|
173
|
-
{ required: ['targetLanguages'] }
|
|
174
|
-
],
|
|
168
|
+
required: [],
|
|
175
169
|
},
|
|
176
170
|
},
|
|
177
171
|
{
|
|
@@ -295,14 +289,20 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
295
289
|
});
|
|
296
290
|
|
|
297
291
|
async function handleTranslateText(args) {
|
|
298
|
-
const { texts, targetLanguage, sourceLanguage, targetAudience = 'general', industry = 'technology', region, context } = args;
|
|
299
|
-
|
|
292
|
+
const { texts, targetLanguage, targetLanguages, sourceLanguage, targetAudience = 'general', industry = 'technology', region, context } = args;
|
|
293
|
+
|
|
300
294
|
if (!texts || !Array.isArray(texts) || texts.length === 0) {
|
|
301
295
|
throw new Error('texts must be a non-empty array');
|
|
302
296
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
297
|
+
|
|
298
|
+
// Support both single and multi-language: targetLanguage OR targetLanguages
|
|
299
|
+
if (!targetLanguage && !targetLanguages?.length) {
|
|
300
|
+
throw new Error('Either targetLanguage or targetLanguages must be provided');
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Ensure both are not provided at the same time
|
|
304
|
+
if (targetLanguage && targetLanguages?.length) {
|
|
305
|
+
throw new Error('Cannot specify both targetLanguage and targetLanguages');
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
// Check if this is a large translation request
|
|
@@ -320,6 +320,7 @@ async function handleTranslateText(args) {
|
|
|
320
320
|
apiKey: API_KEY,
|
|
321
321
|
texts: texts,
|
|
322
322
|
targetLanguage: targetLanguage,
|
|
323
|
+
targetLanguages: targetLanguages,
|
|
323
324
|
sourceLanguage: sourceLanguage && sourceLanguage !== 'auto' ? sourceLanguage : undefined,
|
|
324
325
|
targetAudience: targetAudience,
|
|
325
326
|
industry: industry,
|
|
@@ -573,12 +574,13 @@ async function handleListLanguages(args) {
|
|
|
573
574
|
}
|
|
574
575
|
|
|
575
576
|
async function handleTranslateFile(args) {
|
|
576
|
-
const {
|
|
577
|
-
filePath,
|
|
578
|
-
fileContent,
|
|
579
|
-
fileType = 'auto',
|
|
580
|
-
targetLanguage,
|
|
581
|
-
|
|
577
|
+
const {
|
|
578
|
+
filePath,
|
|
579
|
+
fileContent,
|
|
580
|
+
fileType = 'auto',
|
|
581
|
+
targetLanguage,
|
|
582
|
+
targetLanguages,
|
|
583
|
+
targetAudience = 'general',
|
|
582
584
|
industry = 'technology',
|
|
583
585
|
preserveKeys = true,
|
|
584
586
|
outputFormat = 'same',
|
|
@@ -586,13 +588,19 @@ async function handleTranslateFile(args) {
|
|
|
586
588
|
region,
|
|
587
589
|
context
|
|
588
590
|
} = args;
|
|
589
|
-
|
|
591
|
+
|
|
590
592
|
if (!filePath && !fileContent) {
|
|
591
593
|
throw new Error('Either filePath or fileContent must be provided');
|
|
592
594
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
595
|
+
|
|
596
|
+
// Support both single and multi-language: targetLanguage OR targetLanguages
|
|
597
|
+
if (!targetLanguage && !targetLanguages?.length) {
|
|
598
|
+
throw new Error('Either targetLanguage or targetLanguages must be provided');
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// Ensure both are not provided at the same time
|
|
602
|
+
if (targetLanguage && targetLanguages?.length) {
|
|
603
|
+
throw new Error('Cannot specify both targetLanguage and targetLanguages');
|
|
596
604
|
}
|
|
597
605
|
|
|
598
606
|
// Read file content if path provided and no content given
|
|
@@ -622,6 +630,7 @@ async function handleTranslateFile(args) {
|
|
|
622
630
|
fileContent: content,
|
|
623
631
|
fileType,
|
|
624
632
|
targetLanguage,
|
|
633
|
+
targetLanguages,
|
|
625
634
|
sourceLanguage,
|
|
626
635
|
targetAudience,
|
|
627
636
|
industry,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i18n-agent/mcp-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
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": {
|