@i18n-agent/mcp-client 1.8.16 → 1.8.18

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/install.js CHANGED
@@ -184,7 +184,8 @@ function createMCPConfig() {
184
184
  env: {
185
185
  MCP_SERVER_URL: "https://mcp.i18nagent.ai",
186
186
  API_KEY: ""
187
- }
187
+ },
188
+ disabled: false
188
189
  }
189
190
  }
190
191
  };
@@ -272,7 +273,8 @@ function updateClaudeConfig(configPath, ideKey = 'claude') {
272
273
  env: {
273
274
  MCP_SERVER_URL: "https://mcp.i18nagent.ai",
274
275
  API_KEY: existingApiKey || ""
275
- }
276
+ },
277
+ disabled: false
276
278
  };
277
279
  } else {
278
280
  // For system node, use 'node' with args
@@ -294,7 +296,8 @@ function updateClaudeConfig(configPath, ideKey = 'claude') {
294
296
  env: {
295
297
  MCP_SERVER_URL: "https://mcp.i18nagent.ai",
296
298
  API_KEY: existingApiKey || ""
297
- }
299
+ },
300
+ disabled: false
298
301
  };
299
302
  } else {
300
303
  const baseConfig = createMCPConfig();
@@ -350,7 +353,8 @@ function updateGenericMCPConfig(configPath) {
350
353
  env: {
351
354
  MCP_SERVER_URL: "https://mcp.i18nagent.ai",
352
355
  API_KEY: existingApiKey || ""
353
- }
356
+ },
357
+ disabled: false
354
358
  };
355
359
  } else {
356
360
  const baseConfig = createMCPConfig();
@@ -402,7 +406,8 @@ function updateClaudeJsonConfig(configPath) {
402
406
  env: {
403
407
  MCP_SERVER_URL: "https://mcp.i18nagent.ai",
404
408
  API_KEY: existingApiKey || ""
405
- }
409
+ },
410
+ disabled: false
406
411
  };
407
412
  } else {
408
413
  config.mcpServers["i18n-agent"] = {
@@ -411,7 +416,8 @@ function updateClaudeJsonConfig(configPath) {
411
416
  env: {
412
417
  MCP_SERVER_URL: "https://mcp.i18nagent.ai",
413
418
  API_KEY: existingApiKey || ""
414
- }
419
+ },
420
+ disabled: false
415
421
  };
416
422
  }
417
423
 
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.2';
8
+ const MCP_CLIENT_VERSION = '1.8.18';
9
9
 
10
10
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
11
11
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
@@ -1610,6 +1610,7 @@ async function handleDownloadTranslations(args) {
1610
1610
  };
1611
1611
 
