@velaro/cli 0.3.0 → 0.4.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/lib/commands/mcp-key.js +53 -1
- package/package.json +1 -1
package/lib/commands/mcp-key.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
1
4
|
import { get, post, del } from '../api.js';
|
|
2
5
|
import { runCommand } from '../run.js';
|
|
3
6
|
|
|
@@ -10,7 +13,8 @@ export const mcpKeyCommand = {
|
|
|
10
13
|
.command(mcpKeyCreateCommand)
|
|
11
14
|
.command(mcpKeyRevokeCommand)
|
|
12
15
|
.command(mcpKeyRotateCommand)
|
|
13
|
-
.
|
|
16
|
+
.command(mcpKeyInstallCommand)
|
|
17
|
+
.demandCommand(1, 'Specify a subcommand: list, create, revoke, rotate, install'),
|
|
14
18
|
handler: () => {},
|
|
15
19
|
};
|
|
16
20
|
|
|
@@ -64,6 +68,54 @@ const mcpKeyRevokeCommand = {
|
|
|
64
68
|
}),
|
|
65
69
|
};
|
|
66
70
|
|
|
71
|
+
const mcpKeyInstallCommand = {
|
|
72
|
+
command: 'install',
|
|
73
|
+
describe: 'Create an MCP key and write it to ~/.claude/settings.json automatically',
|
|
74
|
+
builder: (y) =>
|
|
75
|
+
y
|
|
76
|
+
.option('label', {
|
|
77
|
+
describe: 'Label for the key',
|
|
78
|
+
type: 'string',
|
|
79
|
+
default: 'Claude Code',
|
|
80
|
+
})
|
|
81
|
+
.option('api', {
|
|
82
|
+
describe: 'Velaro API base URL (defaults to production)',
|
|
83
|
+
type: 'string',
|
|
84
|
+
}),
|
|
85
|
+
|
|
86
|
+
handler: runCommand(async (argv) => {
|
|
87
|
+
const payload = { label: argv.label };
|
|
88
|
+
const result = await post('/McpApiKeys', payload);
|
|
89
|
+
const rawKey = result.rawKey;
|
|
90
|
+
|
|
91
|
+
// Write to ~/.claude/settings.json
|
|
92
|
+
const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
|
|
93
|
+
let settings = {};
|
|
94
|
+
if (fs.existsSync(settingsPath)) {
|
|
95
|
+
try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); } catch {}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const apiBase = argv.api || 'https://api-admin-us-east.velaro.com';
|
|
99
|
+
settings.mcpServers = settings.mcpServers || {};
|
|
100
|
+
settings.mcpServers.velaro = {
|
|
101
|
+
command: 'npx',
|
|
102
|
+
args: ['-y', '@velaro/mcp-server'],
|
|
103
|
+
env: {
|
|
104
|
+
VELARO_MCP_KEY: rawKey,
|
|
105
|
+
VELARO_ADMIN_API: apiBase,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
110
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
111
|
+
|
|
112
|
+
console.log(`✅ MCP key created: ${result.label} (${result.keyPrefix}...)`);
|
|
113
|
+
console.log(`✅ Written to: ${settingsPath}`);
|
|
114
|
+
console.log(`\nRestart Claude Code to pick up the new MCP server.`);
|
|
115
|
+
console.log(`\nTo verify: run 'velaro mcp-key list' or check Settings → Developer → MCP Keys in the admin portal.`);
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
|
|
67
119
|
const mcpKeyRotateCommand = {
|
|
68
120
|
command: 'rotate <id>',
|
|
69
121
|
describe: 'Revoke an existing key and issue a replacement in one step',
|