@elisym/mcp 0.8.15 → 0.8.17
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/dist/index.js +53 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -448,8 +448,23 @@ async function runInstall(options) {
|
|
|
448
448
|
if (options.agent) {
|
|
449
449
|
validateAgentName(options.agent);
|
|
450
450
|
}
|
|
451
|
-
|
|
451
|
+
let effectiveAgent = options.agent;
|
|
452
|
+
if (effectiveAgent === void 0) {
|
|
453
|
+
const resolved = await resolveDefaultAgent();
|
|
454
|
+
if (resolved.kind === "ambiguous") {
|
|
455
|
+
console.log(
|
|
456
|
+
`Multiple agents found (${resolved.names.join(", ")}). Re-run with --agent <name> to choose one.`
|
|
457
|
+
);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
if (resolved.kind === "single") {
|
|
461
|
+
effectiveAgent = resolved.name;
|
|
462
|
+
console.log(`Auto-bound to agent "${effectiveAgent}".`);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const entry = buildServerEntry(effectiveAgent, options.env);
|
|
452
466
|
let installed = 0;
|
|
467
|
+
let rebound = 0;
|
|
453
468
|
for (const client of CLIENTS) {
|
|
454
469
|
if (options.client && client.name !== options.client) {
|
|
455
470
|
continue;
|
|
@@ -459,10 +474,13 @@ async function runInstall(options) {
|
|
|
459
474
|
continue;
|
|
460
475
|
}
|
|
461
476
|
try {
|
|
462
|
-
const
|
|
463
|
-
if (
|
|
477
|
+
const result = await installToConfig(path, entry, effectiveAgent);
|
|
478
|
+
if (result === "installed") {
|
|
464
479
|
console.log(`Installed to ${client.name}: ${path}`);
|
|
465
480
|
installed++;
|
|
481
|
+
} else if (result === "rebound") {
|
|
482
|
+
console.log(`Rebound ${client.name} to agent "${effectiveAgent}": ${path}`);
|
|
483
|
+
rebound++;
|
|
466
484
|
} else {
|
|
467
485
|
console.log(`Already installed in ${client.name}`);
|
|
468
486
|
}
|
|
@@ -470,10 +488,21 @@ async function runInstall(options) {
|
|
|
470
488
|
console.log(`Skipped ${client.name}: ${e.message}`);
|
|
471
489
|
}
|
|
472
490
|
}
|
|
473
|
-
if (installed === 0 && !options.client) {
|
|
491
|
+
if (installed === 0 && rebound === 0 && !options.client) {
|
|
474
492
|
console.log("No MCP clients found to install into.");
|
|
475
493
|
}
|
|
476
494
|
}
|
|
495
|
+
async function resolveDefaultAgent() {
|
|
496
|
+
const agents = await listAgents(process.cwd());
|
|
497
|
+
const [first, second] = agents;
|
|
498
|
+
if (!first) {
|
|
499
|
+
return { kind: "none" };
|
|
500
|
+
}
|
|
501
|
+
if (!second) {
|
|
502
|
+
return { kind: "single", name: first.name };
|
|
503
|
+
}
|
|
504
|
+
return { kind: "ambiguous", names: agents.map((agent) => agent.name) };
|
|
505
|
+
}
|
|
477
506
|
async function runUpdate(options) {
|
|
478
507
|
validateClientName(options.client);
|
|
479
508
|
if (options.agent) {
|
|
@@ -610,7 +639,7 @@ async function runList() {
|
|
|
610
639
|
async function writeJsonAtomic(path, data) {
|
|
611
640
|
await writeFileAtomic(path, JSON.stringify(data, null, 2), 384);
|
|
612
641
|
}
|
|
613
|
-
async function installToConfig(path, entry) {
|
|
642
|
+
async function installToConfig(path, entry, agentRebind) {
|
|
614
643
|
let raw;
|
|
615
644
|
try {
|
|
616
645
|
raw = await readFile(path, "utf-8");
|
|
@@ -619,7 +648,7 @@ async function installToConfig(path, entry) {
|
|
|
619
648
|
throw err;
|
|
620
649
|
}
|
|
621
650
|
await writeJsonAtomic(path, { mcpServers: { elisym: entry } });
|
|
622
|
-
return
|
|
651
|
+
return "installed";
|
|
623
652
|
}
|
|
624
653
|
let config;
|
|
625
654
|
try {
|
|
@@ -630,12 +659,27 @@ async function installToConfig(path, entry) {
|
|
|
630
659
|
if (!config.mcpServers) {
|
|
631
660
|
config.mcpServers = {};
|
|
632
661
|
}
|
|
633
|
-
|
|
634
|
-
|
|
662
|
+
const existing = config.mcpServers.elisym;
|
|
663
|
+
if (existing) {
|
|
664
|
+
if (agentRebind === void 0) {
|
|
665
|
+
return "unchanged";
|
|
666
|
+
}
|
|
667
|
+
if (typeof existing !== "object" || Array.isArray(existing)) {
|
|
668
|
+
return "unchanged";
|
|
669
|
+
}
|
|
670
|
+
const rawEnv = existing.env;
|
|
671
|
+
const currentEnv = rawEnv && typeof rawEnv === "object" && !Array.isArray(rawEnv) ? { ...rawEnv } : {};
|
|
672
|
+
if (currentEnv.ELISYM_AGENT === agentRebind) {
|
|
673
|
+
return "unchanged";
|
|
674
|
+
}
|
|
675
|
+
currentEnv.ELISYM_AGENT = agentRebind;
|
|
676
|
+
existing.env = currentEnv;
|
|
677
|
+
await safeRewriteJson(path, raw, config);
|
|
678
|
+
return "rebound";
|
|
635
679
|
}
|
|
636
680
|
config.mcpServers.elisym = entry;
|
|
637
681
|
await safeRewriteJson(path, raw, config);
|
|
638
|
-
return
|
|
682
|
+
return "installed";
|
|
639
683
|
}
|
|
640
684
|
function createLogger(destination) {
|
|
641
685
|
const opts = {
|