@i18n-agent/mcp-client 1.8.3 → 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.
- package/install.js +49 -7
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -9,6 +9,7 @@ import fs from 'fs';
|
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import os from 'os';
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
12
|
+
import { execSync } from 'child_process';
|
|
12
13
|
|
|
13
14
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
15
|
|
|
@@ -99,6 +100,24 @@ function copyMcpClientToStableLocation() {
|
|
|
99
100
|
// Copy mcp-client.js to stable location
|
|
100
101
|
fs.copyFileSync(paths.sourceFile, paths.mcpClientPath);
|
|
101
102
|
|
|
103
|
+
// Copy package.json to stable location
|
|
104
|
+
const packageJsonSource = path.resolve(__dirname, 'package.json');
|
|
105
|
+
const packageJsonDest = path.join(paths.packageDir, 'package.json');
|
|
106
|
+
fs.copyFileSync(packageJsonSource, packageJsonDest);
|
|
107
|
+
|
|
108
|
+
// Install dependencies
|
|
109
|
+
console.log(` 📦 Installing dependencies...`);
|
|
110
|
+
try {
|
|
111
|
+
execSync('npm install --production --silent', {
|
|
112
|
+
cwd: paths.packageDir,
|
|
113
|
+
stdio: 'pipe'
|
|
114
|
+
});
|
|
115
|
+
console.log(` ✅ Dependencies installed successfully`);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error(` ⚠️ Warning: Failed to install dependencies automatically`);
|
|
118
|
+
console.error(` 💡 Run manually: cd ${paths.packageDir} && npm install`);
|
|
119
|
+
}
|
|
120
|
+
|
|
102
121
|
console.log(` 📦 Installed MCP client to: ${paths.packageDir}`);
|
|
103
122
|
|
|
104
123
|
return paths;
|
|
@@ -178,26 +197,33 @@ exec node "${mcpClientPath}"`;
|
|
|
178
197
|
|
|
179
198
|
function updateClaudeConfig(configPath) {
|
|
180
199
|
let config = {};
|
|
181
|
-
|
|
200
|
+
let existingApiKey = "";
|
|
201
|
+
|
|
182
202
|
// Read existing config if it exists
|
|
183
203
|
if (fs.existsSync(configPath)) {
|
|
184
204
|
try {
|
|
185
205
|
const content = fs.readFileSync(configPath, 'utf8');
|
|
186
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
|
+
}
|
|
187
213
|
} catch (error) {
|
|
188
214
|
console.warn(`Warning: Could not parse existing config at ${configPath}`);
|
|
189
215
|
}
|
|
190
216
|
}
|
|
191
|
-
|
|
217
|
+
|
|
192
218
|
// Ensure mcpServers exists
|
|
193
219
|
if (!config.mcpServers) {
|
|
194
220
|
config.mcpServers = {};
|
|
195
221
|
}
|
|
196
|
-
|
|
222
|
+
|
|
197
223
|
// Detect if we need a wrapper script (for nvm users)
|
|
198
224
|
const nodeEnv = detectNodeEnvironment();
|
|
199
225
|
const claudeDir = path.join(os.homedir(), '.claude');
|
|
200
|
-
|
|
226
|
+
|
|
201
227
|
if (nodeEnv.isNvm) {
|
|
202
228
|
// Create wrapper script for nvm users
|
|
203
229
|
console.log(' 🔧 Detected nvm environment, creating wrapper script...');
|
|
@@ -207,29 +233,40 @@ function updateClaudeConfig(configPath) {
|
|
|
207
233
|
command: wrapperPath,
|
|
208
234
|
env: {
|
|
209
235
|
MCP_SERVER_URL: "https://mcp.i18nagent.ai",
|
|
210
|
-
API_KEY: ""
|
|
236
|
+
API_KEY: existingApiKey || ""
|
|
211
237
|
}
|
|
212
238
|
};
|
|
213
239
|
} else {
|
|
214
240
|
// Standard configuration for system node
|
|
215
241
|
const baseConfig = createMCPConfig();
|
|
216
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
|
+
}
|
|
217
247
|
}
|
|
218
|
-
|
|
248
|
+
|
|
219
249
|
// Write updated config
|
|
220
250
|
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
221
251
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
222
|
-
|
|
252
|
+
|
|
223
253
|
return config;
|
|
224
254
|
}
|
|
225
255
|
|
|
226
256
|
function updateGenericMCPConfig(configPath) {
|
|
227
257
|
let config = {};
|
|
258
|
+
let existingApiKey = "";
|
|
228
259
|
|
|
229
260
|
if (fs.existsSync(configPath)) {
|
|
230
261
|
try {
|
|
231
262
|
const existing = fs.readFileSync(configPath, 'utf8');
|
|
232
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
|
+
}
|
|
233
270
|
} catch (error) {
|
|
234
271
|
console.warn(`Warning: Could not parse existing config at ${configPath}`);
|
|
235
272
|
}
|
|
@@ -242,6 +279,11 @@ function updateGenericMCPConfig(configPath) {
|
|
|
242
279
|
const baseConfig = createMCPConfig();
|
|
243
280
|
config.mcpServers["i18n-agent"] = baseConfig.mcpServers["i18n-agent"];
|
|
244
281
|
|
|
282
|
+
// Preserve existing API key
|
|
283
|
+
if (existingApiKey) {
|
|
284
|
+
config.mcpServers["i18n-agent"].env.API_KEY = existingApiKey;
|
|
285
|
+
}
|
|
286
|
+
|
|
245
287
|
// Write config
|
|
246
288
|
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
247
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.
|
|
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": {
|