Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat(mcp): support multi-target installer

Tin6ab96ea61bde
diff --git a/apps/mcp/package.json b/apps/mcp/package.json
index 45aa5cae5..9d3bb1eb7 100644
--- a/apps/mcp/package.json
+++ b/apps/mcp/package.json
@@ -1,6 +1,6 @@
{
"name": "@kaneo/mcp",
- "version": "0.1.0",
+ "version": "0.1.2",
"description": "Model Context Protocol (stdio) server for Kaneo — tasks, projects, labels, and device authorization",
"license": "MIT",
"type": "module",
diff --git a/apps/mcp/src/install/index.ts b/apps/mcp/src/install/index.ts
index 0b589d863..896df848a 100644
--- a/apps/mcp/src/install/index.ts
+++ b/apps/mcp/src/install/index.ts
@@ -174,13 +174,15 @@ export async function runInstall(argv: string[]): Promise<void> {
return;
}
- let targetId = parsed.target as InstallTargetId | undefined;
+ let targetIds = parsed.target
+ ? [parsed.target as InstallTargetId]
+ : undefined;
const needsInteractive =
- input.isTTY && output.isTTY && !parsed.yes && targetId === undefined;
+ input.isTTY && output.isTTY && !parsed.yes && targetIds === undefined;
if (needsInteractive) {
- targetId = await promptTargetSelect();
- } else if (targetId === undefined) {
+ targetIds = await promptTargetSelect();
+ } else if (targetIds === undefined) {
console.error(
"Non-interactive mode: specify --target (e.g. --target cursor-user) and use -y to confirm.",
);
@@ -190,7 +192,7 @@ export async function runInstall(argv: string[]): Promise<void> {
}
let customPath = parsed.output;
- if (targetId === "custom") {
+ if (targetIds.includes("custom")) {
if (!customPath) {
if (input.isTTY && output.isTTY) {
customPath = await promptCustomConfigPath();
@@ -202,11 +204,6 @@ export async function runInstall(argv: string[]): Promise<void> {
}
}
- const configPath = resolveTargetConfigPath(targetId, {
- cwd: parsed.projectDir,
- customPath,
- });
-
const entryPath = resolvePackageEntryPath();
const env =
parsed.apiUrl !== undefined && parsed.apiUrl.length > 0
@@ -219,46 +216,64 @@ export async function runInstall(argv: string[]): Promise<void> {
...(env ? { env } : {}),
};
- let existingText: string | null = null;
- try {
- existingText = await readFile(configPath, "utf8");
- } catch {
- existingText = null;
- }
+ const writtenPaths: string[] = [];
+
+ for (const targetId of targetIds) {
+ const configPath = resolveTargetConfigPath(targetId, {
+ cwd: parsed.projectDir,
+ customPath,
+ });
- const already = hasExistingServerEntry(existingText, parsed.name);
+ let existingText: string | null = null;
+ try {
+ existingText = await readFile(configPath, "utf8");
+ } catch {
+ existingText = null;
+ }
+
+ const already = hasExistingServerEntry(existingText, parsed.name);
- if (already && !parsed.yes) {
- if (input.isTTY && output.isTTY) {
- const ok = await promptConfirmOverwrite(parsed.name);
- if (!ok) {
- console.log("Aborted.");
+ if (already && !parsed.yes) {
+ if (input.isTTY && output.isTTY) {
+ const ok = await promptConfirmOverwrite(parsed.name);
+ if (!ok) {
+ console.log(`Skipped:\n ${configPath}`);
+ continue;
+ }
+ } else {
+ console.error(
+ `Entry "${parsed.name}" already exists. Pass -y to overwrite.`,
+ );
+ process.exitCode = 1;
return;
}
- } else {
+ }
+
+ let merged: string;
+ try {
+ merged = mergeMcpServerEntry(existingText, parsed.name, serverConfig);
+ } catch {
console.error(
- `Entry "${parsed.name}" already exists. Pass -y to overwrite.`,
+ `Cannot update config (invalid JSON or merge error): ${configPath}`,
);
process.exitCode = 1;
return;
}
+
+ await mkdir(dirname(configPath), { recursive: true });
+ await writeFile(configPath, merged, { encoding: "utf8", mode: 0o600 });
+ writtenPaths.push(configPath);
}
- let merged: string;
- try {
- merged = mergeMcpServerEntry(existingText, parsed.name, serverConfig);
- } catch {
- console.error(
- `Cannot update config (invalid JSON or merge error): ${configPath}`,
- );
- process.exitCode = 1;
+ if (writtenPaths.length === 0) {
+ console.log("No config files were updated.");
return;
}
- await mkdir(dirname(configPath), { recursive: true });
- await writeFile(configPath, merged, { encoding: "utf8", mode: 0o600 });
-
- console.log(`Wrote MCP server "${parsed.name}" to:\n ${configPath}`);
+ console.log(`Wrote MCP server "${parsed.name}" to:`);
+ for (const configPath of writtenPaths) {
+ console.log(` ${configPath}`);
+ }
console.log("\nRestart your MCP client (or reload the window) if needed.");
}
diff --git a/apps/mcp/src/install/wizard.ts b/apps/mcp/src/install/wizard.ts
index f787aee10..03d102259 100644
--- a/apps/mcp/src/install/wizard.ts
+++ b/apps/mcp/src/install/wizard.ts
@@ -6,38 +6,33 @@ function onCancel(): void {
process.exit(0);
}
-function printIntro(): void {
- console.log(`
-────────────────────────────────────────
- Kaneo MCP · editor setup
-────────────────────────────────────────
- Use ↑ / ↓ to move, Enter to select.
-────────────────────────────────────────
-`);
-}
-
-export async function promptTargetSelect(): Promise<InstallTargetId> {
- printIntro();
+export async function promptTargetSelect(): Promise<InstallTargetId[]> {
const answer = await prompts(
{
- type: "select",
- name: "target",
+ type: "multiselect",
+ name: "targets",
message: "Where should Kaneo register this MCP server?",
choices: INSTALL_TARGETS.map((t) => ({
title: t.label,
description: t.description,
value: t.id,
})),
- initial: 0,
+ hint: "- Space to select. Enter to confirm.",
+ min: 1,
+ instructions: false,
},
{ onCancel },
);
- if (answer.target === undefined) {
+ if (
+ answer.targets === undefined ||
+ !Array.isArray(answer.targets) ||
+ answer.targets.length === 0
+ ) {
onCancel();
}
- return answer.target as InstallTargetId;
+ return answer.targets as InstallTargetId[];
}
export async function promptCustomConfigPath(): Promise<string> {