mcpick 0.0.8 → 0.0.10
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/CHANGELOG.md +16 -0
- package/dist/cli/commands/add.js +135 -0
- package/dist/cli/commands/backup.js +55 -0
- package/dist/cli/commands/cache.js +181 -0
- package/dist/cli/commands/disable.js +33 -0
- package/dist/cli/commands/enable.js +39 -0
- package/dist/cli/commands/list.js +63 -0
- package/dist/cli/commands/plugins.js +93 -0
- package/dist/cli/commands/profile.js +112 -0
- package/dist/cli/commands/remove.js +31 -0
- package/dist/cli/commands/restore.js +56 -0
- package/dist/cli/index.js +21 -0
- package/dist/cli/output.js +21 -0
- package/dist/commands/edit-plugins.js +56 -0
- package/dist/commands/manage-cache.js +155 -0
- package/dist/core/plugin-cache.js +259 -0
- package/dist/core/settings.js +59 -0
- package/dist/index.js +42 -4
- package/dist/utils/paths.js +21 -0
- package/package.json +8 -7
- package/dist/commands/launch.js +0 -21
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import { write_claude_config } from '../../core/config.js';
|
|
3
|
+
import { list_profiles, load_profile, save_profile, } from '../../core/profile.js';
|
|
4
|
+
import { error, output } from '../output.js';
|
|
5
|
+
const list = defineCommand({
|
|
6
|
+
meta: {
|
|
7
|
+
name: 'list',
|
|
8
|
+
description: 'List all saved profiles',
|
|
9
|
+
},
|
|
10
|
+
args: {
|
|
11
|
+
json: {
|
|
12
|
+
type: 'boolean',
|
|
13
|
+
description: 'Output as JSON',
|
|
14
|
+
default: false,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
async run({ args }) {
|
|
18
|
+
const profiles = await list_profiles();
|
|
19
|
+
if (args.json) {
|
|
20
|
+
output(profiles, true);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
if (profiles.length === 0) {
|
|
24
|
+
console.log('No profiles found.');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
for (const p of profiles) {
|
|
28
|
+
console.log(`${p.name} (${p.serverCount} servers)`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const load = defineCommand({
|
|
34
|
+
meta: {
|
|
35
|
+
name: 'load',
|
|
36
|
+
description: 'Load and apply a saved profile',
|
|
37
|
+
},
|
|
38
|
+
args: {
|
|
39
|
+
name: {
|
|
40
|
+
type: 'positional',
|
|
41
|
+
description: 'Profile name',
|
|
42
|
+
required: true,
|
|
43
|
+
},
|
|
44
|
+
json: {
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
description: 'Output as JSON',
|
|
47
|
+
default: false,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
async run({ args }) {
|
|
51
|
+
try {
|
|
52
|
+
const config = await load_profile(args.name);
|
|
53
|
+
await write_claude_config(config);
|
|
54
|
+
const server_count = Object.keys(config.mcpServers || {}).length;
|
|
55
|
+
if (args.json) {
|
|
56
|
+
output({
|
|
57
|
+
profile: args.name,
|
|
58
|
+
servers: server_count,
|
|
59
|
+
}, true);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
console.log(`Profile '${args.name}' applied (${server_count} servers)`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
error(err instanceof Error ? err.message : 'Failed to load profile');
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
const save = defineCommand({
|
|
71
|
+
meta: {
|
|
72
|
+
name: 'save',
|
|
73
|
+
description: 'Save current config as a profile',
|
|
74
|
+
},
|
|
75
|
+
args: {
|
|
76
|
+
name: {
|
|
77
|
+
type: 'positional',
|
|
78
|
+
description: 'Profile name',
|
|
79
|
+
required: true,
|
|
80
|
+
},
|
|
81
|
+
json: {
|
|
82
|
+
type: 'boolean',
|
|
83
|
+
description: 'Output as JSON',
|
|
84
|
+
default: false,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
async run({ args }) {
|
|
88
|
+
try {
|
|
89
|
+
const server_count = await save_profile(args.name);
|
|
90
|
+
if (args.json) {
|
|
91
|
+
output({
|
|
92
|
+
profile: args.name,
|
|
93
|
+
servers: server_count,
|
|
94
|
+
}, true);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
console.log(`Profile '${args.name}' saved (${server_count} servers)`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
error(err instanceof Error ? err.message : 'Failed to save profile');
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
export default defineCommand({
|
|
106
|
+
meta: {
|
|
107
|
+
name: 'profile',
|
|
108
|
+
description: 'Manage MCP server profiles',
|
|
109
|
+
},
|
|
110
|
+
subCommands: { list, load, save },
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import { read_server_registry, write_server_registry, } from '../../core/registry.js';
|
|
3
|
+
import { remove_mcp_via_cli } from '../../utils/claude-cli.js';
|
|
4
|
+
import { error } from '../output.js';
|
|
5
|
+
export default defineCommand({
|
|
6
|
+
meta: {
|
|
7
|
+
name: 'remove',
|
|
8
|
+
description: 'Remove an MCP server from the registry and disable it',
|
|
9
|
+
},
|
|
10
|
+
args: {
|
|
11
|
+
server: {
|
|
12
|
+
type: 'positional',
|
|
13
|
+
description: 'Server name to remove',
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
async run({ args }) {
|
|
18
|
+
const registry = await read_server_registry();
|
|
19
|
+
const index = registry.servers.findIndex((s) => s.name === args.server);
|
|
20
|
+
if (index < 0) {
|
|
21
|
+
error(`Server '${args.server}' not found in registry. Run 'mcpick list' to see available servers.`);
|
|
22
|
+
}
|
|
23
|
+
// Remove from registry
|
|
24
|
+
registry.servers.splice(index, 1);
|
|
25
|
+
await write_server_registry(registry);
|
|
26
|
+
// Also disable via CLI (best effort)
|
|
27
|
+
await remove_mcp_via_cli(args.server);
|
|
28
|
+
console.log(`Removed '${args.server}' from registry`);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=remove.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { write_claude_config } from '../../core/config.js';
|
|
4
|
+
import { list_backups } from '../../core/registry.js';
|
|
5
|
+
import { validate_claude_config } from '../../core/validation.js';
|
|
6
|
+
import { error, output } from '../output.js';
|
|
7
|
+
export default defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name: 'restore',
|
|
10
|
+
description: 'Restore MCP server config from a backup (latest if no file specified)',
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
file: {
|
|
14
|
+
type: 'positional',
|
|
15
|
+
description: 'Backup filename or path (optional, defaults to latest)',
|
|
16
|
+
required: false,
|
|
17
|
+
},
|
|
18
|
+
json: {
|
|
19
|
+
type: 'boolean',
|
|
20
|
+
description: 'Output as JSON',
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run({ args }) {
|
|
25
|
+
const backups = await list_backups();
|
|
26
|
+
if (backups.length === 0) {
|
|
27
|
+
error('No backups found. Run "mcpick backup" first.');
|
|
28
|
+
}
|
|
29
|
+
let backup_path;
|
|
30
|
+
if (args.file) {
|
|
31
|
+
const found = backups.find((b) => b.filename === args.file || b.path === args.file);
|
|
32
|
+
if (!found) {
|
|
33
|
+
error(`Backup '${args.file}' not found. Available: ${backups.map((b) => b.filename).join(', ')}`);
|
|
34
|
+
}
|
|
35
|
+
backup_path = found.path;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
backup_path = backups[0].path;
|
|
39
|
+
}
|
|
40
|
+
const content = await readFile(backup_path, 'utf-8');
|
|
41
|
+
const parsed = JSON.parse(content);
|
|
42
|
+
const config = validate_claude_config(parsed);
|
|
43
|
+
await write_claude_config(config);
|
|
44
|
+
const server_count = Object.keys(config.mcpServers || {}).length;
|
|
45
|
+
if (args.json) {
|
|
46
|
+
output({
|
|
47
|
+
restored: backup_path,
|
|
48
|
+
servers: server_count,
|
|
49
|
+
}, true);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log(`Restored from ${backup_path} (${server_count} servers)`);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=restore.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineCommand, runMain } from 'citty';
|
|
2
|
+
const main = defineCommand({
|
|
3
|
+
meta: {
|
|
4
|
+
name: 'mcpick',
|
|
5
|
+
description: 'MCP Server Configuration Manager',
|
|
6
|
+
},
|
|
7
|
+
subCommands: {
|
|
8
|
+
list: () => import('./commands/list.js').then((m) => m.default),
|
|
9
|
+
enable: () => import('./commands/enable.js').then((m) => m.default),
|
|
10
|
+
disable: () => import('./commands/disable.js').then((m) => m.default),
|
|
11
|
+
remove: () => import('./commands/remove.js').then((m) => m.default),
|
|
12
|
+
add: () => import('./commands/add.js').then((m) => m.default),
|
|
13
|
+
backup: () => import('./commands/backup.js').then((m) => m.default),
|
|
14
|
+
restore: () => import('./commands/restore.js').then((m) => m.default),
|
|
15
|
+
profile: () => import('./commands/profile.js').then((m) => m.default),
|
|
16
|
+
plugins: () => import('./commands/plugins.js').then((m) => m.default),
|
|
17
|
+
cache: () => import('./commands/cache.js').then((m) => m.default),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
export const run = () => runMain(main);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function output(data, json) {
|
|
2
|
+
if (json) {
|
|
3
|
+
console.log(JSON.stringify(data, null, 2));
|
|
4
|
+
}
|
|
5
|
+
else if (typeof data === 'string') {
|
|
6
|
+
console.log(data);
|
|
7
|
+
}
|
|
8
|
+
else if (Array.isArray(data)) {
|
|
9
|
+
for (const item of data) {
|
|
10
|
+
console.log(item);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
console.log(data);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function error(message) {
|
|
18
|
+
console.error(`error: ${message}`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { log, multiselect, note } from '@clack/prompts';
|
|
2
|
+
import { build_enabled_plugins, get_all_plugins, read_claude_settings, write_claude_settings, } from '../core/settings.js';
|
|
3
|
+
export async function edit_plugins() {
|
|
4
|
+
try {
|
|
5
|
+
const settings = await read_claude_settings();
|
|
6
|
+
const plugins = get_all_plugins(settings);
|
|
7
|
+
if (plugins.length === 0) {
|
|
8
|
+
note('No plugins found in ~/.claude/settings.json.\n' +
|
|
9
|
+
'Install plugins via Claude Code: /plugin');
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const plugin_choices = plugins.map((plugin) => ({
|
|
13
|
+
value: `${plugin.name}@${plugin.marketplace}`,
|
|
14
|
+
label: plugin.name,
|
|
15
|
+
hint: plugin.marketplace,
|
|
16
|
+
}));
|
|
17
|
+
const currently_enabled = plugins
|
|
18
|
+
.filter((p) => p.enabled)
|
|
19
|
+
.map((p) => `${p.name}@${p.marketplace}`);
|
|
20
|
+
const selected = await multiselect({
|
|
21
|
+
message: 'Select plugins to enable:',
|
|
22
|
+
options: plugin_choices,
|
|
23
|
+
initialValues: currently_enabled,
|
|
24
|
+
required: false,
|
|
25
|
+
});
|
|
26
|
+
if (typeof selected === 'symbol') {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const selected_set = new Set(selected);
|
|
30
|
+
const updated_plugins = plugins.map((plugin) => ({
|
|
31
|
+
...plugin,
|
|
32
|
+
enabled: selected_set.has(`${plugin.name}@${plugin.marketplace}`),
|
|
33
|
+
}));
|
|
34
|
+
const enabled_plugins = build_enabled_plugins(updated_plugins);
|
|
35
|
+
await write_claude_settings({ enabledPlugins: enabled_plugins });
|
|
36
|
+
const enabled_count = updated_plugins.filter((p) => p.enabled).length;
|
|
37
|
+
const disabled_count = updated_plugins.filter((p) => !p.enabled).length;
|
|
38
|
+
note(`Plugins updated!\n` +
|
|
39
|
+
`Enabled: ${enabled_count}, Disabled: ${disabled_count}`);
|
|
40
|
+
// Show what changed
|
|
41
|
+
const newly_enabled = updated_plugins.filter((p) => p.enabled &&
|
|
42
|
+
!currently_enabled.includes(`${p.name}@${p.marketplace}`));
|
|
43
|
+
const newly_disabled = updated_plugins.filter((p) => !p.enabled &&
|
|
44
|
+
currently_enabled.includes(`${p.name}@${p.marketplace}`));
|
|
45
|
+
if (newly_enabled.length > 0) {
|
|
46
|
+
log.success(`Enabled: ${newly_enabled.map((p) => p.name).join(', ')}`);
|
|
47
|
+
}
|
|
48
|
+
if (newly_disabled.length > 0) {
|
|
49
|
+
log.warn(`Disabled: ${newly_disabled.map((p) => p.name).join(', ')}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error(`Failed to edit plugins: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=edit-plugins.js.map
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { confirm, isCancel, log, multiselect, note, select, } from '@clack/prompts';
|
|
2
|
+
import { clean_orphaned_versions, clear_plugin_caches, get_cached_plugins_info, refresh_all_marketplaces, } from '../core/plugin-cache.js';
|
|
3
|
+
function format_status_line(p) {
|
|
4
|
+
const markers = [];
|
|
5
|
+
if (p.isVersionStale) {
|
|
6
|
+
markers.push(`version: ${p.installedVersion} → ${p.latestVersion}`);
|
|
7
|
+
}
|
|
8
|
+
if (p.isShaStale) {
|
|
9
|
+
markers.push('commits behind');
|
|
10
|
+
}
|
|
11
|
+
if (p.orphanedVersions.length > 0) {
|
|
12
|
+
markers.push(`${p.orphanedVersions.length} orphaned`);
|
|
13
|
+
}
|
|
14
|
+
const status = markers.length > 0
|
|
15
|
+
? `[stale: ${markers.join(', ')}]`
|
|
16
|
+
: '[up to date]';
|
|
17
|
+
return `${p.name}@${p.marketplace} v${p.installedVersion} ${status}`;
|
|
18
|
+
}
|
|
19
|
+
async function handle_status() {
|
|
20
|
+
const plugins = await get_cached_plugins_info();
|
|
21
|
+
if (plugins.length === 0) {
|
|
22
|
+
log.info('No cached plugins found.');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const lines = plugins.map(format_status_line).join('\n');
|
|
26
|
+
note(lines, 'Plugin Cache Status');
|
|
27
|
+
}
|
|
28
|
+
async function handle_clear() {
|
|
29
|
+
const plugins = await get_cached_plugins_info();
|
|
30
|
+
if (plugins.length === 0) {
|
|
31
|
+
log.info('No cached plugins to clear.');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const selected = await multiselect({
|
|
35
|
+
message: 'Select plugins to clear cache for:',
|
|
36
|
+
options: plugins.map((p) => {
|
|
37
|
+
const stale = p.isVersionStale || p.isShaStale;
|
|
38
|
+
return {
|
|
39
|
+
value: p.key,
|
|
40
|
+
label: `${p.name}@${p.marketplace}`,
|
|
41
|
+
hint: stale
|
|
42
|
+
? `v${p.installedVersion} → ${p.latestVersion ?? 'unknown'} (stale)`
|
|
43
|
+
: `v${p.installedVersion}`,
|
|
44
|
+
};
|
|
45
|
+
}),
|
|
46
|
+
initialValues: plugins
|
|
47
|
+
.filter((p) => p.isVersionStale || p.isShaStale)
|
|
48
|
+
.map((p) => p.key),
|
|
49
|
+
});
|
|
50
|
+
if (isCancel(selected) || selected.length === 0)
|
|
51
|
+
return;
|
|
52
|
+
const should_clear = await confirm({
|
|
53
|
+
message: `Clear cache for ${selected.length} plugin(s)? This will also refresh the marketplace.`,
|
|
54
|
+
});
|
|
55
|
+
if (isCancel(should_clear) || !should_clear)
|
|
56
|
+
return;
|
|
57
|
+
const result = await clear_plugin_caches(selected);
|
|
58
|
+
for (const key of result.cleared) {
|
|
59
|
+
log.success(`Cleared: ${key}`);
|
|
60
|
+
}
|
|
61
|
+
for (const err of result.errors) {
|
|
62
|
+
log.error(`Error: ${err}`);
|
|
63
|
+
}
|
|
64
|
+
if (result.cleared.length > 0) {
|
|
65
|
+
note('Run /reload-plugins in Claude Code or restart your session to apply changes.', 'Next Steps');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function handle_clean_orphaned() {
|
|
69
|
+
const should_clean = await confirm({
|
|
70
|
+
message: 'Remove all orphaned plugin version directories?',
|
|
71
|
+
});
|
|
72
|
+
if (isCancel(should_clean) || !should_clean)
|
|
73
|
+
return;
|
|
74
|
+
const result = await clean_orphaned_versions();
|
|
75
|
+
if (result.cleaned === 0) {
|
|
76
|
+
log.info('No orphaned versions found.');
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
for (const p of result.paths) {
|
|
80
|
+
log.success(`Removed: ${p}`);
|
|
81
|
+
}
|
|
82
|
+
log.info(`Cleaned ${result.cleaned} orphaned version(s).`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function handle_refresh() {
|
|
86
|
+
const should_refresh = await confirm({
|
|
87
|
+
message: 'Refresh all marketplace clones (git pull)?',
|
|
88
|
+
});
|
|
89
|
+
if (isCancel(should_refresh) || !should_refresh)
|
|
90
|
+
return;
|
|
91
|
+
const results = await refresh_all_marketplaces();
|
|
92
|
+
if (results.size === 0) {
|
|
93
|
+
log.info('No marketplaces configured.');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
for (const [name, result] of results) {
|
|
97
|
+
if (result.success) {
|
|
98
|
+
log.success(`${name}: refreshed`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
log.error(`${name}: ${result.error}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export async function manage_cache() {
|
|
106
|
+
while (true) {
|
|
107
|
+
const action = await select({
|
|
108
|
+
message: 'Plugin cache management:',
|
|
109
|
+
options: [
|
|
110
|
+
{
|
|
111
|
+
value: 'status',
|
|
112
|
+
label: 'View cache status',
|
|
113
|
+
hint: 'Show plugins with staleness info',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
value: 'clear',
|
|
117
|
+
label: 'Clear plugin caches',
|
|
118
|
+
hint: 'Refresh marketplace + clear selected caches',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
value: 'clean-orphaned',
|
|
122
|
+
label: 'Clean orphaned versions',
|
|
123
|
+
hint: 'Remove old version directories',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
value: 'refresh',
|
|
127
|
+
label: 'Refresh marketplaces',
|
|
128
|
+
hint: 'Git pull all marketplace clones',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
value: 'back',
|
|
132
|
+
label: 'Back',
|
|
133
|
+
hint: 'Return to main menu',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
});
|
|
137
|
+
if (isCancel(action) || action === 'back')
|
|
138
|
+
return;
|
|
139
|
+
switch (action) {
|
|
140
|
+
case 'status':
|
|
141
|
+
await handle_status();
|
|
142
|
+
break;
|
|
143
|
+
case 'clear':
|
|
144
|
+
await handle_clear();
|
|
145
|
+
break;
|
|
146
|
+
case 'clean-orphaned':
|
|
147
|
+
await handle_clean_orphaned();
|
|
148
|
+
break;
|
|
149
|
+
case 'refresh':
|
|
150
|
+
await handle_refresh();
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=manage-cache.js.map
|