1612
1612
  try {
1613
+ // Step 1: Get download URLs from MCP server
1613
1614
  const response = await axios.post(MCP_SERVER_URL, mcpRequest, {
1614
1615
  headers: { 'Content-Type': 'application/json' },
1615
1616
  timeout: 30000
@@ -1619,7 +1620,103 @@ async function handleDownloadTranslations(args) {
1619
1620
  throw new Error(`Download translations error: ${response.data.error.message || response.data.error}`);
1620
1621
  }
1621
1622
 
1622
- return response.data.result;
1623
+ const result = response.data.result;
1624
+
1625
+ // Parse the MCP response
1626
+ let parsedResult;
1627
+ if (result && result.content && result.content[0]) {
1628
+ parsedResult = JSON.parse(result.content[0].text);
1629
+ } else {
1630
+ parsedResult = result;
1631
+ }
1632
+
1633
+ // Detect storage type and handle accordingly
1634
+ const storageType = parsedResult.storageType || 'local';
1635
+ const outputDir = `/tmp/i18n-translations-${jobId}`;
1636
+
1637
+ // Create output directory
1638
+ if (!fs.existsSync(outputDir)) {
1639
+ fs.mkdirSync(outputDir, { recursive: true });
1640
+ }
1641
+
1642
+ const filesWritten = [];
1643
+
1644
+ if (storageType === 's3' && parsedResult.downloadUrls) {
1645
+ // Case 1: S3 Storage - download files from presigned URLs
1646
+ console.error(`📥 Downloading ${Object.keys(parsedResult.downloadUrls).length} translation files from S3...`);
1647
+
1648
+ for (const [language, urlInfo] of Object.entries(parsedResult.downloadUrls)) {
1649
+ try {
1650
+ console.error(`📥 Downloading ${language}...`);
1651
+
1652
+ const fileResponse = await axios.get(urlInfo.url, {
1653
+ responseType: 'text',
1654
+ timeout: 60000, // 1 minute per file
1655
+ headers: {
1656
+ 'Authorization': `Bearer ${API_KEY}`
1657
+ }
1658
+ });
1659
+
1660
+ // Determine file extension from file name or metadata
1661
+ const fileType = parsedResult.fileName?.split('.').pop() || 'json';
1662
+ const fileName = `${language}.${fileType}`;
1663
+ const filePath = path.join(outputDir, fileName);
1664
+
1665
+ // Write file to disk
1666
+ fs.writeFileSync(filePath, fileResponse.data, 'utf8');
1667
+ filesWritten.push(filePath);
1668
+
1669
+ console.error(`✅ Downloaded ${fileName}`);
1670
+ } catch (downloadError) {
1671
+ console.error(`❌ Failed to download ${language}:`, downloadError.message);
1672
+ throw new Error(`Failed to download ${language}: ${downloadError.message}`);
1673
+ }
1674
+ }
1675
+ } else if (parsedResult.translations) {
1676
+ // Case 2: Raw Translations - write directly from response
1677
+ console.error(`💾 Writing ${Object.keys(parsedResult.translations).length} translation files from raw content...`);
1678
+
1679
+ for (const [language, content] of Object.entries(parsedResult.translations)) {
1680
+ try {
1681
+ console.error(`💾 Writing ${language}...`);
1682
+
1683
+ // Determine file extension from file name or default to json
1684
+ const fileType = parsedResult.fileName?.split('.').pop() || 'json';
1685
+ const fileName = `${language}.${fileType}`;
1686
+ const filePath = path.join(outputDir, fileName);
1687
+
1688
+ // Write file to disk
1689
+ fs.writeFileSync(filePath, content, 'utf8');
1690
+ filesWritten.push(filePath);
1691
+
1692
+ console.error(`✅ Wrote ${fileName}`);
1693
+ } catch (writeError) {
1694
+ console.error(`❌ Failed to write ${language}:`, writeError.message);
1695
+ throw new Error(`Failed to write ${language}: ${writeError.message}`);
1696
+ }
1697
+ }
1698
+ } else {
1699
+ // No valid download method found
1700
+ throw new Error(`No translations available. Storage type: ${storageType}. Expected either downloadUrls (S3) or translations (raw content).`);
1701
+ }
1702
+
1703
+ // Return success with file paths
1704
+ return {
1705
+ content: [{
1706
+ type: 'text',
1707
+ text: JSON.stringify({
1708
+ success: true,
1709
+ jobId,
1710
+ outputDirectory: outputDir,
1711
+ filesWritten,
1712
+ storageType,
1713
+ fileName: parsedResult.fileName,
1714
+ targetLanguages: parsedResult.targetLanguages,
1715
+ message: `✅ ${storageType === 's3' ? 'Downloaded' : 'Wrote'} ${filesWritten.length} translation files to ${outputDir}`
1716
+ }, null, 2)
1717
+ }]
1718
+ };
1719
+
1623
1720
  } catch (error) {
1624
1721
  console.error('Download translations error:', error);
1625
1722
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-agent/mcp-client",
3
- "version": "1.8.16",
3
+ "version": "1.8.18",
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": {