@i18n-agent/mcp-client 1.8.1 โ 1.8.3
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 +66 -21
- package/mcp-client.js +23 -9
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -46,8 +46,8 @@ const IDE_CONFIGS = {
|
|
|
46
46
|
},
|
|
47
47
|
'claude-code': {
|
|
48
48
|
name: 'Claude Code CLI',
|
|
49
|
-
configPath: path.join(os.homedir(), '.claude.json'),
|
|
50
|
-
displayPath: '~/.claude.json'
|
|
49
|
+
configPath: path.join(os.homedir(), '.config/claude/claude_code_config.json'),
|
|
50
|
+
displayPath: '~/.config/claude/claude_code_config.json'
|
|
51
51
|
},
|
|
52
52
|
cursor: {
|
|
53
53
|
name: 'Cursor',
|
|
@@ -83,21 +83,37 @@ Features:
|
|
|
83
83
|
`);
|
|
84
84
|
|
|
85
85
|
const getMcpClientPaths = () => {
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
86
|
+
// Instead of using ephemeral npx cache, install to stable location
|
|
87
|
+
const stableDir = path.join(os.homedir(), '.claude', 'mcp-servers', 'i18n-agent');
|
|
88
|
+
const mcpClientPath = path.join(stableDir, 'mcp-client.js');
|
|
89
|
+
const packageDir = stableDir;
|
|
90
|
+
return { mcpClientPath, packageDir, sourceFile: path.resolve(__dirname, 'mcp-client.js') };
|
|
89
91
|
};
|
|
90
92
|
|
|
93
|
+
function copyMcpClientToStableLocation() {
|
|
94
|
+
const paths = getMcpClientPaths();
|
|
95
|
+
|
|
96
|
+
// Create stable directory
|
|
97
|
+
fs.mkdirSync(paths.packageDir, { recursive: true });
|
|
98
|
+
|
|
99
|
+
// Copy mcp-client.js to stable location
|
|
100
|
+
fs.copyFileSync(paths.sourceFile, paths.mcpClientPath);
|
|
101
|
+
|
|
102
|
+
console.log(` ๐ฆ Installed MCP client to: ${paths.packageDir}`);
|
|
103
|
+
|
|
104
|
+
return paths;
|
|
105
|
+
}
|
|
106
|
+
|
|
91
107
|
async function detectAvailableIDEs() {
|
|
92
108
|
const available = [];
|
|
93
|
-
|
|
109
|
+
|
|
94
110
|
for (const [key, config] of Object.entries(IDE_CONFIGS)) {
|
|
95
111
|
const configDir = path.dirname(config.configPath);
|
|
96
112
|
if (fs.existsSync(configDir)) {
|
|
97
113
|
available.push({ key, ...config });
|
|
98
114
|
}
|
|
99
115
|
}
|
|
100
|
-
|
|
116
|
+
|
|
101
117
|
return available;
|
|
102
118
|
}
|
|
103
119
|
|
|
@@ -236,7 +252,12 @@ function updateGenericMCPConfig(configPath) {
|
|
|
236
252
|
async function main() {
|
|
237
253
|
try {
|
|
238
254
|
console.log('๐ Detecting available AI IDEs...\n');
|
|
239
|
-
|
|
255
|
+
|
|
256
|
+
// First, copy MCP client to stable location
|
|
257
|
+
console.log('๐ฆ Installing MCP client files...');
|
|
258
|
+
copyMcpClientToStableLocation();
|
|
259
|
+
console.log('');
|
|
260
|
+
|
|
240
261
|
const availableIDEs = await detectAvailableIDEs();
|
|
241
262
|
|
|
242
263
|
if (availableIDEs.length === 0) {
|
|
@@ -312,32 +333,56 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
|
|
|
312
333
|
|
|
313
334
|
console.log(`๐ Installation complete! Configured ${installCount} IDE(s).
|
|
314
335
|
|
|
315
|
-
๐
|
|
316
|
-
|
|
317
|
-
1
|
|
336
|
+
๐ CRITICAL: Add your API key (required for MCP client to work)
|
|
337
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
338
|
+
Step 1: Get your API key
|
|
339
|
+
๐ Visit: https://app.i18nagent.ai
|
|
340
|
+
๐ Sign up or log in
|
|
341
|
+
๐ Copy your API key (starts with "i18n_")
|
|
318
342
|
|
|
319
|
-
2
|
|
343
|
+
Step 2: Add API key to config file(s)
|
|
320
344
|
${configPaths}
|
|
321
345
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
346
|
+
Option A - Edit config file directly (RECOMMENDED):
|
|
347
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
348
|
+
Open the config file and find the "env" section:
|
|
349
|
+
|
|
350
|
+
"mcpServers": {
|
|
351
|
+
"i18n-agent": {
|
|
352
|
+
"command": "...",
|
|
353
|
+
"env": {
|
|
354
|
+
"MCP_SERVER_URL": "https://mcp.i18nagent.ai",
|
|
355
|
+
"API_KEY": "" โ Paste your API key here (between the quotes)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
326
358
|
}
|
|
327
359
|
|
|
328
|
-
|
|
360
|
+
Example with actual key:
|
|
361
|
+
"API_KEY": "i18n_1234567890abcdef"
|
|
362
|
+
|
|
363
|
+
Option B - Use environment variable:
|
|
364
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
329
365
|
${envVarInstructions}
|
|
330
366
|
|
|
331
|
-
3
|
|
367
|
+
Step 3: Restart your IDE
|
|
368
|
+
Close and reopen your IDE to load the new configuration
|
|
332
369
|
|
|
333
370
|
๐งช Test the installation
|
|
371
|
+
โโโโโโโโโโโโโโโโโโโโโโ
|
|
334
372
|
Try these commands in your AI IDE:
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
373
|
+
โ "Translate 'Hello world' to Spanish"
|
|
374
|
+
โ "Check my translation credits"
|
|
375
|
+
โ "List supported languages"
|
|
376
|
+
|
|
377
|
+
If you get "Invalid API key" errors, double-check:
|
|
378
|
+
- API key is correctly pasted in the config file
|
|
379
|
+
- No extra spaces or quotes around the key
|
|
380
|
+
- Config file is saved
|
|
381
|
+
- IDE has been restarted
|
|
338
382
|
|
|
339
383
|
๐ Documentation: https://docs.i18nagent.ai
|
|
340
384
|
๐ Issues: https://github.com/i18n-agent/mcp-client/issues
|
|
385
|
+
๐ฌ Support: support@i18nagent.ai
|
|
341
386
|
`);
|
|
342
387
|
} else {
|
|
343
388
|
console.error('โ Installation failed for all IDEs. Please check the error messages above.');
|
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.
|
|
8
|
+
const MCP_CLIENT_VERSION = '1.8.2';
|
|
9
9
|
|
|
10
10
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
11
11
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
@@ -334,26 +334,40 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
334
334
|
}
|
|
335
335
|
} catch (error) {
|
|
336
336
|
console.error(`Error executing tool ${name}:`, error);
|
|
337
|
-
|
|
337
|
+
|
|
338
338
|
// Check if error is about API key or credit issues
|
|
339
339
|
const errorMsg = error.message || '';
|
|
340
|
-
const isAuthError = errorMsg.toLowerCase().includes('api key') ||
|
|
340
|
+
const isAuthError = errorMsg.toLowerCase().includes('api key') ||
|
|
341
341
|
errorMsg.toLowerCase().includes('api_key') ||
|
|
342
342
|
errorMsg.toLowerCase().includes('unauthorized') ||
|
|
343
343
|
errorMsg.includes('(401)');
|
|
344
|
-
const isCreditError = errorMsg.toLowerCase().includes('credit') ||
|
|
344
|
+
const isCreditError = errorMsg.toLowerCase().includes('credit') ||
|
|
345
345
|
errorMsg.toLowerCase().includes('quota') ||
|
|
346
346
|
errorMsg.toLowerCase().includes('limit exceeded') ||
|
|
347
347
|
errorMsg.includes('(402)');
|
|
348
|
-
|
|
348
|
+
|
|
349
|
+
// Check if error is already descriptive (validation errors, specific errors with clear messages)
|
|
350
|
+
const hasDescriptiveError = errorMsg.includes('Invalid language code') ||
|
|
351
|
+
errorMsg.includes('is a multilingual region') ||
|
|
352
|
+
errorMsg.includes('not found') ||
|
|
353
|
+
errorMsg.includes('timed out') ||
|
|
354
|
+
errorMsg.includes('Timeout') ||
|
|
355
|
+
errorMsg.includes('Required') ||
|
|
356
|
+
errorMsg.includes('must be') ||
|
|
357
|
+
errorMsg.includes('is required') ||
|
|
358
|
+
errorMsg.length > 200; // Long errors are likely already detailed
|
|
359
|
+
|
|
349
360
|
let finalErrorMsg = error.message;
|
|
350
|
-
|
|
351
|
-
//
|
|
361
|
+
|
|
362
|
+
// Only add retry guidance if:
|
|
363
|
+
// 1. It's not an auth/credit error
|
|
364
|
+
// 2. It's a content-based tool
|
|
365
|
+
// 3. The error is NOT already descriptive
|
|
352
366
|
const contentBasedTools = ['translate_text', 'translate_file'];
|
|
353
|
-
if (!isAuthError && !isCreditError && contentBasedTools.includes(name)) {
|
|
367
|
+
if (!isAuthError && !isCreditError && !hasDescriptiveError && contentBasedTools.includes(name)) {
|
|
354
368
|
finalErrorMsg = `${error.message}. Please retry with smaller chunks or split the content into multiple requests.`;
|
|
355
369
|
}
|
|
356
|
-
|
|
370
|
+
|
|
357
371
|
throw new McpError(
|
|
358
372
|
ErrorCode.InternalError,
|
|
359
373
|
`Tool execution failed: ${finalErrorMsg}`
|
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.3",
|
|
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": {
|