@i18n-agent/mcp-client 1.8.1 → 1.8.2
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/mcp-client.js +23 -9
- package/package.json +1 -1
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.2",
|
|
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": {
|