@i18n-agent/mcp-client 1.8.13 → 1.8.14

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 +78 -12
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -78,9 +78,6 @@ Features:
78
78
  šŸ“ File translation (JSON, YAML, CSV, MD, etc.)
79
79
  šŸ’° Credit balance checking
80
80
  🌐 48 languages supported with regional variants
81
-
82
- šŸ”‘ IMPORTANT: Get your API key at https://app.i18nagent.ai
83
- (Required for the MCP client to work)
84
81
  `);
85
82
 
86
83
  const getMcpClientPaths = () => {
@@ -136,6 +133,45 @@ async function detectAvailableIDEs() {
136
133
  return available;
137
134
  }
138
135
 
136
+ function checkExistingApiKey(configPath) {
137
+ if (!fs.existsSync(configPath)) {
138
+ return false;
139
+ }
140
+
141
+ try {
142
+ const content = fs.readFileSync(configPath, 'utf8');
143
+ const config = JSON.parse(content);
144
+ const apiKey = config.mcpServers?.["i18n-agent"]?.env?.API_KEY;
145
+ return apiKey && apiKey.trim() !== '';
146
+ } catch (error) {
147
+ return false;
148
+ }
149
+ }
150
+
151
+ async function checkExistingApiKeys(availableIDEs) {
152
+ const withKeys = [];
153
+ const withoutKeys = [];
154
+
155
+ for (const ide of availableIDEs) {
156
+ // Also check ~/.claude.json for Claude Code CLI
157
+ if (ide.key === 'claude-code') {
158
+ const claudeJsonPath = path.join(os.homedir(), '.claude.json');
159
+ if (checkExistingApiKey(claudeJsonPath)) {
160
+ withKeys.push(ide);
161
+ continue;
162
+ }
163
+ }
164
+
165
+ if (checkExistingApiKey(ide.configPath)) {
166
+ withKeys.push(ide);
167
+ } else {
168
+ withoutKeys.push(ide);
169
+ }
170
+ }
171
+
172
+ return { withKeys, withoutKeys };
173
+ }
174
+
139
175
  function createMCPConfig() {
140
176
  const { mcpClientPath, packageDir } = getMcpClientPaths();
141
177
 
@@ -392,13 +428,8 @@ async function main() {
392
428
  try {
393
429
  console.log('šŸ” Detecting available AI IDEs...\n');
394
430
 
395
- // First, copy MCP client to stable location
396
- console.log('šŸ“¦ Installing MCP client files...');
397
- copyMcpClientToStableLocation();
398
- console.log('');
399
-
400
431
  const availableIDEs = await detectAvailableIDEs();
401
-
432
+
402
433
  if (availableIDEs.length === 0) {
403
434
  console.log(`āŒ No supported AI IDEs detected.
404
435
 
@@ -418,13 +449,48 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
418
449
  `);
419
450
  process.exit(1);
420
451
  }
421
-
452
+
422
453
  console.log('āœ… Available AI IDEs:');
423
454
  availableIDEs.forEach((ide, index) => {
424
455
  console.log(`${index + 1}. ${ide.name}`);
425
456
  });
426
-
427
- console.log('\nšŸ“ Installing for all available IDEs...\n');
457
+ console.log('');
458
+
459
+ // Check for existing API keys BEFORE installation
460
+ const { withKeys, withoutKeys } = await checkExistingApiKeys(availableIDEs);
461
+
462
+ if (withKeys.length > 0 && withoutKeys.length === 0) {
463
+ console.log(`āœ… API Keys Already Configured:`);
464
+ withKeys.forEach(ide => {
465
+ console.log(` - ${ide.name}`);
466
+ });
467
+ console.log(`\nšŸ’š Your API keys are preserved. Updating MCP client files only...\n`);
468
+ } else if (withKeys.length > 0 && withoutKeys.length > 0) {
469
+ // Mixed case: some have keys, some don't
470
+ console.log(`āœ… API Keys Already Configured:`);
471
+ withKeys.forEach(ide => {
472
+ console.log(` - ${ide.name}`);
473
+ });
474
+ console.log(`\nšŸ”‘ API Key Setup Required:`);
475
+ withoutKeys.forEach(ide => {
476
+ console.log(` - ${ide.name}`);
477
+ });
478
+ console.log(`\nšŸ’š Existing API keys will be preserved.`);
479
+ console.log(`šŸ’” Get your API key at: https://app.i18nagent.ai\n`);
480
+ } else if (withoutKeys.length > 0) {
481
+ console.log(`šŸ”‘ API Key Setup Required:`);
482
+ withoutKeys.forEach(ide => {
483
+ console.log(` - ${ide.name}`);
484
+ });
485
+ console.log(`\nšŸ’” Get your API key at: https://app.i18nagent.ai\n`);
486
+ }
487
+
488
+ // Now copy MCP client to stable location
489
+ console.log('šŸ“¦ Installing MCP client files...');
490
+ copyMcpClientToStableLocation();
491
+ console.log('');
492
+
493
+ console.log('šŸ“ Updating configurations...\n');
428
494
 
429
495
  let installCount = 0;
430
496
  const installedIDEs = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-agent/mcp-client",
3
- "version": "1.8.13",
3
+ "version": "1.8.14",
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": {