multiagents 0.1.0 → 0.1.1
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/cli/commands.ts +8 -1
- package/cli/install-mcp.ts +130 -0
- package/package.json +1 -1
- package/scripts/postinstall.ts +41 -20
package/cli/commands.ts
CHANGED
|
@@ -13,7 +13,8 @@ function printUsage(): void {
|
|
|
13
13
|
console.log(`multiagents CLI
|
|
14
14
|
|
|
15
15
|
Usage:
|
|
16
|
-
multiagents
|
|
16
|
+
multiagents install-mcp Configure MCP servers for Claude Code
|
|
17
|
+
multiagents setup Interactive setup wizard
|
|
17
18
|
multiagents dashboard [session-id] TUI dashboard
|
|
18
19
|
multiagents session create <name> Create a new session
|
|
19
20
|
multiagents session list List all sessions
|
|
@@ -35,6 +36,12 @@ export async function runCli(args: string[]): Promise<void> {
|
|
|
35
36
|
const command = args[0];
|
|
36
37
|
|
|
37
38
|
switch (command) {
|
|
39
|
+
case "install-mcp": {
|
|
40
|
+
const { installMcp } = await import("./install-mcp.ts");
|
|
41
|
+
await installMcp();
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
case "setup": {
|
|
39
46
|
const { setup } = await import("./setup.ts");
|
|
40
47
|
await setup();
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* multiagents install-mcp — Configure MCP servers for Claude Code.
|
|
4
|
+
*
|
|
5
|
+
* 1. Writes multiagents + multiagents-orch to ~/.claude/.mcp.json
|
|
6
|
+
* 2. Adds them to enabledMcpjsonServers in ~/.claude/settings.json
|
|
7
|
+
* 3. Prints instructions to restart Claude Code
|
|
8
|
+
*
|
|
9
|
+
* Uses the installed binary names (multiagents-server, multiagents-orch)
|
|
10
|
+
* so it works regardless of where the package is installed.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as fs from "node:fs";
|
|
14
|
+
import * as path from "node:path";
|
|
15
|
+
import * as os from "node:os";
|
|
16
|
+
|
|
17
|
+
const HOME = os.homedir();
|
|
18
|
+
const CLAUDE_DIR = path.join(HOME, ".claude");
|
|
19
|
+
const MCP_JSON = path.join(CLAUDE_DIR, ".mcp.json");
|
|
20
|
+
const SETTINGS_JSON = path.join(CLAUDE_DIR, "settings.json");
|
|
21
|
+
|
|
22
|
+
function findBinary(name: string): string {
|
|
23
|
+
const which = Bun.spawnSync(["which", name]);
|
|
24
|
+
const found = new TextDecoder().decode(which.stdout).trim();
|
|
25
|
+
if (found) return found;
|
|
26
|
+
|
|
27
|
+
// Fallback to common locations
|
|
28
|
+
const candidates = [
|
|
29
|
+
path.join(HOME, ".bun", "bin", name),
|
|
30
|
+
`/usr/local/bin/${name}`,
|
|
31
|
+
`/opt/homebrew/bin/${name}`,
|
|
32
|
+
];
|
|
33
|
+
for (const c of candidates) {
|
|
34
|
+
if (fs.existsSync(c)) return c;
|
|
35
|
+
}
|
|
36
|
+
return name; // hope it's in PATH at runtime
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function installMcp(): Promise<void> {
|
|
40
|
+
console.log("\n\x1b[1m\x1b[36m multiagents install-mcp\x1b[0m");
|
|
41
|
+
console.log("\x1b[90m Configure MCP servers for Claude Code\x1b[0m\n");
|
|
42
|
+
|
|
43
|
+
const serverBin = findBinary("multiagents-server");
|
|
44
|
+
const orchBin = findBinary("multiagents-orch");
|
|
45
|
+
|
|
46
|
+
console.log(` Server binary: ${serverBin}`);
|
|
47
|
+
console.log(` Orchestrator binary: ${orchBin}\n`);
|
|
48
|
+
|
|
49
|
+
// --- Step 1: Write ~/.claude/.mcp.json ---
|
|
50
|
+
if (!fs.existsSync(CLAUDE_DIR)) {
|
|
51
|
+
fs.mkdirSync(CLAUDE_DIR, { recursive: true });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let mcpConfig: { mcpServers: Record<string, unknown> } = { mcpServers: {} };
|
|
55
|
+
if (fs.existsSync(MCP_JSON)) {
|
|
56
|
+
try {
|
|
57
|
+
mcpConfig = JSON.parse(fs.readFileSync(MCP_JSON, "utf-8"));
|
|
58
|
+
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
59
|
+
} catch {
|
|
60
|
+
fs.copyFileSync(MCP_JSON, MCP_JSON + ".bak");
|
|
61
|
+
mcpConfig = { mcpServers: {} };
|
|
62
|
+
console.log(" \x1b[33m!\x1b[0m Existing .mcp.json was corrupted — backed up and recreated");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
mcpConfig.mcpServers["multiagents"] = {
|
|
67
|
+
command: serverBin,
|
|
68
|
+
args: [],
|
|
69
|
+
};
|
|
70
|
+
mcpConfig.mcpServers["multiagents-orch"] = {
|
|
71
|
+
command: orchBin,
|
|
72
|
+
args: [],
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
fs.writeFileSync(MCP_JSON, JSON.stringify(mcpConfig, null, 2) + "\n");
|
|
76
|
+
console.log(" \x1b[32m✔\x1b[0m Wrote ~/.claude/.mcp.json");
|
|
77
|
+
|
|
78
|
+
// --- Step 2: Enable in ~/.claude/settings.json ---
|
|
79
|
+
let settings: Record<string, unknown> = {};
|
|
80
|
+
if (fs.existsSync(SETTINGS_JSON)) {
|
|
81
|
+
try {
|
|
82
|
+
settings = JSON.parse(fs.readFileSync(SETTINGS_JSON, "utf-8"));
|
|
83
|
+
} catch {
|
|
84
|
+
console.log(" \x1b[33m!\x1b[0m Could not parse settings.json — skipping auto-enable");
|
|
85
|
+
printDone();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Ensure enabledMcpjsonServers includes our servers
|
|
91
|
+
let enabled = (settings.enabledMcpjsonServers as string[]) ?? [];
|
|
92
|
+
let changed = false;
|
|
93
|
+
if (!enabled.includes("multiagents")) {
|
|
94
|
+
enabled.push("multiagents");
|
|
95
|
+
changed = true;
|
|
96
|
+
}
|
|
97
|
+
if (!enabled.includes("multiagents-orch")) {
|
|
98
|
+
enabled.push("multiagents-orch");
|
|
99
|
+
changed = true;
|
|
100
|
+
}
|
|
101
|
+
if (changed) {
|
|
102
|
+
settings.enabledMcpjsonServers = enabled;
|
|
103
|
+
fs.writeFileSync(SETTINGS_JSON, JSON.stringify(settings, null, 2) + "\n");
|
|
104
|
+
console.log(" \x1b[32m✔\x1b[0m Enabled in ~/.claude/settings.json");
|
|
105
|
+
} else {
|
|
106
|
+
console.log(" \x1b[32m✔\x1b[0m Already enabled in settings.json");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
printDone();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function printDone(): void {
|
|
113
|
+
console.log(`
|
|
114
|
+
\x1b[1m\x1b[32mDone!\x1b[0m MCP servers configured.
|
|
115
|
+
|
|
116
|
+
\x1b[1mNext step:\x1b[0m Restart Claude Code to load the new tools.
|
|
117
|
+
Exit Claude Code and run: \x1b[90mclaude\x1b[0m
|
|
118
|
+
|
|
119
|
+
\x1b[1mManual setup:\x1b[0m If auto-config doesn't work, add to ~/.claude/.mcp.json:
|
|
120
|
+
\x1b[90m {
|
|
121
|
+
"mcpServers": {
|
|
122
|
+
"multiagents": { "command": "multiagents-server", "args": [] },
|
|
123
|
+
"multiagents-orch": { "command": "multiagents-orch", "args": [] }
|
|
124
|
+
}
|
|
125
|
+
}\x1b[0m
|
|
126
|
+
|
|
127
|
+
And add to ~/.claude/settings.json:
|
|
128
|
+
\x1b[90m "enabledMcpjsonServers": ["multiagents", "multiagents-orch"]\x1b[0m
|
|
129
|
+
`);
|
|
130
|
+
}
|
package/package.json
CHANGED
package/scripts/postinstall.ts
CHANGED
|
@@ -16,21 +16,20 @@ const HOME = os.homedir();
|
|
|
16
16
|
const CLAUDE_DIR = path.join(HOME, ".claude");
|
|
17
17
|
const MCP_JSON = path.join(CLAUDE_DIR, ".mcp.json");
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
if (fs.existsSync(defaultBun)) return defaultBun;
|
|
30
|
-
return "bun"; // fallback — hope it's in PATH at runtime
|
|
19
|
+
// Use installed binary names — works regardless of install location
|
|
20
|
+
function findBinary(name: string): string {
|
|
21
|
+
try {
|
|
22
|
+
const which = Bun.spawnSync(["which", name]);
|
|
23
|
+
const found = new TextDecoder().decode(which.stdout).trim();
|
|
24
|
+
if (found) return found;
|
|
25
|
+
} catch { /* ok */ }
|
|
26
|
+
const defaultPath = path.join(HOME, ".bun", "bin", name);
|
|
27
|
+
if (fs.existsSync(defaultPath)) return defaultPath;
|
|
28
|
+
return name; // fallback
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
const
|
|
31
|
+
const SERVER_BIN = findBinary("multiagents-server");
|
|
32
|
+
const ORCH_BIN = findBinary("multiagents-orch");
|
|
34
33
|
|
|
35
34
|
try {
|
|
36
35
|
// Ensure ~/.claude/ exists
|
|
@@ -53,11 +52,11 @@ try {
|
|
|
53
52
|
|
|
54
53
|
let changed = false;
|
|
55
54
|
|
|
56
|
-
// Add multiagents MCP server
|
|
55
|
+
// Add multiagents MCP server (using installed binary names)
|
|
57
56
|
if (!config.mcpServers["multiagents"]) {
|
|
58
57
|
config.mcpServers["multiagents"] = {
|
|
59
|
-
command:
|
|
60
|
-
args: [
|
|
58
|
+
command: SERVER_BIN,
|
|
59
|
+
args: [],
|
|
61
60
|
};
|
|
62
61
|
changed = true;
|
|
63
62
|
}
|
|
@@ -65,8 +64,8 @@ try {
|
|
|
65
64
|
// Add orchestrator MCP server
|
|
66
65
|
if (!config.mcpServers["multiagents-orch"]) {
|
|
67
66
|
config.mcpServers["multiagents-orch"] = {
|
|
68
|
-
command:
|
|
69
|
-
args: [
|
|
67
|
+
command: ORCH_BIN,
|
|
68
|
+
args: [],
|
|
70
69
|
};
|
|
71
70
|
changed = true;
|
|
72
71
|
}
|
|
@@ -74,11 +73,33 @@ try {
|
|
|
74
73
|
if (changed) {
|
|
75
74
|
fs.writeFileSync(MCP_JSON, JSON.stringify(config, null, 2) + "\n");
|
|
76
75
|
console.log("[multiagents] MCP servers configured in ~/.claude/.mcp.json");
|
|
77
|
-
console.log(" Restart Claude Code to pick up the new tools.");
|
|
78
76
|
} else {
|
|
79
|
-
console.log("[multiagents] MCP servers already configured.");
|
|
77
|
+
console.log("[multiagents] MCP servers already configured in .mcp.json");
|
|
80
78
|
}
|
|
79
|
+
|
|
80
|
+
// Also enable in settings.json
|
|
81
|
+
const SETTINGS_JSON = path.join(CLAUDE_DIR, "settings.json");
|
|
82
|
+
if (fs.existsSync(SETTINGS_JSON)) {
|
|
83
|
+
try {
|
|
84
|
+
const settings = JSON.parse(fs.readFileSync(SETTINGS_JSON, "utf-8"));
|
|
85
|
+
const enabled: string[] = settings.enabledMcpjsonServers ?? [];
|
|
86
|
+
let settingsChanged = false;
|
|
87
|
+
if (!enabled.includes("multiagents")) { enabled.push("multiagents"); settingsChanged = true; }
|
|
88
|
+
if (!enabled.includes("multiagents-orch")) { enabled.push("multiagents-orch"); settingsChanged = true; }
|
|
89
|
+
if (settingsChanged) {
|
|
90
|
+
settings.enabledMcpjsonServers = enabled;
|
|
91
|
+
fs.writeFileSync(SETTINGS_JSON, JSON.stringify(settings, null, 2) + "\n");
|
|
92
|
+
console.log("[multiagents] Enabled in ~/.claude/settings.json");
|
|
93
|
+
}
|
|
94
|
+
} catch {
|
|
95
|
+
// Don't fail install over settings.json
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
console.log("[multiagents] Restart Claude Code to pick up the new tools.");
|
|
100
|
+
console.log("[multiagents] If tools don't appear, run: multiagents install-mcp");
|
|
81
101
|
} catch (e) {
|
|
82
102
|
// Postinstall should never fail the install
|
|
83
103
|
console.error(`[multiagents] postinstall warning: ${e instanceof Error ? e.message : String(e)}`);
|
|
104
|
+
console.error("[multiagents] Run 'multiagents install-mcp' to configure manually.");
|
|
84
105
|
}
|