mcpick 0.0.17 → 0.0.19
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/.vscode/settings.json +5 -0
- package/CHANGELOG.md +15 -0
- package/dist/add-B9nVyh8T.js +113 -0
- package/dist/add-json-CXNDl3al.js +58 -0
- package/dist/atomic-write-BqEykHp9.js +26 -0
- package/dist/backup-DSDhHI5f.js +64 -0
- package/dist/cache-D6kd7qE8.js +226 -0
- package/dist/claude-cli-BeA-bmoW.js +394 -0
- package/dist/cli-DNNZjJYL.js +84 -0
- package/dist/clone-DLFLewBY.js +88 -0
- package/dist/config-DijVdEFn.js +176 -0
- package/dist/dev-DRJRNp7y.js +265 -0
- package/dist/disable-BA8tXPJN.js +39 -0
- package/dist/enable-Bdnnn_Cq.js +40 -0
- package/dist/get-BPjMXTMc.js +41 -0
- package/dist/hook-state-Di8lUsPr.js +171 -0
- package/dist/hooks-Bmn7pUZa.js +280 -0
- package/dist/index.js +1230 -303
- package/dist/list-B8YeDWt6.js +64 -0
- package/dist/marketplace-Br89Tg-Z.js +168 -0
- package/dist/output-BchYq0mR.js +15 -0
- package/dist/paths-BPISiJi4.js +124 -0
- package/dist/plugin-cache-Bby9Dxm9.js +405 -0
- package/dist/plugins-DHYJF5CP.js +212 -0
- package/dist/profile-CX97sMGp.js +120 -0
- package/dist/profile-DkY_lBEm.js +70 -0
- package/dist/redact-O35tjnRD.js +26 -0
- package/dist/registry-CfUKT7_C.js +92 -0
- package/dist/reload-CYDhkCVZ.js +31 -0
- package/dist/remove-DIPWYMpk.js +31 -0
- package/dist/reset-project-choices-DRM5KByw.js +28 -0
- package/dist/restore-DdMfUljI.js +84 -0
- package/dist/rolldown-runtime-CiIaOW0V.js +13 -0
- package/dist/settings-DEcWtzLE.js +201 -0
- package/dist/validation-xMlbgGCF.js +44 -0
- package/package.json +20 -19
- package/dist/cli/commands/add-json.js +0 -60
- package/dist/cli/commands/add.js +0 -135
- package/dist/cli/commands/backup.js +0 -83
- package/dist/cli/commands/cache.js +0 -296
- package/dist/cli/commands/dev.js +0 -161
- package/dist/cli/commands/disable.js +0 -36
- package/dist/cli/commands/enable.js +0 -39
- package/dist/cli/commands/get.js +0 -45
- package/dist/cli/commands/hooks.js +0 -314
- package/dist/cli/commands/list.js +0 -63
- package/dist/cli/commands/marketplace.js +0 -211
- package/dist/cli/commands/plugins.js +0 -265
- package/dist/cli/commands/profile.js +0 -134
- package/dist/cli/commands/reload.js +0 -36
- package/dist/cli/commands/remove.js +0 -35
- package/dist/cli/commands/reset-project-choices.js +0 -32
- package/dist/cli/commands/restore.js +0 -105
- package/dist/cli/index.js +0 -28
- package/dist/cli/output.js +0 -21
- package/dist/commands/add-server.js +0 -310
- package/dist/commands/backup.js +0 -60
- package/dist/commands/edit-config.js +0 -109
- package/dist/commands/edit-plugins.js +0 -201
- package/dist/commands/manage-cache.js +0 -155
- package/dist/commands/manage-hooks.js +0 -99
- package/dist/commands/manage-marketplace.js +0 -293
- package/dist/commands/restore.js +0 -118
- package/dist/core/config.js +0 -146
- package/dist/core/dev-override.js +0 -210
- package/dist/core/hook-state.js +0 -220
- package/dist/core/plugin-cache.js +0 -506
- package/dist/core/profile.js +0 -94
- package/dist/core/registry.js +0 -121
- package/dist/core/settings.js +0 -243
- package/dist/core/validation.js +0 -49
- package/dist/types.js +0 -2
- package/dist/utils/atomic-write.js +0 -27
- package/dist/utils/claude-cli.js +0 -483
- package/dist/utils/paths.js +0 -114
package/dist/utils/claude-cli.js
DELETED
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
import { exec } from 'node:child_process';
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
|
-
const execAsync = promisify(exec);
|
|
4
|
-
/**
|
|
5
|
-
* Check if Claude CLI is available
|
|
6
|
-
*/
|
|
7
|
-
export async function check_claude_cli() {
|
|
8
|
-
try {
|
|
9
|
-
await execAsync('claude --version');
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Escape a string for shell usage
|
|
18
|
-
*/
|
|
19
|
-
function shell_escape(str) {
|
|
20
|
-
// Replace single quotes with escaped version
|
|
21
|
-
return `'${str.replace(/'/g, "'\\''")}'`;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Validate environment variable key
|
|
25
|
-
* Must start with letter or underscore, contain only alphanumeric and underscores
|
|
26
|
-
*/
|
|
27
|
-
function is_valid_env_key(key) {
|
|
28
|
-
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Build the claude mcp add command for a server
|
|
32
|
-
*/
|
|
33
|
-
function build_add_command(server, scope) {
|
|
34
|
-
const parts = ['claude', 'mcp', 'add'];
|
|
35
|
-
// Server name
|
|
36
|
-
parts.push(shell_escape(server.name));
|
|
37
|
-
// Transport type
|
|
38
|
-
const transport = server.type || 'stdio';
|
|
39
|
-
parts.push('--transport', transport);
|
|
40
|
-
// Scope
|
|
41
|
-
parts.push('--scope', scope);
|
|
42
|
-
// Handle different transport types
|
|
43
|
-
if (transport === 'stdio') {
|
|
44
|
-
// Environment variables (skip invalid keys to prevent injection)
|
|
45
|
-
if (server.env) {
|
|
46
|
-
for (const [key, value] of Object.entries(server.env)) {
|
|
47
|
-
if (is_valid_env_key(key)) {
|
|
48
|
-
parts.push('-e', `${key}=${shell_escape(value)}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Command and args (after --)
|
|
53
|
-
if ('command' in server && server.command) {
|
|
54
|
-
parts.push('--');
|
|
55
|
-
parts.push(shell_escape(server.command));
|
|
56
|
-
if (server.args && server.args.length > 0) {
|
|
57
|
-
parts.push(...server.args.map((arg) => shell_escape(arg)));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
// HTTP or SSE transport — URL must come before header flags
|
|
63
|
-
if ('url' in server && server.url) {
|
|
64
|
-
parts.push(shell_escape(server.url));
|
|
65
|
-
}
|
|
66
|
-
if ('headers' in server && server.headers) {
|
|
67
|
-
for (const [key, value] of Object.entries(server.headers)) {
|
|
68
|
-
parts.push('-H', shell_escape(`${key}: ${value}`));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return parts.join(' ');
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Add an MCP server using Claude CLI
|
|
76
|
-
*/
|
|
77
|
-
export async function add_mcp_via_cli(server, scope) {
|
|
78
|
-
// Check if CLI is available
|
|
79
|
-
const cli_available = await check_claude_cli();
|
|
80
|
-
if (!cli_available) {
|
|
81
|
-
return {
|
|
82
|
-
success: false,
|
|
83
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
const command = build_add_command(server, scope);
|
|
87
|
-
try {
|
|
88
|
-
await execAsync(command);
|
|
89
|
-
return { success: true };
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
93
|
-
return {
|
|
94
|
-
success: false,
|
|
95
|
-
error: `Failed to add server via CLI: ${message}`,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Remove an MCP server using Claude CLI
|
|
101
|
-
*/
|
|
102
|
-
export async function remove_mcp_via_cli(name) {
|
|
103
|
-
// Check if CLI is available
|
|
104
|
-
const cli_available = await check_claude_cli();
|
|
105
|
-
if (!cli_available) {
|
|
106
|
-
return {
|
|
107
|
-
success: false,
|
|
108
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
await execAsync(`claude mcp remove ${shell_escape(name)}`);
|
|
113
|
-
return { success: true };
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
117
|
-
return {
|
|
118
|
-
success: false,
|
|
119
|
-
error: `Failed to remove server via CLI: ${message}`,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Install a plugin via Claude CLI
|
|
125
|
-
*/
|
|
126
|
-
export async function install_plugin_via_cli(key, scope = 'user') {
|
|
127
|
-
const cli_available = await check_claude_cli();
|
|
128
|
-
if (!cli_available) {
|
|
129
|
-
return {
|
|
130
|
-
success: false,
|
|
131
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
try {
|
|
135
|
-
await execAsync(`claude plugin install ${shell_escape(key)} --scope ${scope}`);
|
|
136
|
-
return { success: true };
|
|
137
|
-
}
|
|
138
|
-
catch (error) {
|
|
139
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
140
|
-
return {
|
|
141
|
-
success: false,
|
|
142
|
-
error: `Failed to install plugin: ${message}`,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Uninstall a plugin via Claude CLI
|
|
148
|
-
*/
|
|
149
|
-
export async function uninstall_plugin_via_cli(key, scope = 'user') {
|
|
150
|
-
const cli_available = await check_claude_cli();
|
|
151
|
-
if (!cli_available) {
|
|
152
|
-
return {
|
|
153
|
-
success: false,
|
|
154
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
try {
|
|
158
|
-
await execAsync(`claude plugin uninstall ${shell_escape(key)} --scope ${scope}`);
|
|
159
|
-
return { success: true };
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
163
|
-
return {
|
|
164
|
-
success: false,
|
|
165
|
-
error: `Failed to uninstall plugin: ${message}`,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Update a plugin via Claude CLI
|
|
171
|
-
*/
|
|
172
|
-
export async function update_plugin_via_cli(key, scope = 'user') {
|
|
173
|
-
const cli_available = await check_claude_cli();
|
|
174
|
-
if (!cli_available) {
|
|
175
|
-
return {
|
|
176
|
-
success: false,
|
|
177
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
try {
|
|
181
|
-
await execAsync(`claude plugin update ${shell_escape(key)} --scope ${scope}`);
|
|
182
|
-
return { success: true };
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
186
|
-
return {
|
|
187
|
-
success: false,
|
|
188
|
-
error: `Failed to update plugin: ${message}`,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Add a marketplace via Claude CLI
|
|
194
|
-
*/
|
|
195
|
-
/**
|
|
196
|
-
* Extract GitHub owner/repo from various source formats.
|
|
197
|
-
* Returns null if not a recognizable GitHub reference.
|
|
198
|
-
*/
|
|
199
|
-
function parse_github_repo(source) {
|
|
200
|
-
// HTTPS URL: https://github.com/owner/repo[.git]
|
|
201
|
-
const https_match = source.match(/^https?:\/\/github\.com\/([^/]+)\/([^/.]+)(?:\.git)?$/);
|
|
202
|
-
if (https_match)
|
|
203
|
-
return { owner: https_match[1], repo: https_match[2] };
|
|
204
|
-
// SSH URL: git@github.com:owner/repo[.git]
|
|
205
|
-
const ssh_match = source.match(/^git@github\.com:([^/]+)\/([^/.]+)(?:\.git)?$/);
|
|
206
|
-
if (ssh_match)
|
|
207
|
-
return { owner: ssh_match[1], repo: ssh_match[2] };
|
|
208
|
-
// Shorthand: owner/repo (no slashes beyond the one separator)
|
|
209
|
-
const shorthand_match = source.match(/^([^/\s]+)\/([^/\s]+)$/);
|
|
210
|
-
if (shorthand_match)
|
|
211
|
-
return { owner: shorthand_match[1], repo: shorthand_match[2] };
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Validate that a GitHub repository exists and is accessible.
|
|
216
|
-
* Returns an error message if validation fails, null if OK.
|
|
217
|
-
*/
|
|
218
|
-
async function validate_github_repo(owner, repo) {
|
|
219
|
-
try {
|
|
220
|
-
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}`, {
|
|
221
|
-
method: 'GET',
|
|
222
|
-
headers: { Accept: 'application/vnd.github.v3+json' },
|
|
223
|
-
});
|
|
224
|
-
if (response.status === 200)
|
|
225
|
-
return null;
|
|
226
|
-
if (response.status === 404) {
|
|
227
|
-
return `Repository '${owner}/${repo}' not found on GitHub. Check the name or ensure it's not private.`;
|
|
228
|
-
}
|
|
229
|
-
if (response.status === 403) {
|
|
230
|
-
return `Access denied for '${owner}/${repo}'. The repository may be private — configure a GitHub token or use SSH.`;
|
|
231
|
-
}
|
|
232
|
-
return `GitHub API returned status ${response.status} for '${owner}/${repo}'.`;
|
|
233
|
-
}
|
|
234
|
-
catch {
|
|
235
|
-
// Network error — skip validation and let the CLI attempt the clone
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
export async function marketplace_add_via_cli(source) {
|
|
240
|
-
const cli_available = await check_claude_cli();
|
|
241
|
-
if (!cli_available) {
|
|
242
|
-
return {
|
|
243
|
-
success: false,
|
|
244
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
// Validate GitHub repo exists before attempting clone
|
|
248
|
-
// Only validate shorthand (owner/repo) — explicit URLs imply the user knows the repo
|
|
249
|
-
const gh = parse_github_repo(source);
|
|
250
|
-
const is_shorthand = gh && !source.startsWith('http') && !source.startsWith('git@');
|
|
251
|
-
if (gh && is_shorthand) {
|
|
252
|
-
const validation_error = await validate_github_repo(gh.owner, gh.repo);
|
|
253
|
-
if (validation_error) {
|
|
254
|
-
return { success: false, error: validation_error };
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
try {
|
|
258
|
-
await execAsync(`claude plugin marketplace add ${shell_escape(source)}`);
|
|
259
|
-
return { success: true };
|
|
260
|
-
}
|
|
261
|
-
catch (error) {
|
|
262
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
263
|
-
// Provide clearer error messages for common failures
|
|
264
|
-
if (message.includes('SSH') ||
|
|
265
|
-
message.includes('Permission denied (publickey)')) {
|
|
266
|
-
return {
|
|
267
|
-
success: false,
|
|
268
|
-
error: `SSH authentication failed for '${source}'. Either:\n - Configure SSH keys: https://docs.github.com/en/authentication/connecting-to-github-with-ssh\n - Use HTTPS URL instead: https://github.com/${gh ? `${gh.owner}/${gh.repo}` : source}`,
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
if (message.includes('not found') ||
|
|
272
|
-
message.includes('does not exist')) {
|
|
273
|
-
return {
|
|
274
|
-
success: false,
|
|
275
|
-
error: `Repository '${source}' not found. Check the name and your access permissions.`,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
return {
|
|
279
|
-
success: false,
|
|
280
|
-
error: `Failed to add marketplace: ${message}`,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Remove a marketplace via Claude CLI
|
|
286
|
-
*/
|
|
287
|
-
export async function marketplace_remove_via_cli(name) {
|
|
288
|
-
const cli_available = await check_claude_cli();
|
|
289
|
-
if (!cli_available) {
|
|
290
|
-
return {
|
|
291
|
-
success: false,
|
|
292
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
try {
|
|
296
|
-
await execAsync(`claude plugin marketplace remove ${shell_escape(name)}`);
|
|
297
|
-
return { success: true };
|
|
298
|
-
}
|
|
299
|
-
catch (error) {
|
|
300
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
301
|
-
return {
|
|
302
|
-
success: false,
|
|
303
|
-
error: `Failed to remove marketplace: ${message}`,
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Update marketplace(s) via Claude CLI
|
|
309
|
-
*/
|
|
310
|
-
export async function marketplace_update_via_cli(name) {
|
|
311
|
-
const cli_available = await check_claude_cli();
|
|
312
|
-
if (!cli_available) {
|
|
313
|
-
return {
|
|
314
|
-
success: false,
|
|
315
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
try {
|
|
319
|
-
const cmd = name
|
|
320
|
-
? `claude plugin marketplace update ${shell_escape(name)}`
|
|
321
|
-
: 'claude plugin marketplace update';
|
|
322
|
-
await execAsync(cmd);
|
|
323
|
-
return { success: true };
|
|
324
|
-
}
|
|
325
|
-
catch (error) {
|
|
326
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
327
|
-
return {
|
|
328
|
-
success: false,
|
|
329
|
-
error: `Failed to update marketplace: ${message}`,
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* List marketplaces via Claude CLI
|
|
335
|
-
*/
|
|
336
|
-
export async function marketplace_list_via_cli() {
|
|
337
|
-
const cli_available = await check_claude_cli();
|
|
338
|
-
if (!cli_available) {
|
|
339
|
-
return {
|
|
340
|
-
success: false,
|
|
341
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
try {
|
|
345
|
-
const { stdout } = await execAsync('claude plugin marketplace list');
|
|
346
|
-
return { success: true, stdout: stdout.trim() };
|
|
347
|
-
}
|
|
348
|
-
catch (error) {
|
|
349
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
350
|
-
return {
|
|
351
|
-
success: false,
|
|
352
|
-
error: `Failed to list marketplaces: ${message}`,
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Get the scope description for display
|
|
358
|
-
*/
|
|
359
|
-
export function get_scope_description(scope) {
|
|
360
|
-
switch (scope) {
|
|
361
|
-
case 'local':
|
|
362
|
-
return 'This project only (default)';
|
|
363
|
-
case 'project':
|
|
364
|
-
return 'Shared via .mcp.json (version controlled)';
|
|
365
|
-
case 'user':
|
|
366
|
-
return 'Global - all projects';
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Validate a plugin or marketplace manifest via Claude CLI
|
|
371
|
-
*/
|
|
372
|
-
export async function validate_plugin_via_cli(path) {
|
|
373
|
-
const cli_available = await check_claude_cli();
|
|
374
|
-
if (!cli_available) {
|
|
375
|
-
return {
|
|
376
|
-
success: false,
|
|
377
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
try {
|
|
381
|
-
const { stdout } = await execAsync(`claude plugin validate ${shell_escape(path)}`);
|
|
382
|
-
return { success: true, stdout: stdout.trim() };
|
|
383
|
-
}
|
|
384
|
-
catch (error) {
|
|
385
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
386
|
-
return {
|
|
387
|
-
success: false,
|
|
388
|
-
error: `Validation failed: ${message}`,
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Get details about an MCP server via Claude CLI
|
|
394
|
-
*/
|
|
395
|
-
export async function mcp_get_via_cli(name) {
|
|
396
|
-
const cli_available = await check_claude_cli();
|
|
397
|
-
if (!cli_available) {
|
|
398
|
-
return {
|
|
399
|
-
success: false,
|
|
400
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
try {
|
|
404
|
-
const { stdout } = await execAsync(`claude mcp get ${shell_escape(name)}`);
|
|
405
|
-
return { success: true, stdout: stdout.trim() };
|
|
406
|
-
}
|
|
407
|
-
catch (error) {
|
|
408
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
409
|
-
return {
|
|
410
|
-
success: false,
|
|
411
|
-
error: `Failed to get server details: ${message}`,
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Add an MCP server from raw JSON via Claude CLI
|
|
417
|
-
*/
|
|
418
|
-
export async function mcp_add_json_via_cli(name, json, scope = 'local') {
|
|
419
|
-
const cli_available = await check_claude_cli();
|
|
420
|
-
if (!cli_available) {
|
|
421
|
-
return {
|
|
422
|
-
success: false,
|
|
423
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
try {
|
|
427
|
-
await execAsync(`claude mcp add-json ${shell_escape(name)} ${shell_escape(json)} --scope ${scope}`);
|
|
428
|
-
return { success: true };
|
|
429
|
-
}
|
|
430
|
-
catch (error) {
|
|
431
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
432
|
-
return {
|
|
433
|
-
success: false,
|
|
434
|
-
error: `Failed to add server from JSON: ${message}`,
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Reset project-scoped MCP server choices via Claude CLI
|
|
440
|
-
*/
|
|
441
|
-
export async function mcp_reset_project_choices_via_cli() {
|
|
442
|
-
const cli_available = await check_claude_cli();
|
|
443
|
-
if (!cli_available) {
|
|
444
|
-
return {
|
|
445
|
-
success: false,
|
|
446
|
-
error: 'Claude CLI not found. Please install Claude Code CLI.',
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
try {
|
|
450
|
-
await execAsync('claude mcp reset-project-choices');
|
|
451
|
-
return { success: true };
|
|
452
|
-
}
|
|
453
|
-
catch (error) {
|
|
454
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
455
|
-
return {
|
|
456
|
-
success: false,
|
|
457
|
-
error: `Failed to reset project choices: ${message}`,
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Get scope options for select prompt
|
|
463
|
-
*/
|
|
464
|
-
export function get_scope_options() {
|
|
465
|
-
return [
|
|
466
|
-
{
|
|
467
|
-
value: 'local',
|
|
468
|
-
label: 'Local',
|
|
469
|
-
hint: 'This project only (default)',
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
value: 'project',
|
|
473
|
-
label: 'Project',
|
|
474
|
-
hint: 'Shared via .mcp.json (git)',
|
|
475
|
-
},
|
|
476
|
-
{
|
|
477
|
-
value: 'user',
|
|
478
|
-
label: 'User (Global)',
|
|
479
|
-
hint: 'Available in all projects',
|
|
480
|
-
},
|
|
481
|
-
];
|
|
482
|
-
}
|
|
483
|
-
//# sourceMappingURL=claude-cli.js.map
|
package/dist/utils/paths.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { access, mkdir } from 'node:fs/promises';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
|
-
import { dirname, join } from 'node:path';
|
|
5
|
-
export function get_base_dir() {
|
|
6
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR;
|
|
7
|
-
if (configDir && configDir.length > 0 && existsSync(configDir)) {
|
|
8
|
-
return {
|
|
9
|
-
baseDir: configDir,
|
|
10
|
-
parentDir: dirname(configDir),
|
|
11
|
-
coLocatedConfig: true,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const defaultDir = join(homedir(), '.claude');
|
|
15
|
-
return {
|
|
16
|
-
baseDir: defaultDir,
|
|
17
|
-
parentDir: dirname(defaultDir),
|
|
18
|
-
coLocatedConfig: false,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export function get_claude_config_path() {
|
|
22
|
-
const { baseDir, parentDir, coLocatedConfig } = get_base_dir();
|
|
23
|
-
if (coLocatedConfig) {
|
|
24
|
-
return join(baseDir, '.claude.json');
|
|
25
|
-
}
|
|
26
|
-
return join(parentDir, '.claude.json');
|
|
27
|
-
}
|
|
28
|
-
export function get_claude_settings_path() {
|
|
29
|
-
return join(get_base_dir().baseDir, 'settings.json');
|
|
30
|
-
}
|
|
31
|
-
export function get_mcpick_dir() {
|
|
32
|
-
return join(get_base_dir().baseDir, 'mcpick');
|
|
33
|
-
}
|
|
34
|
-
export function get_dev_overrides_path() {
|
|
35
|
-
return join(get_mcpick_dir(), 'dev-overrides.json');
|
|
36
|
-
}
|
|
37
|
-
export function get_server_registry_path() {
|
|
38
|
-
return join(get_mcpick_dir(), 'servers.json');
|
|
39
|
-
}
|
|
40
|
-
export function get_backups_dir() {
|
|
41
|
-
return join(get_mcpick_dir(), 'backups');
|
|
42
|
-
}
|
|
43
|
-
export function get_profiles_dir() {
|
|
44
|
-
return join(get_mcpick_dir(), 'profiles');
|
|
45
|
-
}
|
|
46
|
-
export function get_profile_path(name) {
|
|
47
|
-
// Allow .json extension or add it
|
|
48
|
-
const filename = name.endsWith('.json') ? name : `${name}.json`;
|
|
49
|
-
return join(get_profiles_dir(), filename);
|
|
50
|
-
}
|
|
51
|
-
function format_backup_timestamp() {
|
|
52
|
-
const now = new Date();
|
|
53
|
-
const year = now.getFullYear();
|
|
54
|
-
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
55
|
-
const day = String(now.getDate()).padStart(2, '0');
|
|
56
|
-
const hour = String(now.getHours()).padStart(2, '0');
|
|
57
|
-
const minute = String(now.getMinutes()).padStart(2, '0');
|
|
58
|
-
const second = String(now.getSeconds()).padStart(2, '0');
|
|
59
|
-
return `${year}-${month}-${day}-${hour}${minute}${second}`;
|
|
60
|
-
}
|
|
61
|
-
export function get_backup_filename() {
|
|
62
|
-
return `mcp-servers-${format_backup_timestamp()}.json`;
|
|
63
|
-
}
|
|
64
|
-
export function get_plugin_backup_filename() {
|
|
65
|
-
return `plugins-${format_backup_timestamp()}.json`;
|
|
66
|
-
}
|
|
67
|
-
export async function ensure_directory_exists(dir_path) {
|
|
68
|
-
try {
|
|
69
|
-
await access(dir_path);
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
await mkdir(dir_path, { recursive: true });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get the current working directory (project path)
|
|
77
|
-
*/
|
|
78
|
-
export function get_current_project_path() {
|
|
79
|
-
return process.cwd();
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Get the path to .mcp.json in the current project directory (project scope)
|
|
83
|
-
*/
|
|
84
|
-
export function get_project_mcp_json_path() {
|
|
85
|
-
return join(get_current_project_path(), '.mcp.json');
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Get the path to the global .mcp.json in home directory (user scope)
|
|
89
|
-
*/
|
|
90
|
-
export function get_global_mcp_json_path() {
|
|
91
|
-
return join(homedir(), '.mcp.json');
|
|
92
|
-
}
|
|
93
|
-
export function get_plugins_dir() {
|
|
94
|
-
return join(get_base_dir().baseDir, 'plugins');
|
|
95
|
-
}
|
|
96
|
-
export function get_installed_plugins_path() {
|
|
97
|
-
return join(get_plugins_dir(), 'installed_plugins.json');
|
|
98
|
-
}
|
|
99
|
-
export function get_known_marketplaces_path() {
|
|
100
|
-
return join(get_plugins_dir(), 'known_marketplaces.json');
|
|
101
|
-
}
|
|
102
|
-
export function get_plugin_cache_dir() {
|
|
103
|
-
return join(get_plugins_dir(), 'cache');
|
|
104
|
-
}
|
|
105
|
-
export function get_marketplaces_dir() {
|
|
106
|
-
return join(get_plugins_dir(), 'marketplaces');
|
|
107
|
-
}
|
|
108
|
-
export function get_disabled_hooks_path() {
|
|
109
|
-
return join(get_mcpick_dir(), 'disabled-hooks.json');
|
|
110
|
-
}
|
|
111
|
-
export function get_marketplace_manifest_path(name) {
|
|
112
|
-
return join(get_marketplaces_dir(), name, '.claude-plugin', 'marketplace.json');
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=paths.js.map
|