@i18n-agent/mcp-client 1.7.7 → 1.7.9

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 +73 -1
  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.7';
8
+ const MCP_CLIENT_VERSION = '1.7.9';
9
9
 
10
10
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
11
11
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
@@ -232,6 +232,20 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
232
232
  required: ['jobId'],
233
233
  },
234
234
  },
235
+ {
236
+ name: 'download_translations',
237
+ description: 'Download completed translations by writing them to /tmp/i18n-translations-{jobId}/. Returns metadata with file paths instead of large translation content to avoid token bloat. Consumer can then read or copy files as needed.',
238
+ inputSchema: {
239
+ type: 'object',
240
+ properties: {
241
+ jobId: {
242
+ type: 'string',
243
+ description: 'The job ID of the completed translation',
244
+ },
245
+ },
246
+ required: ['jobId'],
247
+ },
248
+ },
235
249
  ],
236
250
  };
237
251
  });
@@ -266,6 +280,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
266
280
  case 'resume_translation':
267
281
  return await handleResumeTranslation(args);
268
282
 
283
+ case 'download_translations':
284
+ return await handleDownloadTranslations(args);
285
+
269
286
  default:
270
287
  throw new McpError(
271
288
  ErrorCode.MethodNotFound,
@@ -1438,6 +1455,61 @@ async function handleResumeTranslation(args) {
1438
1455
  }
1439
1456
  }
1440
1457
 
1458
+ // Handler for downloading completed translations
1459
+ async function handleDownloadTranslations(args) {
1460
+ const { jobId } = args;
1461
+
1462
+ if (!jobId) {
1463
+ throw new Error('jobId is required');
1464
+ }
1465
+
1466
+ const mcpRequest = {
1467
+ jsonrpc: '2.0',
1468
+ id: Date.now(),
1469
+ method: 'tools/call',
1470
+ params: {
1471
+ name: 'download_translations',
1472
+ arguments: {
1473
+ apiKey: API_KEY,
1474
+ jobId
1475
+ }
1476
+ }
1477
+ };
1478
+
1479
+ try {
1480
+ const response = await axios.post(MCP_SERVER_URL, mcpRequest, {
1481
+ headers: { 'Content-Type': 'application/json' },
1482
+ timeout: 30000
1483
+ });
1484
+
1485
+ if (response.data.error) {
1486
+ throw new Error(`Download translations error: ${response.data.error.message || response.data.error}`);
1487
+ }
1488
+
1489
+ return response.data.result;
1490
+ } catch (error) {
1491
+ console.error('Download translations error:', error);
1492
+
1493
+ // Handle 503 service unavailable
1494
+ if (error.response?.status === 503) {
1495
+ throw new Error(`i18n-agent encountered unexpected problem, and we are working on it, try again later.`);
1496
+ }
1497
+
1498
+ // Handle 404 not found
1499
+ if (error.response?.status === 404) {
1500
+ throw new Error(`Translation job ${jobId} not found. The job may have expired or the ID is incorrect.`);
1501
+ }
1502
+
1503
+ // Handle timeout
1504
+ if (error.code === 'ECONNABORTED') {
1505
+ throw new Error(`Download request timed out. The service may be experiencing high load. Please try again.`);
1506
+ }
1507
+
1508
+ // Generic error
1509
+ throw new Error(`Unable to download translations: ${error.message}`);
1510
+ }
1511
+ }
1512
+
1441
1513
  // Start the server
1442
1514
  async function main() {
1443
1515
  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.7",
3
+ "version": "1.7.9",
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": {