@i18n-agent/mcp-client 1.8.17 → 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.
Files changed (3) hide show
  1. package/install.js +12 -6
  2. package/mcp-client.js +59 -35
  3. package/package.json +1 -1
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.17';
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';
@@ -1630,11 +1630,8 @@ async function handleDownloadTranslations(args) {
1630
1630
  parsedResult = result;
1631
1631
  }
1632
1632
 
1633
- if (!parsedResult.success) {
1634
- throw new Error(parsedResult.error || 'Failed to get download URLs');
1635
- }
1636
-
1637
- // Step 2: Download files from URLs and write to local /tmp
1633
+ // Detect storage type and handle accordingly
1634
+ const storageType = parsedResult.storageType || 'local';
1638
1635
  const outputDir = `/tmp/i18n-translations-${jobId}`;
1639
1636
 
1640
1637
  // Create output directory
@@ -1642,40 +1639,65 @@ async function handleDownloadTranslations(args) {
1642
1639
  fs.mkdirSync(outputDir, { recursive: true });
1643
1640
  }
1644
1641
 
1645
- const downloadUrls = parsedResult.downloadUrls;
1646
- if (!downloadUrls || downloadUrls.length === 0) {
1647
- throw new Error('No download URLs provided by server');
1648
- }
1649
-
1650
1642
  const filesWritten = [];
1651
1643
 
1652
- // Download each language file
1653
- for (const { language, url } of downloadUrls) {
1654
- try {
1655
- console.error(`📥 Downloading ${language}...`);
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...`);
1656
1647
 
1657
- const fileResponse = await axios.get(url, {
1658
- responseType: 'text',
1659
- timeout: 60000, // 1 minute per file
1660
- headers: {
1661
- 'Authorization': `Bearer ${API_KEY}`
1662
- }
1663
- });
1648
+ for (const [language, urlInfo] of Object.entries(parsedResult.downloadUrls)) {
1649
+ try {
1650
+ console.error(`📥 Downloading ${language}...`);
1664
1651
 
1665
- // Determine file extension from metadata
1666
- const fileType = parsedResult.metadata?.fileType || 'json';
1667
- const fileName = `${language}.${fileType}`;
1668
- const filePath = path.join(outputDir, fileName);
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
+ });
1669
1659
 
1670
- // Write file to disk
1671
- fs.writeFileSync(filePath, fileResponse.data, 'utf8');
1672
- filesWritten.push(filePath);
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);
1673
1664
 
1674
- console.error(`✅ Downloaded ${fileName}`);
1675
- } catch (downloadError) {
1676
- console.error(`❌ Failed to download ${language}:`, downloadError.message);
1677
- throw new Error(`Failed to download ${language}: ${downloadError.message}`);
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
+ }
1678
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).`);
1679
1701
  }
1680
1702
 
1681
1703
  // Return success with file paths
@@ -1687,8 +1709,10 @@ async function handleDownloadTranslations(args) {
1687
1709
  jobId,
1688
1710
  outputDirectory: outputDir,
1689
1711
  filesWritten,
1690
- metadata: parsedResult.metadata,
1691
- message: `✅ Downloaded ${filesWritten.length} translation files to ${outputDir}`
1712
+ storageType,
1713
+ fileName: parsedResult.fileName,
1714
+ targetLanguages: parsedResult.targetLanguages,
1715
+ message: `✅ ${storageType === 's3' ? 'Downloaded' : 'Wrote'} ${filesWritten.length} translation files to ${outputDir}`
1692
1716
  }, null, 2)
1693
1717
  }]
1694
1718
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-agent/mcp-client",
3
- "version": "1.8.17",
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": {