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): add interactive installer

Tin5dd5fd424fd4
diff --git a/apps/mcp/README.md b/apps/mcp/README.md
index 77fb89c54..42a8991c5 100644
--- a/apps/mcp/README.md
+++ b/apps/mcp/README.md
@@ -26,17 +26,53 @@ DEVICE_AUTH_CLIENT_IDS=kaneo-cli,kaneo-mcp,your-client-id
## Install
-If the package is published to npm or your private registry:
+**Recommended (no global install):** run the interactive installer with npx:
+
+```bash
+npx @kaneo/mcp
+```
+
+npm downloads the package, then an **interactive menu** (arrow keys + Enter) asks **where** to register the server (Cursor user-wide, Cursor project, Claude Desktop, or a custom JSON path). It then merges a `mcpServers` entry that points at this package’s `dist/index.js` with your current Node binary.
+
+In a normal terminal, `npx @kaneo/mcp` and `kaneo-mcp` with no subcommand both start the installer. When the process is **not** attached to a TTY (for example when Cursor launches the MCP server with a pipe), the same entry runs the stdio MCP server instead.
+
+To run the server manually from a shell (for example to debug stdio), use:
+
+```bash
+npx @kaneo/mcp serve
+```
+
+If you prefer a global install:
```bash
npm install -g @kaneo/mcp
kaneo-mcp
```
-Or:
+(`kaneo-mcp install` is the same installer with an explicit subcommand.)
+
+Non-interactive example (Cursor user config, skip overwrite prompts):
```bash
-npx @kaneo/mcp
+kaneo-mcp install --target cursor-user -y
+```
+
+Point at a self-hosted API when generating the config:
+
+```bash
+kaneo-mcp install --target cursor-user -y --api-url https://kaneo.example.com
+```
+
+See all options:
+
+```bash
+kaneo-mcp install --help
+```
+
+If you are currently inside the local `apps/mcp` package directory, npm may resolve the local workspace package instead of the published one and fail to expose the bin. In that case, either run `npx` from outside `apps/mcp`, or use a local build:
+
+```bash
+node dist/index.js
```
The published package includes `dist/`. `prepublishOnly` runs the build before publish.
@@ -58,13 +94,7 @@ Or run it from the package directory:
pnpm -C apps/mcp run build
```
-The CLI entry points to `./dist/index.js`.
-
-For Cursor or another MCP client, point the command at the built file:
-
-```text
-.../kaneo/apps/mcp/dist/index.js
-```
+The CLI entry points to `./dist/index.js`. Use `npx @kaneo/mcp` or `kaneo-mcp` after a global install so your IDE config points at the resolved path.
## Authentication
diff --git a/apps/mcp/package.json b/apps/mcp/package.json
index 6eca17c88..45aa5cae5 100644
--- a/apps/mcp/package.json
+++ b/apps/mcp/package.json
@@ -22,6 +22,7 @@
"build": "tsc -p tsconfig.json",
"prepublishOnly": "npm run build",
"dev": "tsx watch src/index.ts",
+ "lint": "biome check --write .",
"start": "node dist/index.js",
"test": "vitest run --config vitest.config.ts",
"test:watch": "vitest --config vitest.config.ts"
@@ -29,11 +30,13 @@
"dependencies": {
"@modelcontextprotocol/sdk": "^1.26.0",
"open": "^10.1.0",
+ "prompts": "^2.4.2",
"zod": "^3.25.0"
},
"devDependencies": {
"@kaneo/typescript-config": "workspace:*",
"@types/node": "^25.3.5",
+ "@types/prompts": "^2.4.9",
"tsx": "^4.21.0",
"typescript": "^5.9.3",
"vitest": "^4.1.2"
diff --git a/apps/mcp/src/cli.ts b/apps/mcp/src/cli.ts
new file mode 100644
index 000000000..df1ee5a38
--- /dev/null
+++ b/apps/mcp/src/cli.ts
@@ -0,0 +1,59 @@
+import { stdin as input } from "node:process";
+import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
+import { runInstall } from "./install/index.js";
+import { createMcpServer } from "./server.js";
+
+const SERVE_ALIASES = new Set(["serve", "server", "stdio", "run"]);
+
+export async function runCli(): Promise<void> {
+ const argv = process.argv.slice(2);
+ if (argv[0] === "-h" || argv[0] === "--help" || argv[0] === "help") {
+ printMainHelp();
+ return;
+ }
+ if (argv[0] === "install" || argv[0] === "setup") {
+ await runInstall(argv.slice(1));
+ return;
+ }
+ if (argv[0] !== undefined) {
+ if (SERVE_ALIASES.has(argv[0])) {
+ await startMcpServer();
+ return;
+ }
+ console.error(`Unknown command: ${argv[0]}`);
+ printMainHelp();
+ process.exitCode = 1;
+ return;
+ }
+ if (input.isTTY) {
+ await runInstall([]);
+ return;
+ }
+ await startMcpServer();
+}
+
+async function startMcpServer(): Promise<void> {
+ const server = createMcpServer();
+ const transport = new StdioServerTransport();
+ await server.connect(transport);
+}
+
+function printMainHelp(): void {
+ console.log(`kaneo-mcp — Kaneo MCP server (stdio transport)
+
+Usage:
+ npx @kaneo/mcp Interactive installer (terminal only; no global install)
+ kaneo-mcp Same: installer in a TTY; MCP server when stdin is piped
+ kaneo-mcp install Register in Cursor / Claude / a custom path (explicit)
+ kaneo-mcp serve Run the MCP server (use from a terminal to test stdio)
+ kaneo-mcp help
+
+Options:
+ -h, --help Show this help
+
+MCP clients (Cursor, etc.) run this process with a pipe, so they get the server.
+In a normal terminal, the default is the interactive installer.
+
+See also: kaneo-mcp install --help
+`);
+}
diff --git a/apps/mcp/src/index.ts b/apps/mcp/src/index.ts
index 67400f0b7..100e1f142 100644
--- a/apps/mcp/src/index.ts
+++ b/apps/mcp/src/index.ts
@@ -1,14 +1,7 @@
#!/usr/bin/env node
-import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
-import { createMcpServer } from "./server.js";
+import { runCli } from "./cli.js";
-async function main(): Promise<void> {
- const server = createMcpServer();
- const transport = new StdioServerTransport();
- await server.connect(transport);
-}
-
-main().catch((err: unknown) => {
+runCli().catch((err: unknown) => {
console.error(err);
process.exit(1);
});
diff --git a/apps/mcp/src/install/index.ts b/apps/mcp/src/install/index.ts
new file mode 100644
index 000000000..0b589d863
--- /dev/null
+++ b/apps/mcp/src/install/index.ts
@@ -0,0 +1,289 @@
+import { mkdir, readFile, writeFile } from "node:fs/promises";
+import { dirname } from "node:path";
+import { stdin as input, stdout as output } from "node:process";
+import { type McpServerEntry, mergeMcpServerEntry } from "./merge-config.js";
+import { resolvePackageEntryPath } from "./resolve-entry.js";
+import { type InstallTargetId, resolveTargetConfigPath } from "./targets.js";
+import {
+ promptConfirmOverwrite,
+ promptCustomConfigPath,
+ promptTargetSelect,
+} from "./wizard.js";
+
+export type ParsedInstallArgs = {
+ target?: string;
+ output?: string;
+ name: string;
+ yes: boolean;
+ apiUrl?: string;
+ projectDir: string;
+ help: boolean;
+};
+
+export function parseInstallArgs(argv: string[]): ParsedInstallArgs {
+ let target: string | undefined;
+ let output: string | undefined;
+ let name = "kaneo";
+ let yes = false;
+ let apiUrl: string | undefined;
+ let projectDir = process.cwd();
+ let help = false;
+
+ for (let i = 0; i < argv.length; i++) {
+ const a = argv[i];
+ if (a === undefined) {
+ continue;
+ }
+ if (a === "-h" || a === "--help") {
+ help = true;
+ continue;
+ }
+ if (a === "-y" || a === "--yes") {
+ yes = true;
+ continue;
+ }
+ if (a === "--target") {
+ const v = argv[i + 1];
+ if (!v || v.startsWith("-")) {
+ throw new Error("--target requires a value");
+ }
+ target = v;
+ i++;
+ continue;
+ }
+ if (a.startsWith("--target=")) {
+ target = a.slice("--target=".length);
+ continue;
+ }
+ if (a === "--output") {
+ const v = argv[i + 1];
+ if (!v || v.startsWith("-")) {
+ throw new Error("--output requires a value");
+ }
+ output = v;
+ i++;
+ continue;
+ }
+ if (a.startsWith("--output=")) {
+ output = a.slice("--output=".length);
+ continue;
+ }
+ if (a === "--name") {
+ const v = argv[i + 1];
+ if (!v || v.startsWith("-")) {
+ throw new Error("--name requires a value");
+ }
+ name = v;
+ i++;
+ continue;
+ }
+ if (a.startsWith("--name=")) {
+ name = a.slice("--name=".length);
+ continue;
+ }
+ if (a === "--api-url") {
+ const v = argv[i + 1];
+ if (!v || v.startsWith("-")) {
+ throw new Error("--api-url requires a value");
+ }
+ apiUrl = v;
+ i++;
+ continue;
+ }
+ if (a.startsWith("--api-url=")) {
+ apiUrl = a.slice("--api-url=".length);
+ continue;
+ }
+ if (a === "--project-dir") {
+ const v = argv[i + 1];
+ if (!v || v.startsWith("-")) {
+ throw new Error("--project-dir requires a value");
+ }
+ projectDir = v;
+ i++;
+ continue;
+ }
+ if (a.startsWith("--project-dir=")) {
+ projectDir = a.slice("--project-dir=".length);
+ continue;
+ }
+ throw new Error(`Unknown option: ${a}`);
+ }
+
+ return { target, output, name, yes, apiUrl, projectDir, help };
+}
+
+function hasExistingServerEntry(
+ jsonText: string | null,
+ serverName: string,
+): boolean {
+ if (!jsonText) {
+ return false;
+ }
+ try {
+ const root = JSON.parse(jsonText) as unknown;
+ if (!root || typeof root !== "object" || Array.isArray(root)) {
+ return false;
+ }
+ const m = (root as { mcpServers?: unknown }).mcpServers;
+ if (!m || typeof m !== "object" || Array.isArray(m)) {
+ return false;
+ }
+ return Object.hasOwn(m as object, serverName);
+ } catch {
+ return false;
+ }
+}
+
+const VALID_TARGETS: readonly InstallTargetId[] = [
+ "cursor-user",
+ "cursor-project",
+ "claude-desktop",
+ "custom",
+];
+
+function isInstallTargetId(s: string): s is InstallTargetId {
+ return (VALID_TARGETS as readonly string[]).includes(s);
+}
+
+export async function runInstall(argv: string[]): Promise<void> {
+ let parsed: ParsedInstallArgs;
+ try {
+ parsed = parseInstallArgs(argv);
+ } catch (e) {
+ console.error(e instanceof Error ? e.message : String(e));
+ printInstallHelp();
+ process.exitCode = 1;
+ return;
+ }
+
+ if (parsed.help) {
+ printInstallHelp();
+ return;
+ }
+
+ if (parsed.target !== undefined && !isInstallTargetId(parsed.target)) {
+ console.error(`Invalid --target. Use one of: ${VALID_TARGETS.join(", ")}`);
+ process.exitCode = 1;
+ return;
+ }
+
+ if (!parsed.name.trim()) {
+ console.error("--name must be a non-empty string.");
+ process.exitCode = 1;
+ return;
+ }
+
+ let targetId = parsed.target as InstallTargetId | undefined;
+ const needsInteractive =
+ input.isTTY && output.isTTY && !parsed.yes && targetId === undefined;
+
+ if (needsInteractive) {
+ targetId = await promptTargetSelect();
+ } else if (targetId === undefined) {
+ console.error(
+ "Non-interactive mode: specify --target (e.g. --target cursor-user) and use -y to confirm.",
+ );
+ printInstallHelp();
+ process.exitCode = 1;
+ return;
+ }
+
+ let customPath = parsed.output;
+ if (targetId === "custom") {
+ if (!customPath) {
+ if (input.isTTY && output.isTTY) {
+ customPath = await promptCustomConfigPath();
+ } else {
+ console.error("Custom target requires --output <path>");
+ process.exitCode = 1;
+ return;
+ }
+ }
+ }
+
+ const configPath = resolveTargetConfigPath(targetId, {
+ cwd: parsed.projectDir,
+ customPath,
+ });
+
+ const entryPath = resolvePackageEntryPath();
+ const env =
+ parsed.apiUrl !== undefined && parsed.apiUrl.length > 0
+ ? { KANEO_API_URL: parsed.apiUrl }
+ : undefined;
+
+ const serverConfig: McpServerEntry = {
+ command: process.execPath,
+ args: [entryPath],
+ ...(env ? { env } : {}),
+ };
+
+ 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.");
+ return;
+ }
+ } else {
+ console.error(
+ `Entry "${parsed.name}" already exists. Pass -y to overwrite.`,
+ );
+ process.exitCode = 1;
+ return;
+ }
+ }
+
+ 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;
+ 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("\nRestart your MCP client (or reload the window) if needed.");
+}
+
+function printInstallHelp(): void {
+ console.log(`kaneo-mcp install — register Kaneo in an MCP client config
+
+Usage:
+ kaneo-mcp install [options]
+
+Without options, runs interactively (pick Cursor / Claude / custom path).
+
+Options:
+ --target <id> cursor-user | cursor-project | claude-desktop | custom
+ --output <path> Required for --target custom (absolute path to JSON file)
+ --project-dir <dir> Base directory for cursor-project (default: current dir)
+ --name <string> MCP server key under mcpServers (default: kaneo)
+ --api-url <url> Set KANEO_API_URL in the generated entry (optional)
+ -y, --yes Overwrite existing entry without prompting
+ -h, --help Show this help
+
+Examples:
+ npm install -g @kaneo/mcp
+ kaneo-mcp install
+
+ kaneo-mcp install --target cursor-user -y
+ kaneo-mcp install --target custom --output /path/to/mcp.json -y
+`);
+}
diff --git a/apps/mcp/src/install/merge-config.test.ts b/apps/mcp/src/install/merge-config.test.ts
new file mode 100644
index 000000000..66f9f5884
--- /dev/null
+++ b/apps/mcp/src/install/merge-config.test.ts
@@ -0,0 +1,44 @@
+import { describe, expect, it } from "vitest";
+import { mergeMcpServerEntry } from "./merge-config.js";
+
+describe("mergeMcpServerEntry", () => {
+ it("creates mcpServers when file is empty", () => {
+ const out = mergeMcpServerEntry(null, "kaneo", {
+ command: "/usr/bin/node",
+ args: ["/app/index.js"],
+ });
+ expect(JSON.parse(out)).toEqual({
+ mcpServers: {
+ kaneo: {
+ command: "/usr/bin/node",
+ args: ["/app/index.js"],
+ },
+ },
+ });
+ });
+
+ it("merges without removing other servers or top-level keys", () => {
+ const existing = JSON.stringify({
+ other: true,
+ mcpServers: {
+ other: { command: "x", args: ["y"] },
+ },
+ });
+ const out = mergeMcpServerEntry(existing, "kaneo", {
+ command: "/usr/bin/node",
+ args: ["/app/index.js"],
+ env: { KANEO_API_URL: "http://localhost:1337" },
+ });
+ expect(JSON.parse(out)).toEqual({
+ other: true,
+ mcpServers: {
+ other: { command: "x", args: ["y"] },
+ kaneo: {
+ command: "/usr/bin/node",
+ args: ["/app/index.js"],
+ env: { KANEO_API_URL: "http://localhost:1337" },
+ },
+ },
+ });
+ });
+});
diff --git a/apps/mcp/src/install/merge-config.ts b/apps/mcp/src/install/merge-config.ts
new file mode 100644
index 000000000..8f5ec2d99
--- /dev/null
+++ b/apps/mcp/src/install/merge-config.ts
@@ -0,0 +1,40 @@
+export type McpServerEntry = {
+ command: string;
+ args: string[];
+ env?: Record<string, string>;
+};
+
+/**
+ * Merges or replaces `mcpServers[serverName]` and returns formatted JSON.
+ * Preserves other top-level keys and other MCP server entries.
+ */
+export function mergeMcpServerEntry(
+ existingJson: string | null,
+ serverName: string,
+ serverConfig: McpServerEntry,
+): string {
+ let root: Record<string, unknown> = {};
+ if (existingJson) {
+ const parsed: unknown = JSON.parse(existingJson);
+ if (
+ typeof parsed === "object" &&
+ parsed !== null &&
+ !Array.isArray(parsed)
+ ) {
+ root = { ...(parsed as Record<string, unknown>) };
+ }
+ }
+
+ const mcpServers = (() => {
+ const raw = root.mcpServers;
+ if (typeof raw === "object" && raw !== null && !Array.isArray(raw)) {
+ return { ...(raw as Record<string, unknown>) };
+ }
+ return {};
+ })();
+
+ mcpServers[serverName] = serverConfig;
+ root.mcpServers = mcpServers;
+
+ return `${JSON.stringify(root, null, 2)}\n`;
+}
diff --git a/apps/mcp/src/install/parse-install-args.test.ts b/apps/mcp/src/install/parse-install-args.test.ts
new file mode 100644
index 000000000..aa183afaa
--- /dev/null
+++ b/apps/mcp/src/install/parse-install-args.test.ts
@@ -0,0 +1,30 @@
+import { describe, expect, it } from "vitest";
+import { parseInstallArgs } from "./index.js";
+
+describe("parseInstallArgs", () => {
+ it("parses flags", () => {
+ expect(
+ parseInstallArgs([
+ "--target",
+ "cursor-user",
+ "--name",
+ "my-kaneo",
+ "-y",
+ "--api-url",
+ "http://example.com",
+ ]),
+ ).toEqual({
+ target: "cursor-user",
+ output: undefined,
+ name: "my-kaneo",
+ yes: true,
+ apiUrl: "http://example.com",
+ projectDir: process.cwd(),
+ help: false,
+ });
+ });
+
+ it("throws on unknown option", () => {
+ expect(() => parseInstallArgs(["--nope"])).toThrow("Unknown option");
+ });
+});
diff --git a/apps/mcp/src/install/resolve-entry.ts b/apps/mcp/src/install/resolve-entry.ts
new file mode 100644
index 000000000..99ca518a1
--- /dev/null
+++ b/apps/mcp/src/install/resolve-entry.ts
@@ -0,0 +1,10 @@
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+
+/**
+ * Absolute path to this package's `dist/index.js` (the MCP stdio entry).
+ * Resolved from `dist/install/resolve-entry.js` at runtime.
+ */
+export function resolvePackageEntryPath(): string {
+ return join(dirname(fileURLToPath(import.meta.url)), "../index.js");
+}
diff --git a/apps/mcp/src/install/targets.ts b/apps/mcp/src/install/targets.ts
new file mode 100644
index 000000000..bbfb969b2
--- /dev/null
+++ b/apps/mcp/src/install/targets.ts
@@ -0,0 +1,79 @@
+import { homedir } from "node:os";
+import { join } from "node:path";
+
+export type InstallTargetId =
+ | "cursor-user"
+ | "cursor-project"
+ | "claude-desktop"
+ | "custom";
+
+export type InstallTarget = {
+ id: InstallTargetId;
+ label: string;
+ description: string;
+};
+
+export const INSTALL_TARGETS: readonly InstallTarget[] = [
+ {
+ id: "cursor-user",
+ label: "Cursor (user-wide)",
+ description: "~/.cursor/mcp.json — available in all projects",
+ },
+ {
+ id: "cursor-project",
+ label: "Cursor (this project only)",
+ description: ".cursor/mcp.json in the current directory",
+ },
+ {
+ id: "claude-desktop",
+ label: "Claude Desktop",
+ description: "claude_desktop_config.json for the Claude app",
+ },
+ {
+ id: "custom",
+ label: "Custom file path",
+ description: "Any JSON file you choose (advanced)",
+ },
+];
+
+export function getClaudeDesktopConfigPath(): string {
+ const platform = process.platform;
+ if (platform === "darwin") {
+ return join(
+ homedir(),
+ "Library",
+ "Application Support",
+ "Claude",
+ "claude_desktop_config.json",
+ );
+ }
+ if (platform === "win32") {
+ const appData = process.env.APPDATA;
+ if (!appData) {
+ throw new Error("APPDATA is not set; cannot resolve Claude Desktop path");
+ }
+ return join(appData, "Claude", "claude_desktop_config.json");
+ }
+ return join(homedir(), ".config", "Claude", "claude_desktop_config.json");
+}
+
+export function resolveTargetConfigPath(
+ id: InstallTargetId,
+ options: { cwd: string; customPath?: string },
+): string {
+ switch (id) {
+ case "cursor-user":
+ return join(homedir(), ".cursor", "mcp.json");
+ case "cursor-project":
+ return join(options.cwd, ".cursor", "mcp.json");
+ case "claude-desktop":
+ return getClaudeDesktopConfigPath();
+ case "custom": {
+ const p = options.customPath?.trim();
+ if (!p) {
+ throw new Error("Custom target requires a file path");
+ }
+ return p;
+ }
+ }
+}
diff --git a/apps/mcp/src/install/wizard.ts b/apps/mcp/src/install/wizard.ts
new file mode 100644
index 000000000..f787aee10
--- /dev/null
+++ b/apps/mcp/src/install/wizard.ts
@@ -0,0 +1,82 @@
+import prompts from "prompts";
+import { INSTALL_TARGETS, type InstallTargetId } from "./targets.js";
+
+function onCancel(): void {
+ console.log("\nCancelled.");
+ 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();
+ const answer = await prompts(
+ {
+ type: "select",
+ name: "target",
+ message: "Where should Kaneo register this MCP server?",
+ choices: INSTALL_TARGETS.map((t) => ({
+ title: t.label,
+ description: t.description,
+ value: t.id,
+ })),
+ initial: 0,
+ },
+ { onCancel },
+ );
+
+ if (answer.target === undefined) {
+ onCancel();
+ }
+
+ return answer.target as InstallTargetId;
+}
+
+export async function promptCustomConfigPath(): Promise<string> {
+ const answer = await prompts(
+ {
+ type: "text",
+ name: "path",
+ message: "Absolute path to the JSON config file (create or update):",
+ validate: (v) =>
+ typeof v === "string" && v.trim().length > 0
+ ? true
+ : "Path is required",
+ },
+ { onCancel },
+ );
+
+ if (answer.path === undefined) {
+ onCancel();
+ }
+
+ return String(answer.path).trim();
+}
+
+export async function promptConfirmOverwrite(
+ serverName: string,
+): Promise<boolean> {
+ const answer = await prompts(
+ {
+ type: "confirm",
+ name: "overwrite",
+ message: `MCP server "${serverName}" is already in this file. Overwrite it?`,
+ initial: false,
+ },
+ { onCancel },
+ );
+
+ if (answer.overwrite === undefined) {
+ onCancel();
+ }
+
+ return Boolean(answer.overwrite);
+}
diff --git a/apps/mcp/src/kaneo/client.ts b/apps/mcp/src/kaneo/client.ts
index b8f900f09..75c38e9aa 100644
--- a/apps/mcp/src/kaneo/client.ts
+++ b/apps/mcp/src/kaneo/client.ts
@@ -52,14 +52,20 @@ export class KaneoClient {
}
}
if (!res.ok) {
- const message =
+ let detail: string;
+ if (
typeof body === "object" &&
body !== null &&
"message" in body &&
typeof (body as { message: unknown }).message === "string"
- ? (body as { message: string }).message
- : `HTTP ${res.status}`;
- throw new Error(`${path}: ${message} ${text}`);
+ ) {
+ detail = (body as { message: string }).message;
+ } else if (typeof body === "string" && body.length > 0) {
+ detail = body.length > 500 ? `${body.slice(0, 500)}…` : body;
+ } else {
+ detail = `HTTP ${res.status}`;
+ }
+ throw new Error(`${path}: ${detail}`);
}
return body as T;
}
diff --git a/apps/mcp/src/server.ts b/apps/mcp/src/server.ts
index 797be985b..615da8159 100644
--- a/apps/mcp/src/server.ts
+++ b/apps/mcp/src/server.ts
@@ -1,9 +1,15 @@
+import { createRequire } from "node:module";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { AuthService } from "./auth/auth-service.js";
import { KaneoClient } from "./kaneo/client.js";
import { registerTools } from "./tools/register.js";
import { normalizeBaseUrl } from "./utils/normalize-base-url.js";
+const require = createRequire(import.meta.url);
+const { version: packageVersion } = require("../package.json") as {
+ version: string;
+};
+
export function createMcpServer(): McpServer {
const baseUrl = normalizeBaseUrl(
process.env.KANEO_API_URL || "http://localhost:1337",
@@ -13,7 +19,7 @@ export function createMcpServer(): McpServer {
const client = new KaneoClient({ baseUrl, auth });
const server = new McpServer({
name: "kaneo-mcp",
- version: "0.1.0",
+ version: packageVersion,
});
registerTools(server, { client });
return server;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 204593312..ba7c65615 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -166,6 +166,9 @@ importers:
open:
specifier: ^10.1.0
version: 10.2.0
+ prompts:
+ specifier: ^2.4.2
+ version: 2.4.2
zod:
specifier: ^3.25.0
version: 3.25.76
@@ -176,6 +179,9 @@ importers:
'@types/node':
specifier: ^25.3.5
version: 25.5.0
+ '@types/prompts':
+ specifier: ^2.4.9
+ version: 2.4.9
tsx:
specifier: ^4.21.0
version: 4.21.0
@@ -4235,6 +4241,9 @@ packages:
resolution: {integrity: sha512-gT+oueVQkqnj6ajGJXblFR4iavIXWsGAFCk3dP4Kki5+a9R4NMt0JARdk6s8cUKcfUoqP5dAtDSLU8xYUTFV+Q==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-qTxFi6Buiu8+50/+3DGIWLHM6QuWsEKugJnnP6iv2Mc4ncxE4A/OJkjuVOA+5X0X1S/nq5VJRa8Lu+nwcvbrKA==}
+
resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==}
peerDependencies:
@@ -12658,6 +12667,11 @@ snapshots:
pg-protocol: 1.12.0
pg-types: 2.2.0
+ '@types/[email protected]':
+ dependencies:
+ '@types/node': 25.5.0
+ kleur: 3.0.3
+
dependencies:
'@types/react': 19.2.14