@i18n-agent/mcp-client 1.7.5 → 1.7.7

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.
Files changed (2) hide show
  1. package/mcp-client.js +106 -27
  2. 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.5';
8
+ const MCP_CLIENT_VERSION = '1.7.7';
9
9
 
10
10
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
11
11
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
@@ -218,6 +218,20 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
218
218
  required: ['jobId'],
219
219
  },
220
220
  },
221
+ {
222
+ name: 'resume_translation',
223
+ description: 'Resume a failed or interrupted async translation job from its last checkpoint. This allows you to continue processing from where it stopped instead of starting over.',
224
+ inputSchema: {
225
+ type: 'object',
226
+ properties: {
227
+ jobId: {
228
+ type: 'string',
229
+ description: 'The job ID of the translation job to resume',
230
+ },
231
+ },
232
+ required: ['jobId'],
233
+ },
234
+ },
221
235
  ],
222
236
  };
223
237
  });
@@ -248,7 +262,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
248
262
 
249
263
  case 'check_translation_status':
250
264
  return await handleCheckTranslationStatus(args);
251
-
265
+
266
+ case 'resume_translation':
267
+ return await handleResumeTranslation(args);
268
+
252
269
  default:
253
270
  throw new McpError(
254
271
  ErrorCode.MethodNotFound,
@@ -577,6 +594,11 @@ async function handleListLanguages(args) {
577
594
  }
578
595
 
579
596
  async function handleTranslateFile(args) {
597
+ // DEBUG: Log ALL args received from Claude Code
598
+ console.error('🔍 [MCP CLIENT] handleTranslateFile received args:', JSON.stringify(Object.keys(args)));
599
+ console.error('🔍 [MCP CLIENT] targetLanguages value:', args.targetLanguages);
600
+ console.error('🔍 [MCP CLIENT] Full args:', JSON.stringify(args).substring(0, 500));
601
+
580
602
  const {
581
603
  filePath,
582
604
  fileContent,
@@ -625,7 +647,26 @@ async function handleTranslateFile(args) {
625
647
 
626
648
  // Check if this is a large file that might need async processing
627
649
  const isLargeFile = content.length > 50000; // > 50KB
628
-
650
+
651
+ // Build arguments object, filtering out undefined values (they get stripped by JSON.stringify)
652
+ const requestArgs = {
653
+ apiKey: API_KEY,
654
+ filePath,
655
+ fileContent: content,
656
+ fileType,
657
+ sourceLanguage,
658
+ targetAudience,
659
+ industry,
660
+ preserveKeys,
661
+ outputFormat
662
+ };
663
+
664
+ // Add optional parameters only if defined
665
+ if (targetLanguage !== undefined) requestArgs.targetLanguage = targetLanguage;
666
+ if (targetLanguages !== undefined) requestArgs.targetLanguages = targetLanguages;
667
+ if (region !== undefined) requestArgs.region = region;
668
+ if (context !== undefined) requestArgs.context = context;
669
+
629
670
  // Use MCP JSON-RPC protocol for translate_file
630
671
  const mcpRequest = {
631
672
  jsonrpc: '2.0',
@@ -633,21 +674,7 @@ async function handleTranslateFile(args) {
633
674
  method: 'tools/call',
634
675
  params: {
635
676
  name: 'translate_file',
636
- arguments: {
637
- apiKey: API_KEY,
638
- filePath,
639
- fileContent: content,
640
- fileType,
641
- targetLanguage,
642
- targetLanguages,
643
- sourceLanguage,
644
- targetAudience,
645
- industry,
646
- region,
647
- context,
648
- preserveKeys,
649
- outputFormat
650
- }
677
+ arguments: requestArgs
651
678
  }
652
679
  };
653
680
 
@@ -1310,11 +1337,11 @@ function getCodeBlockLanguage(fileType) {
1310
1337
  // Handler for checking translation status
1311
1338
  async function handleCheckTranslationStatus(args) {
1312
1339
  const { jobId } = args;
1313
-
1340
+
1314
1341
  if (!jobId) {
1315
1342
  throw new Error('jobId is required');
1316
1343
  }
1317
-
1344
+
1318
1345
  const mcpRequest = {
1319
1346
  jsonrpc: '2.0',
1320
1347
  id: Date.now(),
@@ -1324,41 +1351,93 @@ async function handleCheckTranslationStatus(args) {
1324
1351
  arguments: { jobId }
1325
1352
  }
1326
1353
  };
1327
-
1354
+
1328
1355
  try {
1329
1356
  const response = await axios.post(MCP_SERVER_URL, mcpRequest, {
1330
1357
  headers: { 'Content-Type': 'application/json' },
1331
1358
  timeout: 30000
1332
1359
  });
1333
-
1360
+
1334
1361
  if (response.data.error) {
1335
1362
  throw new Error(`Translation status error: ${response.data.error.message || response.data.error}`);
1336
1363
  }
1337
-
1364
+
1338
1365
  return response.data.result;
1339
1366
  } catch (error) {
1340
1367
  console.error('Check translation status error:', error);
1341
-
1368
+
1342
1369
  // Handle 503 service unavailable
1343
1370
  if (error.response?.status === 503) {
1344
1371
  throw new Error(`i18n-agent encountered unexpected problem, and we are working on it, try again later.`);
1345
1372
  }
1346
-
1373
+
1347
1374
  // Handle 404 not found
1348
1375
  if (error.response?.status === 404) {
1349
1376
  throw new Error(`Translation job ${jobId} not found. The job may have expired or the ID is incorrect.`);
1350
1377
  }
1351
-
1378
+
1352
1379
  // Handle timeout
1353
1380
  if (error.code === 'ECONNABORTED') {
1354
1381
  throw new Error(`Status check timed out. The service may be experiencing high load. Please try again.`);
1355
1382
  }
1356
-
1383
+
1357
1384
  // Generic error
1358
1385
  throw new Error(`Unable to check translation status: ${error.message}`);
1359
1386
  }
1360
1387
  }
1361
1388
 
1389
+ // Handler for resuming translation jobs
1390
+ async function handleResumeTranslation(args) {
1391
+ const { jobId } = args;
1392
+
1393
+ if (!jobId) {
1394
+ throw new Error('jobId is required');
1395
+ }
1396
+
1397
+ const mcpRequest = {
1398
+ jsonrpc: '2.0',
1399
+ id: Date.now(),
1400
+ method: 'tools/call',
1401
+ params: {
1402
+ name: 'resume_translation',
1403
+ arguments: { jobId }
1404
+ }
1405
+ };
1406
+
1407
+ try {
1408
+ const response = await axios.post(MCP_SERVER_URL, mcpRequest, {
1409
+ headers: { 'Content-Type': 'application/json' },
1410
+ timeout: 30000
1411
+ });
1412
+
1413
+ if (response.data.error) {
1414
+ throw new Error(`Resume translation error: ${response.data.error.message || response.data.error}`);
1415
+ }
1416
+
1417
+ return response.data.result;
1418
+ } catch (error) {
1419
+ console.error('Resume translation error:', error);
1420
+
1421
+ // Handle 503 service unavailable
1422
+ if (error.response?.status === 503) {
1423
+ throw new Error(`i18n-agent encountered unexpected problem, and we are working on it, try again later.`);
1424
+ }
1425
+
1426
+ // Handle 404 not found
1427
+ if (error.response?.status === 404) {
1428
+ throw new Error(`Translation job ${jobId} not found. The job may have expired or the ID is incorrect.`);
1429
+ }
1430
+
1431
+ // Handle timeout
1432
+ if (error.code === 'ECONNABORTED') {
1433
+ throw new Error(`Resume request timed out. The service may be experiencing high load. Please try again.`);
1434
+ }
1435
+
1436
+ // Generic error
1437
+ throw new Error(`Unable to resume translation: ${error.message}`);
1438
+ }
1439
+ }
1440
+
1362
1441
  // Start the server
1363
1442
  async function main() {
1364
1443
  const transport = new StdioServerTransport();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-agent/mcp-client",
3
- "version": "1.7.5",
3
+ "version": "1.7.7",
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": {