troxy-cli 1.3.4 → 1.3.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/package.json +1 -1
- package/src/init.js +52 -7
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -15,6 +15,7 @@ function prompt(question) {
|
|
|
15
15
|
const MCP_CLIENTS = [
|
|
16
16
|
{
|
|
17
17
|
name: 'Claude Desktop',
|
|
18
|
+
type: 'standard',
|
|
18
19
|
path: {
|
|
19
20
|
darwin: path.join(os.homedir(), 'Library/Application Support/Claude/claude_desktop_config.json'),
|
|
20
21
|
win32: path.join(process.env.APPDATA || os.homedir(), 'Claude/claude_desktop_config.json'),
|
|
@@ -23,6 +24,7 @@ const MCP_CLIENTS = [
|
|
|
23
24
|
},
|
|
24
25
|
{
|
|
25
26
|
name: 'Cursor',
|
|
27
|
+
type: 'standard',
|
|
26
28
|
path: {
|
|
27
29
|
darwin: path.join(os.homedir(), '.cursor/mcp.json'),
|
|
28
30
|
win32: path.join(os.homedir(), '.cursor/mcp.json'),
|
|
@@ -31,12 +33,31 @@ const MCP_CLIENTS = [
|
|
|
31
33
|
},
|
|
32
34
|
{
|
|
33
35
|
name: 'Windsurf',
|
|
36
|
+
type: 'standard',
|
|
34
37
|
path: {
|
|
35
38
|
darwin: path.join(os.homedir(), '.codeium/windsurf/mcp_config.json'),
|
|
36
39
|
win32: path.join(os.homedir(), '.codeium/windsurf/mcp_config.json'),
|
|
37
40
|
linux: path.join(os.homedir(), '.codeium/windsurf/mcp_config.json'),
|
|
38
41
|
},
|
|
39
42
|
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Zed',
|
|
45
|
+
type: 'zed',
|
|
46
|
+
path: {
|
|
47
|
+
darwin: path.join(os.homedir(), 'Library/Application Support/Zed/settings.json'),
|
|
48
|
+
win32: path.join(process.env.APPDATA || os.homedir(), 'Zed/settings.json'),
|
|
49
|
+
linux: path.join(os.homedir(), '.config/zed/settings.json'),
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'Continue',
|
|
54
|
+
type: 'continue',
|
|
55
|
+
path: {
|
|
56
|
+
darwin: path.join(os.homedir(), '.continue/config.json'),
|
|
57
|
+
win32: path.join(os.homedir(), '.continue/config.json'),
|
|
58
|
+
linux: path.join(os.homedir(), '.continue/config.json'),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
40
61
|
];
|
|
41
62
|
|
|
42
63
|
export async function runInit({ key } = {}) {
|
|
@@ -106,7 +127,9 @@ export async function runInit({ key } = {}) {
|
|
|
106
127
|
for (const client of detected) {
|
|
107
128
|
const configPath = client.path[platform] ?? client.path.linux;
|
|
108
129
|
try {
|
|
109
|
-
|
|
130
|
+
if (client.type === 'zed') patchZedConfig(configPath, key);
|
|
131
|
+
else if (client.type === 'continue') patchContinueConfig(configPath, key);
|
|
132
|
+
else patchMcpConfig(configPath, key);
|
|
110
133
|
console.log(` • ${client.name} ✓`);
|
|
111
134
|
} catch (err) {
|
|
112
135
|
console.log(` • ${client.name} ✗ (${err.message})`);
|
|
@@ -221,14 +244,36 @@ function mcpEntry(apiKey) {
|
|
|
221
244
|
|
|
222
245
|
function patchMcpConfig(configPath, apiKey) {
|
|
223
246
|
let config = {};
|
|
224
|
-
try {
|
|
225
|
-
config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
226
|
-
} catch {
|
|
227
|
-
// file exists but is empty or malformed — start fresh
|
|
228
|
-
}
|
|
229
|
-
|
|
247
|
+
try { config = JSON.parse(fs.readFileSync(configPath, 'utf8')); } catch {}
|
|
230
248
|
if (!config.mcpServers) config.mcpServers = {};
|
|
231
249
|
config.mcpServers.troxy = mcpEntry(apiKey).troxy;
|
|
250
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function patchZedConfig(configPath, apiKey) {
|
|
254
|
+
let config = {};
|
|
255
|
+
try { config = JSON.parse(fs.readFileSync(configPath, 'utf8')); } catch {}
|
|
256
|
+
if (!config.context_servers) config.context_servers = {};
|
|
257
|
+
config.context_servers.troxy = {
|
|
258
|
+
source: 'custom',
|
|
259
|
+
command: 'npx',
|
|
260
|
+
args: ['troxy-cli', 'mcp'],
|
|
261
|
+
env: { TROXY_API_KEY: apiKey },
|
|
262
|
+
};
|
|
263
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
264
|
+
}
|
|
232
265
|
|
|
266
|
+
function patchContinueConfig(configPath, apiKey) {
|
|
267
|
+
let config = {};
|
|
268
|
+
try { config = JSON.parse(fs.readFileSync(configPath, 'utf8')); } catch {}
|
|
269
|
+
if (!config.modelContextProtocolServers) config.modelContextProtocolServers = [];
|
|
270
|
+
// Remove existing troxy entry if present, then add fresh
|
|
271
|
+
config.modelContextProtocolServers = config.modelContextProtocolServers.filter(
|
|
272
|
+
s => !(s.transport?.command === 'npx' && s.transport?.args?.includes('troxy-cli')),
|
|
273
|
+
);
|
|
274
|
+
config.modelContextProtocolServers.push({
|
|
275
|
+
transport: { type: 'stdio', command: 'npx', args: ['troxy-cli', 'mcp'] },
|
|
276
|
+
env: { TROXY_API_KEY: apiKey },
|
|
277
|
+
});
|
|
233
278
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
234
279
|
}
|