@i18n-agent/mcp-client 1.8.4 → 1.8.5

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 +30 -7
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -197,26 +197,33 @@ exec node "${mcpClientPath}"`;
197
197
 
198
198
  function updateClaudeConfig(configPath) {
199
199
  let config = {};
200
-
200
+ let existingApiKey = "";
201
+
201
202
  // Read existing config if it exists
202
203
  if (fs.existsSync(configPath)) {
203
204
  try {
204
205
  const content = fs.readFileSync(configPath, 'utf8');
205
206
  config = JSON.parse(content);
207
+
208
+ // Preserve existing API key if present
209
+ if (config.mcpServers?.["i18n-agent"]?.env?.API_KEY) {
210
+ existingApiKey = config.mcpServers["i18n-agent"].env.API_KEY;
211
+ console.log(' 🔑 Preserving existing API key');
212
+ }
206
213
  } catch (error) {
207
214
  console.warn(`Warning: Could not parse existing config at ${configPath}`);
208
215
  }
209
216
  }
210
-
217
+
211
218
  // Ensure mcpServers exists
212
219
  if (!config.mcpServers) {
213
220
  config.mcpServers = {};
214
221
  }
215
-
222
+
216
223
  // Detect if we need a wrapper script (for nvm users)
217
224
  const nodeEnv = detectNodeEnvironment();
218
225
  const claudeDir = path.join(os.homedir(), '.claude');
219
-
226
+
220
227
  if (nodeEnv.isNvm) {
221
228
  // Create wrapper script for nvm users
222
229
  console.log(' 🔧 Detected nvm environment, creating wrapper script...');
@@ -226,29 +233,40 @@ function updateClaudeConfig(configPath) {
226
233
  command: wrapperPath,
227
234
  env: {
228
235
  MCP_SERVER_URL: "https://mcp.i18nagent.ai",
229
- API_KEY: ""
236
+ API_KEY: existingApiKey || ""
230
237
  }
231
238
  };
232
239
  } else {
233
240
  // Standard configuration for system node
234
241
  const baseConfig = createMCPConfig();
235
242
  config.mcpServers["i18n-agent"] = baseConfig.mcpServers["i18n-agent"];
243
+ // Preserve existing API key
244
+ if (existingApiKey) {
245
+ config.mcpServers["i18n-agent"].env.API_KEY = existingApiKey;
246
+ }
236
247
  }
237
-
248
+
238
249
  // Write updated config
239
250
  fs.mkdirSync(path.dirname(configPath), { recursive: true });
240
251
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
241
-
252
+
242
253
  return config;
243
254
  }
244
255
 
245
256
  function updateGenericMCPConfig(configPath) {
246
257
  let config = {};
258
+ let existingApiKey = "";
247
259
 
248
260
  if (fs.existsSync(configPath)) {
249
261
  try {
250
262
  const existing = fs.readFileSync(configPath, 'utf8');
251
263
  config = JSON.parse(existing);
264
+
265
+ // Preserve existing API key if present
266
+ if (config.mcpServers?.["i18n-agent"]?.env?.API_KEY) {
267
+ existingApiKey = config.mcpServers["i18n-agent"].env.API_KEY;
268
+ console.log(' 🔑 Preserving existing API key');
269
+ }
252
270
  } catch (error) {
253
271
  console.warn(`Warning: Could not parse existing config at ${configPath}`);
254
272
  }
@@ -261,6 +279,11 @@ function updateGenericMCPConfig(configPath) {
261
279
  const baseConfig = createMCPConfig();
262
280
  config.mcpServers["i18n-agent"] = baseConfig.mcpServers["i18n-agent"];
263
281
 
282
+ // Preserve existing API key
283
+ if (existingApiKey) {
284
+ config.mcpServers["i18n-agent"].env.API_KEY = existingApiKey;
285
+ }
286
+
264
287
  // Write config
265
288
  fs.mkdirSync(path.dirname(configPath), { recursive: true });
266
289
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-agent/mcp-client",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
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": {