@i18n-agent/mcp-client 1.8.7 โ†’ 1.8.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/install.js +109 -42
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -198,6 +198,7 @@ exec node "${mcpClientPath}"`;
198
198
  function updateClaudeConfig(configPath, ideKey = 'claude') {
199
199
  let config = {};
200
200
  let existingApiKey = "";
201
+ let hasApiKey = false;
201
202
 
202
203
  // Read existing config if it exists
203
204
  if (fs.existsSync(configPath)) {
@@ -208,6 +209,7 @@ function updateClaudeConfig(configPath, ideKey = 'claude') {
208
209
  // Preserve existing API key if present
209
210
  if (config.mcpServers?.["i18n-agent"]?.env?.API_KEY) {
210
211
  existingApiKey = config.mcpServers["i18n-agent"].env.API_KEY;
212
+ hasApiKey = !!existingApiKey;
211
213
  console.log(' ๐Ÿ”‘ Preserving existing API key');
212
214
  }
213
215
  } catch (error) {
@@ -271,12 +273,13 @@ function updateClaudeConfig(configPath, ideKey = 'claude') {
271
273
  fs.mkdirSync(path.dirname(configPath), { recursive: true });
272
274
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
273
275
 
274
- return config;
276
+ return { config, hasApiKey };
275
277
  }
276
278
 
277
279
  function updateGenericMCPConfig(configPath) {
278
280
  let config = {};
279
281
  let existingApiKey = "";
282
+ let hasApiKey = false;
280
283
 
281
284
  if (fs.existsSync(configPath)) {
282
285
  try {
@@ -286,6 +289,7 @@ function updateGenericMCPConfig(configPath) {
286
289
  // Preserve existing API key if present
287
290
  if (config.mcpServers?.["i18n-agent"]?.env?.API_KEY) {
288
291
  existingApiKey = config.mcpServers["i18n-agent"].env.API_KEY;
292
+ hasApiKey = !!existingApiKey;
289
293
  console.log(' ๐Ÿ”‘ Preserving existing API key');
290
294
  }
291
295
  } catch (error) {
@@ -324,7 +328,64 @@ function updateGenericMCPConfig(configPath) {
324
328
  fs.mkdirSync(path.dirname(configPath), { recursive: true });
325
329
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
326
330
 
327
- return config;
331
+ return { config, hasApiKey };
332
+ }
333
+
334
+ function updateClaudeJsonConfig(configPath) {
335
+ let config = {};
336
+ let existingApiKey = "";
337
+
338
+ if (fs.existsSync(configPath)) {
339
+ try {
340
+ const existing = fs.readFileSync(configPath, 'utf8');
341
+ config = JSON.parse(existing);
342
+
343
+ // Preserve existing API key if present
344
+ if (config.mcpServers?.["i18n-agent"]?.env?.API_KEY) {
345
+ existingApiKey = config.mcpServers["i18n-agent"].env.API_KEY;
346
+ console.log(' ๐Ÿ”‘ Preserving existing API key from ~/.claude.json');
347
+ }
348
+ } catch (error) {
349
+ console.warn(` โš ๏ธ Warning: Could not parse ~/.claude.json - it may be corrupted`);
350
+ return;
351
+ }
352
+ }
353
+
354
+ if (!config.mcpServers) {
355
+ config.mcpServers = {};
356
+ }
357
+
358
+ const nodeEnv = detectNodeEnvironment();
359
+ const { mcpClientPath } = getMcpClientPaths();
360
+
361
+ // Use absolute node path for nvm, 'node' for system installations
362
+ if (nodeEnv.isNvm) {
363
+ config.mcpServers["i18n-agent"] = {
364
+ command: nodeEnv.nodePath,
365
+ args: [mcpClientPath],
366
+ env: {
367
+ MCP_SERVER_URL: "https://mcp.i18nagent.ai",
368
+ API_KEY: existingApiKey || ""
369
+ }
370
+ };
371
+ } else {
372
+ config.mcpServers["i18n-agent"] = {
373
+ command: "node",
374
+ args: [mcpClientPath],
375
+ env: {
376
+ MCP_SERVER_URL: "https://mcp.i18nagent.ai",
377
+ API_KEY: existingApiKey || ""
378
+ }
379
+ };
380
+ }
381
+
382
+ // Write config
383
+ try {
384
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
385
+ console.log(' โœ… ~/.claude.json updated');
386
+ } catch (error) {
387
+ console.warn(` โš ๏ธ Warning: Failed to write ~/.claude.json: ${error.message}`);
388
+ }
328
389
  }
329
390
 
330
391
  async function main() {
@@ -367,15 +428,27 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
367
428
 
368
429
  let installCount = 0;
369
430
  const installedIDEs = [];
431
+ const idesWithApiKey = [];
432
+ const idesNeedingApiKey = [];
370
433
 
371
434
  for (const ide of availableIDEs) {
372
435
  try {
373
436
  console.log(`โš™๏ธ Configuring ${ide.name}...`);
374
437
 
438
+ let result;
375
439
  if (ide.key === 'claude' || ide.key === 'claude-code') {
376
- updateClaudeConfig(ide.configPath, ide.key);
440
+ result = updateClaudeConfig(ide.configPath, ide.key);
441
+
442
+ // Claude Code CLI also needs ~/.claude.json updated (source of truth)
443
+ if (ide.key === 'claude-code') {
444
+ const claudeJsonPath = path.join(os.homedir(), '.claude.json');
445
+ if (fs.existsSync(claudeJsonPath)) {
446
+ console.log(' ๐Ÿ”ง Updating ~/.claude.json (source of truth)...');
447
+ updateClaudeJsonConfig(claudeJsonPath);
448
+ }
449
+ }
377
450
  } else {
378
- updateGenericMCPConfig(ide.configPath);
451
+ result = updateGenericMCPConfig(ide.configPath);
379
452
  }
380
453
 
381
454
  console.log(`โœ… ${ide.name} configured successfully!`);
@@ -383,47 +456,47 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
383
456
  installCount++;
384
457
  installedIDEs.push(ide);
385
458
 
459
+ // Track API key status
460
+ if (result && result.hasApiKey) {
461
+ idesWithApiKey.push(ide);
462
+ } else {
463
+ idesNeedingApiKey.push(ide);
464
+ }
465
+
386
466
  } catch (error) {
387
467
  console.error(`โŒ Failed to configure ${ide.name}: ${error.message}\n`);
388
468
  }
389
469
  }
390
470
 
391
471
  if (installCount > 0) {
392
- // Show config file paths for ONLY installed IDEs
393
- const configPaths = installedIDEs.map(ide => ` - ${ide.name}: ${ide.displayPath}`).join('\n');
394
-
395
- // Platform-specific environment variable instructions
396
- const isWindows = process.platform === 'win32';
397
- const envVarInstructions = isWindows
398
- ? ` Windows PowerShell:
399
- $env:API_KEY="your-api-key-here"
400
-
401
- Or set permanently via System Environment Variables:
402
- 1. Search "Environment Variables" in Windows
403
- 2. Click "New" under User variables
404
- 3. Variable name: API_KEY
405
- 4. Variable value: your-api-key-here`
406
- : ` macOS/Linux:
407
- export API_KEY=your-api-key-here
408
-
409
- Add to shell profile for persistence (~/.bashrc, ~/.zshrc):
410
- echo 'export API_KEY=your-api-key-here' >> ~/.zshrc`;
472
+ console.log(`๐ŸŽ‰ Installation complete! Configured ${installCount} IDE(s).\n`);
473
+
474
+ // Show API key status
475
+ if (idesWithApiKey.length > 0) {
476
+ console.log(`โœ… API Key Already Configured:`);
477
+ idesWithApiKey.forEach(ide => {
478
+ console.log(` - ${ide.name}`);
479
+ });
480
+ console.log('');
481
+ }
411
482
 
412
- console.log(`๐ŸŽ‰ Installation complete! Configured ${installCount} IDE(s).
483
+ if (idesNeedingApiKey.length > 0) {
484
+ console.log(`โš ๏ธ API Key Required For:`);
485
+ idesNeedingApiKey.forEach(ide => {
486
+ console.log(` - ${ide.name} (${ide.displayPath})`);
487
+ });
488
+ console.log('');
413
489
 
414
- ๐Ÿ”‘ CRITICAL: Add your API key (required for MCP client to work)
490
+ // Show setup instructions only for IDEs that need them
491
+ console.log(`๐Ÿ”‘ Setup Instructions
415
492
  โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
416
493
  Step 1: Get your API key
417
494
  ๐Ÿ‘‰ Visit: https://app.i18nagent.ai
418
495
  ๐Ÿ‘‰ Sign up or log in
419
496
  ๐Ÿ‘‰ Copy your API key (starts with "i18n_")
420
497
 
421
- Step 2: Add API key to config file(s)
422
- ${configPaths}
423
-
424
- Option A - Edit config file directly (RECOMMENDED):
425
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
426
- Open the config file and find the "env" section:
498
+ Step 2: Add API key to the config file
499
+ Open the config file and edit the "API_KEY" field:
427
500
 
428
501
  "mcpServers": {
429
502
  "i18n-agent": {
@@ -438,26 +511,20 @@ ${configPaths}
438
511
  Example with actual key:
439
512
  "API_KEY": "i18n_1234567890abcdef"
440
513
 
441
- Option B - Use environment variable:
442
- โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
443
- ${envVarInstructions}
444
-
445
514
  Step 3: Restart your IDE
446
515
  Close and reopen your IDE to load the new configuration
516
+ `);
517
+ }
447
518
 
448
- ๐Ÿงช Test the installation
519
+ // Show test instructions (for all IDEs)
520
+ console.log(`
521
+ ๐Ÿงช Test the Installation
449
522
  โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
450
523
  Try these commands in your AI IDE:
451
524
  โœ“ "Translate 'Hello world' to Spanish"
452
525
  โœ“ "Check my translation credits"
453
526
  โœ“ "List supported languages"
454
527
 
455
- If you get "Invalid API key" errors, double-check:
456
- - API key is correctly pasted in the config file
457
- - No extra spaces or quotes around the key
458
- - Config file is saved
459
- - IDE has been restarted
460
-
461
528
  ๐Ÿ“š Documentation: https://docs.i18nagent.ai
462
529
  ๐Ÿ› Issues: https://github.com/i18n-agent/mcp-client/issues
463
530
  ๐Ÿ’ฌ Support: support@i18nagent.ai
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-agent/mcp-client",
3
- "version": "1.8.7",
3
+ "version": "1.8.9",
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": {