@i18n-agent/mcp-client 1.12.0 ā 1.13.0
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/i18n-agent.js +1 -1
- package/install.js +104 -14
- package/package.json +1 -1
package/i18n-agent.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
|
+
const MCP_CLIENT_VERSION = '1.13.0';
|
|
9
9
|
|
|
10
10
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
11
11
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
package/install.js
CHANGED
|
@@ -139,7 +139,7 @@ function copyMcpClientToStableLocation() {
|
|
|
139
139
|
// Install dependencies
|
|
140
140
|
console.log(` š¦ Installing dependencies...`);
|
|
141
141
|
try {
|
|
142
|
-
execSync('npm install --
|
|
142
|
+
execSync('npm install --omit=dev --ignore-scripts --silent', {
|
|
143
143
|
cwd: paths.packageDir,
|
|
144
144
|
stdio: 'pipe'
|
|
145
145
|
});
|
|
@@ -182,6 +182,62 @@ function checkExistingApiKey(configPath) {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
// Extract actual API key value from a config file
|
|
186
|
+
function extractApiKeyFromConfig(configPath) {
|
|
187
|
+
if (!fs.existsSync(configPath)) {
|
|
188
|
+
return '';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
const content = fs.readFileSync(configPath, 'utf8');
|
|
193
|
+
const config = JSON.parse(content);
|
|
194
|
+
const apiKey = config.mcpServers?.["i18n-agent"]?.env?.API_KEY;
|
|
195
|
+
return (apiKey && apiKey.trim() !== '') ? apiKey.trim() : '';
|
|
196
|
+
} catch (error) {
|
|
197
|
+
return '';
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Find any existing API key from all available IDEs
|
|
202
|
+
function findAnyExistingApiKey(availableIDEs, claudeCodeCLIAvailable = false, codexCLIAvailable = false) {
|
|
203
|
+
// Check Claude Code CLI first
|
|
204
|
+
if (claudeCodeCLIAvailable) {
|
|
205
|
+
const cliKey = getClaudeCodeExistingApiKey('i18n-agent');
|
|
206
|
+
if (cliKey) {
|
|
207
|
+
console.log(' š Found existing API key from Claude Code CLI');
|
|
208
|
+
return cliKey;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Check Codex CLI
|
|
213
|
+
if (codexCLIAvailable) {
|
|
214
|
+
const cliKey = getCodexExistingApiKey('i18n-agent');
|
|
215
|
+
if (cliKey) {
|
|
216
|
+
console.log(' š Found existing API key from Codex CLI');
|
|
217
|
+
return cliKey;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Check all config files
|
|
222
|
+
for (const ide of availableIDEs) {
|
|
223
|
+
const apiKey = extractApiKeyFromConfig(ide.configPath);
|
|
224
|
+
if (apiKey) {
|
|
225
|
+
console.log(` š Found existing API key from ${ide.name}`);
|
|
226
|
+
return apiKey;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Also check ~/.claude.json specifically
|
|
231
|
+
const claudeJsonPath = path.join(os.homedir(), '.claude.json');
|
|
232
|
+
const claudeJsonKey = extractApiKeyFromConfig(claudeJsonPath);
|
|
233
|
+
if (claudeJsonKey) {
|
|
234
|
+
console.log(' š Found existing API key from ~/.claude.json');
|
|
235
|
+
return claudeJsonKey;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return '';
|
|
239
|
+
}
|
|
240
|
+
|
|
185
241
|
async function checkExistingApiKeys(availableIDEs, claudeCodeCLIAvailable = false, codexCLIAvailable = false) {
|
|
186
242
|
const withKeys = [];
|
|
187
243
|
const withoutKeys = [];
|
|
@@ -474,7 +530,7 @@ exec node "${mcpClientPath}"`;
|
|
|
474
530
|
return wrapperPath;
|
|
475
531
|
}
|
|
476
532
|
|
|
477
|
-
function updateClaudeConfig(configPath, ideKey = 'claude') {
|
|
533
|
+
function updateClaudeConfig(configPath, ideKey = 'claude', sharedApiKey = '') {
|
|
478
534
|
let config = {};
|
|
479
535
|
let existingApiKey = "";
|
|
480
536
|
let hasApiKey = false;
|
|
@@ -496,6 +552,13 @@ function updateClaudeConfig(configPath, ideKey = 'claude') {
|
|
|
496
552
|
}
|
|
497
553
|
}
|
|
498
554
|
|
|
555
|
+
// Use shared API key if no existing key found
|
|
556
|
+
if (!existingApiKey && sharedApiKey) {
|
|
557
|
+
existingApiKey = sharedApiKey;
|
|
558
|
+
hasApiKey = true;
|
|
559
|
+
console.log(' š Using shared API key from another IDE');
|
|
560
|
+
}
|
|
561
|
+
|
|
499
562
|
// Ensure mcpServers exists
|
|
500
563
|
if (!config.mcpServers) {
|
|
501
564
|
config.mcpServers = {};
|
|
@@ -557,7 +620,7 @@ function updateClaudeConfig(configPath, ideKey = 'claude') {
|
|
|
557
620
|
return { config, hasApiKey };
|
|
558
621
|
}
|
|
559
622
|
|
|
560
|
-
function updateGenericMCPConfig(configPath) {
|
|
623
|
+
function updateGenericMCPConfig(configPath, sharedApiKey = '') {
|
|
561
624
|
let config = {};
|
|
562
625
|
let existingApiKey = "";
|
|
563
626
|
let hasApiKey = false;
|
|
@@ -578,6 +641,13 @@ function updateGenericMCPConfig(configPath) {
|
|
|
578
641
|
}
|
|
579
642
|
}
|
|
580
643
|
|
|
644
|
+
// Use shared API key if no existing key found
|
|
645
|
+
if (!existingApiKey && sharedApiKey) {
|
|
646
|
+
existingApiKey = sharedApiKey;
|
|
647
|
+
hasApiKey = true;
|
|
648
|
+
console.log(' š Using shared API key from another IDE');
|
|
649
|
+
}
|
|
650
|
+
|
|
581
651
|
if (!config.mcpServers) {
|
|
582
652
|
config.mcpServers = {};
|
|
583
653
|
}
|
|
@@ -652,6 +722,9 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
|
|
|
652
722
|
// Check for existing API keys BEFORE installation
|
|
653
723
|
const { withKeys, withoutKeys } = await checkExistingApiKeys(availableIDEs, claudeCodeCLIAvailable, codexCLIAvailable);
|
|
654
724
|
|
|
725
|
+
// Find a shared API key from any IDE that has one - will be applied to all IDEs
|
|
726
|
+
const sharedApiKey = findAnyExistingApiKey(availableIDEs, claudeCodeCLIAvailable, codexCLIAvailable);
|
|
727
|
+
|
|
655
728
|
if (withKeys.length > 0 && withoutKeys.length === 0) {
|
|
656
729
|
console.log(`ā
API Keys Already Configured:`);
|
|
657
730
|
withKeys.forEach(ide => {
|
|
@@ -659,17 +732,24 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
|
|
|
659
732
|
});
|
|
660
733
|
console.log(`\nš Your API keys are preserved. Updating MCP client files only...\n`);
|
|
661
734
|
} else if (withKeys.length > 0 && withoutKeys.length > 0) {
|
|
662
|
-
// Mixed case: some have keys, some don't
|
|
735
|
+
// Mixed case: some have keys, some don't - we'll share the key!
|
|
663
736
|
console.log(`ā
API Keys Already Configured:`);
|
|
664
737
|
withKeys.forEach(ide => {
|
|
665
738
|
console.log(` - ${ide.name}`);
|
|
666
739
|
});
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
740
|
+
if (sharedApiKey) {
|
|
741
|
+
console.log(`\nš Will apply existing API key to:`);
|
|
742
|
+
withoutKeys.forEach(ide => {
|
|
743
|
+
console.log(` - ${ide.name}`);
|
|
744
|
+
});
|
|
745
|
+
console.log(`\nš API key will be shared across all IDEs.\n`);
|
|
746
|
+
} else {
|
|
747
|
+
console.log(`\nš API Key Setup Required:`);
|
|
748
|
+
withoutKeys.forEach(ide => {
|
|
749
|
+
console.log(` - ${ide.name}`);
|
|
750
|
+
});
|
|
751
|
+
console.log(`\nš” Get your API key at: https://app.i18nagent.ai\n`);
|
|
752
|
+
}
|
|
673
753
|
} else if (withoutKeys.length > 0) {
|
|
674
754
|
console.log(`š API Key Setup Required:`);
|
|
675
755
|
withoutKeys.forEach(ide => {
|
|
@@ -710,7 +790,7 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
|
|
|
710
790
|
|
|
711
791
|
// Special handling for Claude Code CLI - use native CLI if available
|
|
712
792
|
if (ide.key === 'claude-code' && claudeCodeCLIAvailable) {
|
|
713
|
-
// Get existing API key - check CLI registration first, then config file
|
|
793
|
+
// Get existing API key - check CLI registration first, then config file, then use shared key
|
|
714
794
|
let existingApiKey = getClaudeCodeExistingApiKey('i18n-agent');
|
|
715
795
|
if (!existingApiKey && fs.existsSync(ide.configPath)) {
|
|
716
796
|
try {
|
|
@@ -721,6 +801,11 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
|
|
|
721
801
|
// Ignore parse errors
|
|
722
802
|
}
|
|
723
803
|
}
|
|
804
|
+
// Use shared API key if no IDE-specific key found
|
|
805
|
+
if (!existingApiKey && sharedApiKey) {
|
|
806
|
+
existingApiKey = sharedApiKey;
|
|
807
|
+
console.log(' š Using shared API key from another IDE');
|
|
808
|
+
}
|
|
724
809
|
|
|
725
810
|
try {
|
|
726
811
|
installViaClaudeCodeCLI(existingApiKey);
|
|
@@ -744,7 +829,7 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
|
|
|
744
829
|
|
|
745
830
|
// Special handling for Codex - use native CLI if available
|
|
746
831
|
if (ide.key === 'codex' && codexCLIAvailable) {
|
|
747
|
-
// Get existing API key - check CLI registration first, then config file
|
|
832
|
+
// Get existing API key - check CLI registration first, then config file, then use shared key
|
|
748
833
|
let existingApiKey = getCodexExistingApiKey('i18n-agent');
|
|
749
834
|
if (!existingApiKey && fs.existsSync(ide.configPath)) {
|
|
750
835
|
try {
|
|
@@ -755,6 +840,11 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
|
|
|
755
840
|
// Ignore parse errors
|
|
756
841
|
}
|
|
757
842
|
}
|
|
843
|
+
// Use shared API key if no IDE-specific key found
|
|
844
|
+
if (!existingApiKey && sharedApiKey) {
|
|
845
|
+
existingApiKey = sharedApiKey;
|
|
846
|
+
console.log(' š Using shared API key from another IDE');
|
|
847
|
+
}
|
|
758
848
|
|
|
759
849
|
try {
|
|
760
850
|
installViaCodexCLI(existingApiKey);
|
|
@@ -777,9 +867,9 @@ For manual setup instructions, visit: https://docs.i18nagent.ai/setup
|
|
|
777
867
|
}
|
|
778
868
|
|
|
779
869
|
if (ide.key === 'claude' || ide.key === 'claude-code') {
|
|
780
|
-
result = updateClaudeConfig(ide.configPath, ide.key);
|
|
870
|
+
result = updateClaudeConfig(ide.configPath, ide.key, sharedApiKey);
|
|
781
871
|
} else {
|
|
782
|
-
result = updateGenericMCPConfig(ide.configPath);
|
|
872
|
+
result = updateGenericMCPConfig(ide.configPath, sharedApiKey);
|
|
783
873
|
}
|
|
784
874
|
|
|
785
875
|
console.log(`ā
${ide.name} configured successfully!`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i18n-agent/mcp-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
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": "i18n-agent.js",
|
|
6
6
|
"bin": {
|