@i18n-agent/mcp-client 1.8.16 → 1.8.17

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 +75 -2
  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.8.2';
8
+ const MCP_CLIENT_VERSION = '1.8.17';
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,79 @@ 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
+ 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
1638
+ const outputDir = `/tmp/i18n-translations-${jobId}`;
1639
+
1640
+ // Create output directory
1641
+ if (!fs.existsSync(outputDir)) {
1642
+ fs.mkdirSync(outputDir, { recursive: true });
1643
+ }
1644
+
1645
+ const downloadUrls = parsedResult.downloadUrls;
1646
+ if (!downloadUrls || downloadUrls.length === 0) {
1647
+ throw new Error('No download URLs provided by server');
1648
+ }
1649
+
1650
+ const filesWritten = [];
1651
+
1652
+ // Download each language file
1653
+ for (const { language, url } of downloadUrls) {
1654
+ try {
1655
+ console.error(`📥 Downloading ${language}...`);
1656
+
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
+ });
1664
+
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);
1669
+
1670
+ // Write file to disk
1671
+ fs.writeFileSync(filePath, fileResponse.data, 'utf8');
1672
+ filesWritten.push(filePath);
1673
+
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}`);
1678
+ }
1679
+ }
1680
+
1681
+ // Return success with file paths
1682
+ return {
1683
+ content: [{
1684
+ type: 'text',
1685
+ text: JSON.stringify({
1686
+ success: true,
1687
+ jobId,
1688
+ outputDirectory: outputDir,
1689
+ filesWritten,
1690
+ metadata: parsedResult.metadata,
1691
+ message: `✅ Downloaded ${filesWritten.length} translation files to ${outputDir}`
1692
+ }, null, 2)
1693
+ }]
1694
+ };
1695
+
1623
1696
  } catch (error) {
1624
1697
  console.error('Download translations error:', error);
1625
1698
 
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.17",
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": {