Skip to content

The VS Code of video editing, built for agents.

TypeScript

Add MCP server command and enhance dashboard integration

konstantin-paulus277d44e63653
diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts
index 5bd43480..44d4dd04 100644
--- a/apps/cli/src/index.ts
+++ b/apps/cli/src/index.ts
@@ -10,6 +10,7 @@ import { z } from "zod";
import { version } from "../../../package.json";
import { MCP_URL, toolByName } from "@diffusionstudio/dapi";
import { APP_NAME, call, isAppDown, launchApp, ping, waitForApp } from "./cli-client";
+import { runProxy } from "./mcp-proxy";
import type { GenericTool, ToolInput, ToolName } from "@diffusionstudio/dapi";
@@ -88,6 +89,13 @@ program
if (path !== undefined) await run("open", { dir: resolve(path) });
});
+program
+ .command("mcp")
+ .description(
+ `Serve ${APP_NAME}'s MCP server over stdio, for agents that cannot connect to it by URL (Claude Desktop). Launches the app in the background if it is not running. Agents that speak Streamable HTTP should use ${MCP_URL} directly.`,
+ )
+ .action(() => runProxy().catch(appError));
+
program
.command("context")
.alias("ctx")
diff --git a/apps/cli/src/mcp-proxy.ts b/apps/cli/src/mcp-proxy.ts
new file mode 100644
index 00000000..9e800e3f
--- /dev/null
+++ b/apps/cli/src/mcp-proxy.ts
@@ -0,0 +1,49 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// `dapi mcp`: the entry point for agents that only run stdio servers (Claude
+// Desktop). A message pipe between stdio and the app's HTTP endpoint: each
+// side is an SDK transport, so session handling and SSE framing are theirs,
+// and nothing here looks inside a message. Stdout belongs to the protocol;
+// anything for a human goes to stderr.
+
+import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
+import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
+import { MCP_URL } from "@diffusionstudio/dapi";
+import { APP_NAME, isAppDown, launchApp, ping, waitForApp } from "./cli-client";
+
+import type { JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
+
+export async function runProxy(): Promise<void> {
+ try {
+ await ping();
+ } catch (e) {
+ if (!isAppDown(e)) throw e;
+ // Launching is macOS's job; elsewhere the user starts the app by hand.
+ if (!(await launchApp(true))) {
+ throw new Error(`${APP_NAME} is not running. Launch the app first, then retry.`);
+ }
+ await waitForApp();
+ }
+
+ const upstream = new StreamableHTTPClientTransport(new URL(MCP_URL));
+ const stdio = new StdioServerTransport();
+
+ const fail = (error: Error): void => {
+ console.error(`[dapi mcp] ${error.message}`);
+ process.exit(1);
+ };
+
+ upstream.onmessage = (message: JSONRPCMessage) => void stdio.send(message).catch(fail);
+ stdio.onmessage = (message: JSONRPCMessage) => void upstream.send(message).catch(fail);
+ upstream.onerror = (error) => console.error(`[dapi mcp] ${error.message}`);
+ stdio.onerror = (error) => console.error(`[dapi mcp] ${error.message}`);
+ // The app went away (quit, or the session was closed): the agent sees EOF.
+ upstream.onclose = () => process.exit(0);
+ // The agent went away: tell the app, which ends the session.
+ stdio.onclose = () => void upstream.close().finally(() => process.exit(0));
+
+ await upstream.start();
+ await stdio.start();
+}
diff --git a/apps/desktop/scripts/stage-cli.mjs b/apps/desktop/scripts/stage-cli.mjs
index a774a41e..82d53811 100644
--- a/apps/desktop/scripts/stage-cli.mjs
+++ b/apps/desktop/scripts/stage-cli.mjs
@@ -5,7 +5,9 @@
// Stages the dapi CLI into apps/desktop/cli so electron-forge can ship it as
// an app resource (Contents/Resources/cli). The staged layout:
// cli/dapi.js bundled CLI (built by apps/cli), self-contained
-// cli/bin/dapi shell wrapper: the file that gets linked into PATH
+// cli/bin/dapi shell wrapper: what Claude Desktop runs as `dapi mcp`
+// (registered by mcp-install.ts) and the file that gets
+// linked into PATH
import { chmodSync, cpSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
@@ -22,7 +24,7 @@ cpSync(join(cliDir, "dist", "index.js"), join(stageDir, "dapi.js"));
// The wrapper runs the CLI bundle on the app's own Electron binary in Node
// mode, so users need no separate Node install. It resolves symlinks first
-// because Homebrew links it into PATH.
+// because both Homebrew and the in-app installer link it into PATH.
const wrapper = `#!/bin/sh
SELF="$0"
while [ -L "$SELF" ]; do
diff --git a/apps/desktop/src/cli-install.ts b/apps/desktop/src/cli-install.ts
new file mode 100644
index 00000000..955ccd6a
--- /dev/null
+++ b/apps/desktop/src/cli-install.ts
@@ -0,0 +1,99 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// The `dapi` command on PATH: a symlink from /usr/local/bin to the wrapper
+// the app ships in its resources. Creating it needs an admin password,
+// which macOS asks for through osascript so the app itself never sees
+// credentials; removing a link asks only when the folder demands it.
+
+import { app } from "electron";
+import { execFile } from "node:child_process";
+import { existsSync, lstatSync, unlinkSync } from "node:fs";
+import { join } from "node:path";
+
+import type { CliInstallResult, CliStatus, CliUninstallResult } from "./main-channels";
+
+export const CLI_LINK_PATH = "/usr/local/bin/dapi";
+
+// The dev workflow links the workspace build into Homebrew's bin instead
+// (`symlink:create` in apps/cli), so that location counts as installed too.
+const DEV_LINK_PATH = "/opt/homebrew/bin/dapi";
+
+/**
+ * Whether `path` is a symlink — dangling or not, since a link left behind
+ * by a deleted bundle is exactly what removal is for. `existsSync` follows
+ * links and would miss that case.
+ */
+function isLink(path: string): boolean {
+ return lstatSync(path, { throwIfNoEntry: false })?.isSymbolicLink() ?? false;
+}
+
+/** The first of the two locations that holds anything, or null. */
+function installedPath(): string | null {
+ for (const path of [CLI_LINK_PATH, DEV_LINK_PATH]) {
+ if (isLink(path) || existsSync(path)) return path;
+ }
+ return null;
+}
+
+/** Where `dapi` stands on this machine, without asking for a password. */
+export function cliStatus(): CliStatus {
+ const path = installedPath();
+ if (path) return { installed: true, path, managed: isLink(path), available: true };
+ return { installed: false, path: null, managed: false, available: app.isPackaged };
+}
+
+// The standard macOS admin prompt, for the one shell line that needs it.
+function elevated(shell: string): Promise<void> {
+ const script = `do shell script "${shell.replaceAll('"', '\\"')}" with administrator privileges`;
+ return new Promise((resolve, reject) => {
+ execFile("osascript", ["-e", script], (err) => (err ? reject(err) : resolve()));
+ });
+}
+
+/** osascript error -128: the user dismissed the prompt. Not an error, not done. */
+const cancelled = (e: unknown): boolean => ((e as Error).message ?? "").includes("-128");
+
+export async function installCli(): Promise<CliInstallResult> {
+ if (!app.isPackaged) {
+ return {
+ status: "error",
+ error: "Installing the CLI is only available in the packaged app. Use `npm run symlink:create` in development.",
+ };
+ }
+ const wrapper = join(process.resourcesPath, "cli", "bin", "dapi");
+ try {
+ await elevated(`mkdir -p /usr/local/bin && ln -sf '${wrapper}' '${CLI_LINK_PATH}'`);
+ return { status: "installed" };
+ } catch (e) {
+ return cancelled(e) ? { status: "cancelled" } : { status: "error", error: (e as Error).message };
+ }
+}
+
+/**
+ * Takes the `dapi` link off PATH, whichever of the two locations holds it.
+ * Only a symlink is touched: a real binary somebody put there is not ours
+ * to delete. The plain unlink covers Homebrew's user-owned bin; when the
+ * folder refuses (/usr/local/bin is root's), the admin prompt takes over.
+ */
+export async function uninstallCli(): Promise<CliUninstallResult> {
+ const path = installedPath();
+ if (!path) return { status: "absent" };
+ if (!isLink(path)) {
+ return { status: "error", error: `${path} is not a link, so it was left alone.` };
+ }
+ try {
+ unlinkSync(path);
+ return { status: "removed" };
+ } catch (e) {
+ const code = (e as NodeJS.ErrnoException).code;
+ if (code !== "EACCES" && code !== "EPERM") return { status: "error", error: (e as Error).message };
+ }
+ try {
+ await elevated(`rm -f '${path}'`);
+ return { status: "removed" };
+ } catch (e) {
+ return cancelled(e) ? { status: "cancelled" } : { status: "error", error: (e as Error).message };
+ }
+}
diff --git a/apps/desktop/src/main-channels.ts b/apps/desktop/src/main-channels.ts
index 8e43275d..416578a5 100644
--- a/apps/desktop/src/main-channels.ts
+++ b/apps/desktop/src/main-channels.ts
@@ -11,6 +11,7 @@
// @diffusionstudio/dapi), in the other direction: main asks, the renderer answers.
import type { LogEntry, ScreenshotResult } from "@diffusionstudio/dapi";
import type { SourceEdit, WriteResult } from "./edit-types";
+import type { AgentId } from "./mcp-config";
export const MAIN_WIRE = {
REQUEST: "main:request",
@@ -63,6 +64,11 @@ export const MAIN_CHANNELS = {
PROJECTS_FS_REMOVE: "projects:fs-remove",
PROJECTS_FS_REAL_PATH: "projects:fs-real-path",
AGENT_CHAT_ENDPOINT: "agent-chat:endpoint",
+ MCP_STATUS: "mcp:status",
+ MCP_APPLY: "mcp:apply",
+ CLI_STATUS: "cli:status",
+ CLI_INSTALL: "cli:install",
+ CLI_UNINSTALL: "cli:uninstall",
// Main→Renderer events
AUTH_CALLBACK: "auth:callback",
@@ -101,6 +107,59 @@ export type CompileResult =
{ ok: true; code: string } | { ok: false; error: string };
export type { SourceEdit, WriteResult };
+export type { AgentId };
+
+// One agent the settings page lists: whether it is set up on this machine,
+// whether its config already carries the app's MCP entry, and — for the
+// agents that need the bundled `dapi` binary — why this build cannot
+// connect it (null when it can).
+export type McpAgentStatus = {
+ id: AgentId;
+ label: string;
+ detected: boolean;
+ connected: boolean;
+ /** Absolute path of the config file the entry goes into. */
+ config: string;
+ unavailable: string | null;
+};
+
+/** `url` is the HTTP endpoint any other agent can be pointed at by hand. */
+export type McpStatus = { url: string; agents: McpAgentStatus[] };
+
+export type McpApplyRequest = { add: AgentId[]; remove: AgentId[] };
+
+// Per agent: written, taken out, or left as it was with the reason.
+export type McpApplyResult = {
+ added: AgentId[];
+ removed: AgentId[];
+ failures: { id: AgentId; error: string }[];
+};
+
+// Where the `dapi` command stands. `managed` means what is there is a
+// symlink (the app's own, or the dev workflow's Homebrew link), which
+// "Uninstall" can remove; `available` that this build can create the app's
+// link (a dev build cannot: that is `npm run symlink:create`).
+export type CliStatus = {
+ installed: boolean;
+ path: string | null;
+ managed: boolean;
+ available: boolean;
+};
+
+// Outcome of linking the bundled dapi CLI into PATH. "cancelled" means the
+// user dismissed the macOS admin prompt — not an error, not installed.
+export type CliInstallResult =
+ | { status: "installed" }
+ | { status: "cancelled" }
+ | { status: "error"; error: string };
+
+// Outcome of taking the symlink back out. "absent" means there was none to
+// remove; "cancelled" that the admin prompt was dismissed and it stays.
+export type CliUninstallResult =
+ | { status: "removed" }
+ | { status: "absent" }
+ | { status: "cancelled" }
+ | { status: "error"; error: string };
export type MainChannel = (typeof MAIN_CHANNELS)[keyof typeof MAIN_CHANNELS];
@@ -250,6 +309,14 @@ export type MainRequestMap = {
request: void;
response: { url: string } | null;
};
+ // The app's MCP server in the agents' configs (see mcp-install.ts), and
+ // the `dapi` command on PATH (see cli-install.ts). The install/uninstall
+ // calls put the macOS admin prompt on screen.
+ [MAIN_CHANNELS.MCP_STATUS]: { request: void; response: McpStatus };
+ [MAIN_CHANNELS.MCP_APPLY]: { request: McpApplyRequest; response: McpApplyResult };
+ [MAIN_CHANNELS.CLI_STATUS]: { request: void; response: CliStatus };
+ [MAIN_CHANNELS.CLI_INSTALL]: { request: void; response: CliInstallResult };
+ [MAIN_CHANNELS.CLI_UNINSTALL]: { request: void; response: CliUninstallResult };
};
export type FsEntry = {
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index 1ae0fc48..90d1de41 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -11,6 +11,8 @@ import type { FileHandle } from "node:fs/promises";
import { updateElectronApp } from "update-electron-app";
import { DapiServer } from "./dapi/server";
import { agentChatEndpoint, deleteProjectChats, startAgentChat, stopAgentChat } from "./agent-chat";
+import { cliStatus, installCli, uninstallCli } from "./cli-install";
+import { applyMcp, healMcpRegistrations, mcpStatus } from "./mcp-install";
import { enableHeadless } from "./headless";
import { pruneLegacySkills } from "./skills-cleanup";
import { trackInstall } from "./analytics";
@@ -298,6 +300,11 @@ if (app.requestSingleInstanceLock()) {
});
mainBridge.handle(MAIN_CHANNELS.LOGS_GET, () => logBuffer);
mainBridge.handle(MAIN_CHANNELS.AGENT_CHAT_ENDPOINT, () => agentChatEndpoint());
+ mainBridge.handle(MAIN_CHANNELS.MCP_STATUS, () => mcpStatus());
+ mainBridge.handle(MAIN_CHANNELS.MCP_APPLY, (request) => applyMcp(request));
+ mainBridge.handle(MAIN_CHANNELS.CLI_STATUS, () => cliStatus());
+ mainBridge.handle(MAIN_CHANNELS.CLI_INSTALL, () => installCli());
+ mainBridge.handle(MAIN_CHANNELS.CLI_UNINSTALL, () => uninstallCli());
mainBridge.handle(MAIN_CHANNELS.PROJECTS_PICK_ROOT, () => pickRoot(mainWindow));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_PICK_FOLDER, () => pickFolder(mainWindow));
mainBridge.handle(MAIN_CHANNELS.PROJECTS_DEFAULT_ROOT, () => defaultRoot(mainWindow));
@@ -390,6 +397,7 @@ if (app.requestSingleInstanceLock()) {
}),
);
pruneLegacySkills();
+ healMcpRegistrations();
trackInstall();
createWindow(!isHiddenLaunch(process.argv));
});
diff --git a/apps/desktop/src/mcp-config.test.ts b/apps/desktop/src/mcp-config.test.ts
new file mode 100644
index 00000000..8c4b357d
--- /dev/null
+++ b/apps/desktop/src/mcp-config.test.ts
@@ -0,0 +1,154 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import { describe, expect, it } from "vitest";
+import { AGENT_TARGETS, agentTarget, needsBinary, readServer, removeServer, upsertServer } from "./mcp-config";
+
+const spec = {
+ url: "http://127.0.0.1:3274/mcp",
+ command: "/Applications/Diffusion Studio.app/Contents/Resources/cli/bin/dapi",
+ args: ["mcp"],
+};
+
+describe("per-agent entries", () => {
+ it("spells the URL the way each agent expects", () => {
+ expect(agentTarget("claude-code").entry(spec)).toEqual({ type: "http", url: spec.url });
+ expect(agentTarget("cursor").entry(spec)).toEqual({ url: spec.url });
+ expect(agentTarget("vscode").entry(spec)).toEqual({ type: "http", url: spec.url });
+ expect(agentTarget("codex").entry(spec)).toEqual({ url: spec.url });
+ expect(agentTarget("antigravity").entry(spec)).toEqual({ serverUrl: spec.url });
+ expect(agentTarget("gemini-cli").entry(spec)).toEqual({ httpUrl: spec.url });
+ expect(agentTarget("windsurf").entry(spec)).toEqual({ serverUrl: spec.url });
+ });
+
+ it("gives Claude Desktop the stdio proxy, and nobody else", () => {
+ expect(agentTarget("claude-desktop").entry(spec)).toEqual({ command: spec.command, args: ["mcp"] });
+ expect(AGENT_TARGETS.filter(needsBinary).map((t) => t.id)).toEqual(["claude-desktop"]);
+ });
+
+ it("has a unique id per agent", () => {
+ expect(new Set(AGENT_TARGETS.map((t) => t.id)).size).toBe(AGENT_TARGETS.length);
+ });
+});
+
+describe("json configs", () => {
+ it("creates the file from nothing", () => {
+ const text = upsertServer(null, "mcpServers", { type: "http", url: spec.url });
+ expect(JSON.parse(text)).toEqual({ mcpServers: { diffusion: { type: "http", url: spec.url } } });
+ expect(text.endsWith("\n")).toBe(true);
+ });
+
+ it("uses VS Code's root key", () => {
+ const text = upsertServer(null, "servers", { type: "http", url: spec.url });
+ expect(JSON.parse(text)).toEqual({ servers: { diffusion: { type: "http", url: spec.url } } });
+ expect(readServer(text, "servers")).toEqual({ url: spec.url });
+ // The same file read under the other root key has nothing of ours.
+ expect(readServer(text, "mcpServers")).toBeNull();
+ });
+
+ it("keeps other servers and unrelated keys", () => {
+ const before = JSON.stringify({
+ numStartups: 12,
+ mcpServers: { other: { command: "x", args: [] } },
+ projects: { "/a": { allowedTools: [] } },
+ });
+ const after = JSON.parse(upsertServer(before, "mcpServers", { url: spec.url }));
+ expect(after.numStartups).toBe(12);
+ expect(after.projects).toEqual({ "/a": { allowedTools: [] } });
+ expect(after.mcpServers.other).toEqual({ command: "x", args: [] });
+ expect(after.mcpServers.diffusion).toEqual({ url: spec.url });
+ });
+
+ it("replaces a stdio entry with a URL entry, and reads either", () => {
+ const before = upsertServer(null, "mcpServers", { command: "/old/dapi", args: ["mcp"] });
+ expect(readServer(before, "mcpServers")).toEqual({ command: "/old/dapi" });
+ const after = upsertServer(before, "mcpServers", { type: "http", url: spec.url });
+ expect(readServer(after, "mcpServers")).toEqual({ url: spec.url });
+ expect(JSON.parse(after).mcpServers.diffusion.command).toBeUndefined();
+ });
+
+ it("reads the URL under each agent's key", () => {
+ for (const key of ["url", "httpUrl", "serverUrl"]) {
+ expect(readServer(upsertServer(null, "mcpServers", { [key]: spec.url }), "mcpServers")).toEqual({ url: spec.url });
+ }
+ });
+
+ it("refuses to overwrite a file it cannot parse", () => {
+ expect(() => upsertServer("{ not json", "mcpServers", { url: spec.url })).toThrow();
+ expect(() => upsertServer("[1, 2]", "mcpServers", { url: spec.url })).toThrow();
+ expect(readServer("{ not json", "mcpServers")).toBeNull();
+ });
+
+ it("treats an empty file as no config", () => {
+ expect(readServer("", "mcpServers")).toBeNull();
+ expect(JSON.parse(upsertServer(" \n", "mcpServers", { url: spec.url }))).toEqual({ mcpServers: { diffusion: { url: spec.url } } });
+ });
+
+ it("removes our entry and nothing else", () => {
+ const before = JSON.stringify({
+ numStartups: 12,
+ mcpServers: { other: { command: "x", args: [] }, diffusion: { type: "http", url: spec.url } },
+ });
+ const after = removeServer(before, "mcpServers");
+ expect(after).not.toBeNull();
+ expect(JSON.parse(after as string)).toEqual({ numStartups: 12, mcpServers: { other: { command: "x", args: [] } } });
+ expect(readServer(after, "mcpServers")).toBeNull();
+ });
+
+ it("has nothing to remove from a config without our entry", () => {
+ expect(removeServer(null, "mcpServers")).toBeNull();
+ expect(removeServer("", "mcpServers")).toBeNull();
+ expect(removeServer(JSON.stringify({ mcpServers: { other: { url: "u" } } }), "mcpServers")).toBeNull();
+ expect(removeServer("{ not json", "mcpServers")).toBeNull();
+ });
+});
+
+describe("toml configs (codex)", () => {
+ it("appends a table to an existing config", () => {
+ const before = 'model = "o3"\n\n[mcp_servers.other]\ncommand = "x"\n';
+ const after = upsertServer(before, "toml", { url: spec.url });
+ expect(after).toBe('model = "o3"\n\n[mcp_servers.other]\ncommand = "x"\n\n[mcp_servers.diffusion]\nurl = "http://127.0.0.1:3274/mcp"\n');
+ expect(readServer(after, "toml")).toEqual({ url: spec.url });
+ });
+
+ it("replaces our table in place and leaves the next one alone", () => {
+ const before = '[mcp_servers.diffusion]\ncommand = "/old/dapi"\nargs = ["mcp"]\n\n[mcp_servers.other]\ncommand = "x"\n';
+ expect(readServer(before, "toml")).toEqual({ command: "/old/dapi" });
+ const after = upsertServer(before, "toml", { url: spec.url });
+ expect(after).toBe('[mcp_servers.diffusion]\nurl = "http://127.0.0.1:3274/mcp"\n[mcp_servers.other]\ncommand = "x"\n');
+ expect(readServer(after, "toml")).toEqual({ url: spec.url });
+ });
+
+ it("starts a file from nothing", () => {
+ const text = upsertServer(null, "toml", { url: spec.url });
+ expect(text).toBe('[mcp_servers.diffusion]\nurl = "http://127.0.0.1:3274/mcp"\n');
+ });
+
+ it("escapes quotes and backslashes in stdio paths", () => {
+ const odd = { command: 'C:\\Apps\\"Diffusion"\\dapi', args: ["mcp"] };
+ const text = upsertServer(null, "toml", odd);
+ expect(text).toContain('command = "C:\\\\Apps\\\\\\"Diffusion\\"\\\\dapi"');
+ expect(readServer(text, "toml")).toEqual({ command: odd.command });
+ });
+
+ it("reads nothing from a config without our table", () => {
+ expect(readServer('model = "o3"\n', "toml")).toBeNull();
+ expect(removeServer('model = "o3"\n', "toml")).toBeNull();
+ });
+
+ it("removes our table from the end of a config", () => {
+ const before = 'model = "o3"\n\n[mcp_servers.other]\ncommand = "x"\n';
+ const connected = upsertServer(before, "toml", { url: spec.url });
+ expect(removeServer(connected, "toml")).toBe(before);
+ });
+
+ it("removes our table from between others without leaving a gap", () => {
+ const before = 'model = "o3"\n\n[mcp_servers.diffusion]\nurl = "u"\n\n[mcp_servers.other]\ncommand = "x"\n';
+ expect(removeServer(before, "toml")).toBe('model = "o3"\n\n[mcp_servers.other]\ncommand = "x"\n');
+ });
+
+ it("empties a config that held only our table", () => {
+ expect(removeServer(upsertServer(null, "toml", { url: spec.url }), "toml")).toBe("");
+ });
+});
diff --git a/apps/desktop/src/mcp-config.ts b/apps/desktop/src/mcp-config.ts
new file mode 100644
index 00000000..dfdaa4bc
--- /dev/null
+++ b/apps/desktop/src/mcp-config.ts
@@ -0,0 +1,236 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// How the app's MCP server is written into each agent's config, as pure
+// text transforms: no file system, no Electron, so the merge rules are
+// testable. `mcp-install.ts` decides which files and does the I/O.
+
+/**
+ * The two ways to reach the app. Agents that speak Streamable HTTP get the
+ * URL, which is the same on every machine; the rest get the bundled `dapi`
+ * binary in stdio proxy mode.
+ */
+export type McpServerSpec = { url: string; command: string; args: string[] };
+
+/**
+ * The key our entry lives under in every agent's server map, and so the
+ * namespace an agent shows us under: `mcp__diffusion__<tool>` and
+ * `/diffusion:<prompt>`. The same word as our URL scheme, and not `dapi`,
+ * which is the CLI.
+ */
+export const SERVER_NAME = "diffusion";
+
+/** One agent's config entry: what its file format spells a server as. */
+export type ServerEntry = Record<string, string | string[]>;
+
+/** The stable id an agent is addressed by over IPC and in the UI. */
+export type AgentId =
+ | "claude-code"
+ | "claude-desktop"
+ | "cursor"
+ | "vscode"
+ | "codex"
+ | "antigravity"
+ | "gemini-cli"
+ | "windsurf";
+
+/** How a config file spells its server map: JSON under `mcpServers` (or VS Code's `servers`), or Codex's TOML tables. */
+export type ConfigFormat = "mcpServers" | "servers" | "toml";
+
+export type AgentTarget = {
+ id: AgentId;
+ /** Human name, for the UI. */
+ label: string;
+ /** Home-relative path whose presence means the agent is set up on this machine. */
+ marker: string;
+ /** Home-relative path of the config file our entry goes into. */
+ config: string;
+ format: ConfigFormat;
+ /** The entry for this agent: which transport it gets, under the keys its format uses. */
+ entry(spec: McpServerSpec): ServerEntry;
+};
+
+const http = (key: string, extra: ServerEntry = {}) => (spec: McpServerSpec): ServerEntry => ({ ...extra, [key]: spec.url });
+const stdio = (spec: McpServerSpec): ServerEntry => ({ command: spec.command, args: [...spec.args] });
+
+/** Where macOS apps keep their per-user files; agents that are desktop apps put their config there. */
+const APP_SUPPORT = "Library/Application Support";
+
+// Agents whose MCP config we know how to write, in the order the UI lists
+// them. Claude Code's user scope is the top-level `mcpServers` of
+// ~/.claude.json, the same file `claude mcp add --scope user` edits. VS Code
+// keeps its user-level servers under `servers` in the profile's mcp.json.
+// Antigravity shares one config across its IDE and CLI, and only accepts
+// `serverUrl`. Claude Desktop's file takes stdio commands only, so it gets
+// the proxy.
+export const AGENT_TARGETS: readonly AgentTarget[] = [
+ { id: "claude-code", label: "Claude Code", marker: ".claude", config: ".claude.json", format: "mcpServers", entry: http("url", { type: "http" }) },
+ {
+ id: "claude-desktop",
+ label: "Claude Desktop",
+ marker: `${APP_SUPPORT}/Claude`,
+ config: `${APP_SUPPORT}/Claude/claude_desktop_config.json`,
+ format: "mcpServers",
+ entry: stdio,
+ },
+ { id: "cursor", label: "Cursor", marker: ".cursor", config: ".cursor/mcp.json", format: "mcpServers", entry: http("url") },
+ {
+ id: "vscode",
+ label: "VS Code (Copilot)",
+ marker: `${APP_SUPPORT}/Code`,
+ config: `${APP_SUPPORT}/Code/User/mcp.json`,
+ format: "servers",
+ entry: http("url", { type: "http" }),
+ },
+ { id: "codex", label: "Codex", marker: ".codex", config: ".codex/config.toml", format: "toml", entry: http("url") },
+ { id: "antigravity", label: "Antigravity", marker: ".gemini/antigravity", config: ".gemini/config/mcp_config.json", format: "mcpServers", entry: http("serverUrl") },
+ { id: "gemini-cli", label: "Gemini CLI", marker: ".gemini", config: ".gemini/settings.json", format: "mcpServers", entry: http("httpUrl") },
+ { id: "windsurf", label: "Windsurf", marker: ".codeium/windsurf", config: ".codeium/windsurf/mcp_config.json", format: "mcpServers", entry: http("serverUrl") },
+];
+
+export function agentTarget(id: AgentId): AgentTarget {
+ const target = AGENT_TARGETS.find((candidate) => candidate.id === id);
+ if (!target) throw new Error(`Unknown agent: ${id}`);
+ return target;
+}
+
+/** Whether the agent runs our entry over stdio, and so needs the `dapi` binary. */
+export function needsBinary(target: AgentTarget): boolean {
+ return "command" in target.entry({ url: "http://x", command: "x", args: [] });
+}
+
+/**
+ * The config with our entry set, leaving everything else as it was. `text`
+ * is the file's current content, or null when there is none yet. Throws
+ * when the file cannot be parsed: a config we cannot read is not one we
+ * should overwrite.
+ */
+export function upsertServer(text: string | null, format: ConfigFormat, entry: ServerEntry): string {
+ return format === "toml" ? upsertToml(text, entry) : upsertJson(text, format, entry);
+}
+
+/**
+ * The config with our entry taken out, everything else untouched; null when
+ * the file has no entry of ours (or cannot be parsed), so there is nothing
+ * to write back. Other servers and unrelated keys stay as they were.
+ */
+export function removeServer(text: string | null, format: ConfigFormat): string | null {
+ if (readServer(text, format) === null) return null;
+ return format === "toml" ? removeToml(text as string) : removeJson(text as string, format);
+}
+
+/** Where our entry currently points, whatever keys the agent spells it with; null when there is none. */
+export type Registered = { url?: string; command?: string };
+
+export function readServer(text: string | null, format: ConfigFormat): Registered | null {
+ if (text === null) return null;
+ const entry = format === "toml" ? readToml(text) : readJson(text, format);
+ if (!entry) return null;
+ const url = entry.url ?? entry.httpUrl ?? entry.serverUrl;
+ const command = entry.command;
+ if (typeof url !== "string" && typeof command !== "string") return null;
+ return {
+ ...(typeof url === "string" ? { url } : {}),
+ ...(typeof command === "string" ? { command } : {}),
+ };
+}
+
+// --- JSON ------------------------------------------------------------------
+
+type JsonFormat = Exclude<ConfigFormat, "toml">;
+type JsonConfig = Record<string, unknown>;
+
+function parseJson(text: string | null): JsonConfig {
+ if (text === null || text.trim() === "") return {};
+ const parsed: unknown = JSON.parse(text);
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
+ throw new Error("expected a JSON object at the top level");
+ }
+ return parsed as JsonConfig;
+}
+
+function serverMap(config: JsonConfig, root: JsonFormat): Record<string, unknown> {
+ const servers = config[root];
+ return typeof servers === "object" && servers !== null && !Array.isArray(servers)
+ ? (servers as Record<string, unknown>)
+ : {};
+}
+
+function upsertJson(text: string | null, root: JsonFormat, entry: ServerEntry): string {
+ const config = parseJson(text);
+ config[root] = { ...serverMap(config, root), [SERVER_NAME]: entry };
+ return `${JSON.stringify(config, null, 2)}\n`;
+}
+
+function removeJson(text: string, root: JsonFormat): string {
+ const config = parseJson(text);
+ const { [SERVER_NAME]: _ours, ...servers } = serverMap(config, root);
+ config[root] = servers;
+ return `${JSON.stringify(config, null, 2)}\n`;
+}
+
+function readJson(text: string, root: JsonFormat): Record<string, unknown> | null {
+ let config: JsonConfig;
+ try {
+ config = parseJson(text);
+ } catch {
+ return null;
+ }
+ const entry = serverMap(config, root)[SERVER_NAME];
+ return typeof entry === "object" && entry !== null ? (entry as Record<string, unknown>) : null;
+}
+
+// --- TOML (Codex) ----------------------------------------------------------
+
+// Our table, from its header up to the next table header or the end. A
+// header line is `[...]` at column 0; indented or commented ones are not.
+const TOML_TABLE = new RegExp(String.raw`^\[mcp_servers\.${SERVER_NAME}\][^\n]*\n(?:(?!\[)[^\n]*\n?)*`, "m");
+
+function tomlString(value: string): string {
+ return `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
+}
+
+function tomlValue(value: string | string[]): string {
+ return Array.isArray(value) ? `[${value.map(tomlString).join(", ")}]` : tomlString(value);
+}
+
+function tomlTable(entry: ServerEntry): string {
+ const lines = Object.entries(entry).map(([key, value]) => `${key} = ${tomlValue(value)}`);
+ return [`[mcp_servers.${SERVER_NAME}]`, ...lines, ""].join("\n");
+}
+
+function upsertToml(text: string | null, entry: ServerEntry): string {
+ const current = text ?? "";
+ const table = tomlTable(entry);
+ if (TOML_TABLE.test(current)) return current.replace(TOML_TABLE, table);
+ const separator = current === "" || current.endsWith("\n\n") ? "" : current.endsWith("\n") ? "\n" : "\n\n";
+ return `${current}${separator}${table}`;
+}
+
+// Drops our table, then the blank lines it used to sit between so the file
+// does not end in (or contain) a growing gap after a connect/disconnect cycle.
+function removeToml(text: string): string {
+ const rest = text.replace(TOML_TABLE, "").replace(/\n{3,}/g, "\n\n").trimEnd();
+ return rest === "" ? "" : `${rest}\n`;
+}
+
+function readToml(text: string): Record<string, unknown> | null {
+ const table = text.match(TOML_TABLE)?.[0];
+ if (!table) return null;
+ const entry: Record<string, unknown> = {};
+ for (const line of table.split("\n").slice(1)) {
+ const scalar = line.match(/^(\w+)\s*=\s*"((?:[^"\\]|\\.)*)"\s*$/);
+ if (scalar) {
+ entry[scalar[1]] = untomlString(scalar[2]);
+ continue;
+ }
+ const list = line.match(/^(\w+)\s*=\s*\[([^\]]*)\]\s*$/);
+ if (list) entry[list[1]] = [...list[2].matchAll(/"((?:[^"\\]|\\.)*)"/g)].map((m) => untomlString(m[1]));
+ }
+ return entry;
+}
+
+function untomlString(value: string): string {
+ return value.replaceAll('\\"', '"').replaceAll("\\\\", "\\");
+}
diff --git a/apps/desktop/src/mcp-install.ts b/apps/desktop/src/mcp-install.ts
new file mode 100644
index 00000000..c9087ec3
--- /dev/null
+++ b/apps/desktop/src/mcp-install.ts
@@ -0,0 +1,147 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Registers the app's MCP server with the agents on this machine, one agent
+// at a time as the settings page asks: the fixed loopback URL for agents
+// that speak HTTP, the bundled `dapi mcp` proxy for the rest. No PATH
+// symlink and no admin prompt — that is `cli-install.ts`, for people who
+// type `dapi`.
+
+import { app } from "electron";
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import { homedir } from "node:os";
+import { dirname, join } from "node:path";
+import { MCP_URL } from "@diffusionstudio/dapi";
+import { AGENT_TARGETS, agentTarget, needsBinary, readServer, removeServer, upsertServer } from "./mcp-config";
+
+import type { AgentTarget, McpServerSpec } from "./mcp-config";
+import type { McpAgentStatus, McpApplyRequest, McpApplyResult, McpStatus } from "./main-channels";
+
+// The dev workflow links the workspace build into Homebrew's bin
+// (`symlink:create` in apps/cli); that is the binary a dev build registers.
+const DEV_BINARY = "/opt/homebrew/bin/dapi";
+
+/** The bundled `dapi` binary, or null when none is available (an unstaged dev build). */
+export function dapiBinary(): string | null {
+ const command = app.isPackaged ? join(process.resourcesPath, "cli", "bin", "dapi") : DEV_BINARY;
+ return existsSync(command) ? command : null;
+}
+
+function spec(): McpServerSpec {
+ return { url: MCP_URL, command: dapiBinary() ?? "", args: ["mcp"] };
+}
+
+function configPath(target: AgentTarget): string {
+ return join(homedir(), target.config);
+}
+
+function readConfig(target: AgentTarget): string | null {
+ const path = configPath(target);
+ return existsSync(path) ? readFileSync(path, "utf8") : null;
+}
+
+function writeConfig(target: AgentTarget, text: string): void {
+ const path = configPath(target);
+ mkdirSync(dirname(path), { recursive: true });
+ writeFileSync(path, text);
+}
+
+/**
+ * Why this agent cannot be connected from this build, or null when it can.
+ * Only the stdio agents have reasons: a build without the `dapi` binary has
+ * nothing for them to run, and a quarantined first launch runs from a
+ * translocated read-only mount whose path won't survive the next launch —
+ * registering it would dangle.
+ */
+function unavailableReason(target: AgentTarget, current: McpServerSpec): string | null {
+ if (!needsBinary(target)) return null;
+ if (current.command === "") return "Needs the dapi command line tool, which this build does not include.";
+ if (app.isPackaged && current.command.includes("/AppTranslocation/")) {
+ return "Move Diffusion Studio to the Applications folder and relaunch it first.";
+ }
+ return null;
+}
+
+function agentStatus(target: AgentTarget, current: McpServerSpec): McpAgentStatus {
+ const registered = readServer(readConfig(target), target.format);
+ return {
+ id: target.id,
+ label: target.label,
+ detected: existsSync(join(homedir(), target.marker)),
+ connected: registered !== null,
+ config: configPath(target),
+ unavailable: unavailableReason(target, current),
+ };
+}
+
+/** Every agent we know, with whether it is on this machine and whether its config carries our entry. */
+export function mcpStatus(): McpStatus {
+ const current = spec();
+ return { url: current.url, agents: AGENT_TARGETS.map((target) => agentStatus(target, current)) };
+}
+
+/**
+ * Writes our entry into the configs of `add` and takes it out of the configs
+ * of `remove`, one file at a time, so one unreadable config does not stop
+ * the rest. Other servers in the same file are left alone either way.
+ */
+export function applyMcp(request: McpApplyRequest): McpApplyResult {
+ const current = spec();
+ const result: McpApplyResult = { added: [], removed: [], failures: [] };
+
+ for (const id of request.add) {
+ const target = agentTarget(id);
+ const reason = unavailableReason(target, current);
+ if (reason) {
+ result.failures.push({ id, error: reason });
+ continue;
+ }
+ try {
+ writeConfig(target, upsertServer(readConfig(target), target.format, target.entry(current)));
+ result.added.push(id);
+ } catch (e) {
+ result.failures.push({ id, error: `${target.config}: ${(e as Error).message}` });
+ }
+ }
+
+ for (const id of request.remove) {
+ const target = agentTarget(id);
+ try {
+ const next = removeServer(readConfig(target), target.format);
+ if (next !== null) writeConfig(target, next);
+ result.removed.push(id);
+ } catch (e) {
+ result.failures.push({ id, error: `${target.config}: ${(e as Error).message}` });
+ }
+ }
+
+ return result;
+}
+
+/**
+ * Launch-time self-heal for the stdio agents: an entry that still runs the
+ * proxy from a bundle that moved (or was translocated when it was written)
+ * is rewritten to the binary this build has. Entries the user wrote by hand
+ * for something else are left alone.
+ */
+export function healMcpRegistrations(): void {
+ if (!app.isPackaged) return;
+ const current = spec();
+ if (current.command === "" || current.command.includes("/AppTranslocation/")) return;
+
+ for (const target of AGENT_TARGETS) {
+ const text = readConfig(target);
+ const registered = readServer(text, target.format);
+ if (!registered?.command) continue;
+ const ours = registered.command.includes("Diffusion Studio") || registered.command.includes("/AppTranslocation/");
+ if (!ours) continue;
+ const entry = target.entry(current);
+ if (registered.command === entry.command) continue;
+ try {
+ writeConfig(target, upsertServer(text, target.format, entry));
+ } catch {
+ // best effort — the settings page remains as a manual fix
+ }
+ }
+}
diff --git a/apps/web/src/assets/icons/agent-cursor.svg b/apps/web/src/assets/icons/agent-cursor.svg
new file mode 100644
index 00000000..d3e06be2
--- /dev/null
+++ b/apps/web/src/assets/icons/agent-cursor.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(5 5) scale(0.583333)" fill="currentColor" fill-rule="evenodd">
+<path d="M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"></path>
+</g>
+</svg>
diff --git a/apps/web/src/assets/icons/ai-mcp-cli.svg b/apps/web/src/assets/icons/ai-mcp-cli.svg
new file mode 100644
index 00000000..fc4066a4
--- /dev/null
+++ b/apps/web/src/assets/icons/ai-mcp-cli.svg
@@ -0,0 +1,3 @@
+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M16.7459 8.9822C17.7929 10.0294 17.7928 11.7273 16.7459 12.7746L12.5032 17.0173C12.2726 17.2479 12.2727 17.622 12.5032 17.8528L13.2753 18.6248C13.4702 18.82 13.4701 19.1367 13.2753 19.3319C13.0801 19.5271 12.7634 19.527 12.5681 19.3319L11.7961 18.5599C11.1751 17.9386 11.1749 16.9314 11.7961 16.3101L16.0388 12.0675C16.6952 11.4108 16.6952 10.346 16.0388 9.68931C15.3821 9.03268 14.3174 9.03283 13.6606 9.68931L10.1893 13.1606C10.0673 13.2826 9.89726 13.3285 9.73972 13.298C9.67674 13.2858 9.61559 13.2614 9.56018 13.2248C9.53235 13.2065 9.50595 13.1844 9.48146 13.1599C9.37064 13.0488 9.32521 12.8988 9.34059 12.7539C9.34548 12.7081 9.35415 12.6625 9.37166 12.6192C9.38393 12.5889 9.39944 12.5595 9.41793 12.5315C9.43618 12.504 9.45715 12.4771 9.48146 12.4528L12.9528 8.98151C13.6093 8.3247 13.6095 7.26001 12.9528 6.60331C12.296 5.94704 11.2312 5.94696 10.5746 6.60331L5.56061 11.6173C5.36534 11.8125 5.04876 11.8125 4.8535 11.6173C4.65853 11.422 4.65834 11.1053 4.8535 10.9102L9.86747 5.89621C10.9147 4.84933 12.6126 4.84941 13.6599 5.89621C14.2967 6.53303 14.5433 7.41035 14.4057 8.23574C15.2312 8.09786 16.1089 8.34526 16.7459 8.9822ZM15.2032 10.5249C15.3984 10.7201 15.3984 11.0367 15.2032 11.232L11.7319 14.7033C10.6846 15.7505 8.98679 15.7506 7.93949 14.7033C6.89243 13.656 6.89232 11.9581 7.93949 10.9109L11.4108 7.43955C11.606 7.24445 11.9227 7.24443 12.1179 7.43955C12.3131 7.63477 12.313 7.95138 12.1179 8.14666L8.6466 11.618C7.98995 12.2747 7.99006 13.3394 8.6466 13.9962C9.30337 14.6529 10.368 14.6529 11.0248 13.9962L14.4961 10.5249C14.6913 10.3298 15.008 10.33 15.2032 10.5249Z" fill="currentColor"/>
+</svg>
diff --git a/apps/web/src/assets/icons/antigravity.svg b/apps/web/src/assets/icons/antigravity.svg
new file mode 100644
index 00000000..ee79e568
--- /dev/null
+++ b/apps/web/src/assets/icons/antigravity.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(5 5) scale(0.583333)" fill="currentColor" fill-rule="evenodd">
+<path d="M21.751 22.607c1.34 1.005 3.35.335 1.508-1.508C17.73 15.74 18.904 1 12.037 1 5.17 1 6.342 15.74.815 21.1c-2.01 2.009.167 2.511 1.507 1.506 5.192-3.517 4.857-9.714 9.715-9.714 4.857 0 4.522 6.197 9.714 9.715z"></path>
+</g>
+</svg>
diff --git a/apps/web/src/assets/icons/clipboard.svg b/apps/web/src/assets/icons/clipboard.svg
new file mode 100644
index 00000000..cd610c42
--- /dev/null
+++ b/apps/web/src/assets/icons/clipboard.svg
@@ -0,0 +1,3 @@
+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M9.27273 6.14286V5.07143H14.7273V6.14286H9.27273ZM9 4C8.54813 4 8.18182 4.35977 8.18182 4.80357V5.07143H7.63636C6.73262 5.07143 6 5.79097 6 6.67857V17.3929C6 18.2804 6.73262 19 7.63636 19H16.3636C17.2673 19 18 18.2804 18 17.3929V6.67857C18 5.79097 17.2673 5.07143 16.3636 5.07143H15.8182V4.80357C15.8182 4.35977 15.4519 4 15 4H9ZM15.8182 6.14286V6.41071C15.8182 6.85451 15.4519 7.21429 15 7.21429H9C8.54813 7.21429 8.18182 6.85451 8.18182 6.41071V6.14286H7.63636C7.33512 6.14286 7.09091 6.38271 7.09091 6.67857V17.3929C7.09091 17.6887 7.33512 17.9286 7.63636 17.9286H16.3636C16.6648 17.9286 16.9091 17.6887 16.9091 17.3929V6.67857C16.9091 6.38271 16.6648 6.14286 16.3636 6.14286H15.8182Z" fill="currentColor" />
+</svg>
diff --git a/apps/web/src/assets/icons/gemini-cli.svg b/apps/web/src/assets/icons/gemini-cli.svg
new file mode 100644
index 00000000..4845602e
--- /dev/null
+++ b/apps/web/src/assets/icons/gemini-cli.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(5 5) scale(0.583333)" fill="currentColor" fill-rule="evenodd">
+<path d="M16.793 10.358v3.867L7.236 18.82v-2.8l7.751-3.728-7.75-3.728V5.763l9.556 4.595z"></path><path clip-rule="evenodd" d="M19.608 0A4.392 4.392 0 0124 4.392v15.216A4.392 4.392 0 0119.608 24H4.392A4.392 4.392 0 010 19.608V4.392A4.392 4.392 0 014.392 0h15.216zM4.26 1.444A2.816 2.816 0 001.444 4.26v15.48a2.816 2.816 0 002.816 2.816h15.48a2.816 2.816 0 002.816-2.816V4.26a2.816 2.816 0 00-2.816-2.816H4.26z"></path>
+</g>
+</svg>
diff --git a/apps/web/src/assets/icons/github-copilot.svg b/apps/web/src/assets/icons/github-copilot.svg
new file mode 100644
index 00000000..0c65a9d9
--- /dev/null
+++ b/apps/web/src/assets/icons/github-copilot.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(5 5) scale(0.583333)" fill="currentColor" fill-rule="evenodd">
+<path d="M19.245 5.364c1.322 1.36 1.877 3.216 2.11 5.817.622 0 1.2.135 1.592.654l.73.964c.21.278.323.61.323.955v2.62c0 .339-.173.669-.453.868C20.239 19.602 16.157 21.5 12 21.5c-4.6 0-9.205-2.583-11.547-4.258-.28-.2-.452-.53-.453-.868v-2.62c0-.345.113-.679.321-.956l.73-.963c.392-.517.974-.654 1.593-.654l.029-.297c.25-2.446.81-4.213 2.082-5.52 2.461-2.54 5.71-2.851 7.146-2.864h.198c1.436.013 4.685.323 7.146 2.864zm-7.244 4.328c-.284 0-.613.016-.962.05-.123.447-.305.85-.57 1.108-1.05 1.023-2.316 1.18-2.994 1.18-.638 0-1.306-.13-1.851-.464-.516.165-1.012.403-1.044.996a65.882 65.882 0 00-.063 2.884l-.002.48c-.002.563-.005 1.126-.013 1.69.002.326.204.63.51.765 2.482 1.102 4.83 1.657 6.99 1.657 2.156 0 4.504-.555 6.985-1.657a.854.854 0 00.51-.766c.03-1.682.006-3.372-.076-5.053-.031-.596-.528-.83-1.046-.996-.546.333-1.212.464-1.85.464-.677 0-1.942-.157-2.993-1.18-.266-.258-.447-.661-.57-1.108-.32-.032-.64-.049-.96-.05zm-2.525 4.013c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zm5 0c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zM7.635 5.087c-1.05.102-1.935.438-2.385.906-.975 1.037-.765 3.668-.21 4.224.405.394 1.17.657 1.995.657h.09c.649-.013 1.785-.176 2.73-1.11.435-.41.705-1.433.675-2.47-.03-.834-.27-1.52-.63-1.813-.39-.336-1.275-.482-2.265-.394zm6.465.394c-.36.292-.6.98-.63 1.813-.03 1.037.24 2.06.675 2.47.968.957 2.136 1.104 2.776 1.11h.044c.825 0 1.59-.263 1.995-.657.555-.556.765-3.187-.21-4.224-.45-.468-1.335-.804-2.385-.906-.99-.088-1.875.058-2.265.394zM12 7.615c-.24 0-.525.015-.84.044.03.16.045.336.06.526l-.001.159a2.94 2.94 0 01-.014.25c.225-.022.425-.027.612-.028h.366c.187 0 .387.006.612.028-.015-.146-.015-.277-.015-.409.015-.19.03-.365.06-.526a9.29 9.29 0 00-.84-.044z"></path>
+</g>
+</svg>
diff --git a/apps/web/src/assets/icons/windsurf.svg b/apps/web/src/assets/icons/windsurf.svg
new file mode 100644
index 00000000..dffd0758
--- /dev/null
+++ b/apps/web/src/assets/icons/windsurf.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(5 5) scale(0.583333)" fill="currentColor" fill-rule="evenodd">
+<path clip-rule="evenodd" d="M23.78 5.004h-.228a2.187 2.187 0 00-2.18 2.196v4.912c0 .98-.804 1.775-1.76 1.775a1.818 1.818 0 01-1.472-.773L13.168 5.95a2.197 2.197 0 00-1.81-.95c-1.134 0-2.154.972-2.154 2.173v4.94c0 .98-.797 1.775-1.76 1.775-.57 0-1.136-.289-1.472-.773L.408 5.098C.282 4.918 0 5.007 0 5.228v4.284c0 .216.066.426.188.604l5.475 7.889c.324.466.8.812 1.351.938 1.377.316 2.645-.754 2.645-2.117V11.89c0-.98.787-1.775 1.76-1.775h.002c.586 0 1.135.288 1.472.773l4.972 7.163a2.15 2.15 0 001.81.95c1.158 0 2.151-.973 2.151-2.173v-4.939c0-.98.787-1.775 1.76-1.775h.194c.122 0 .22-.1.22-.222V5.225a.221.221 0 00-.22-.222z"></path>
+</g>
+</svg>
diff --git a/apps/web/src/components/dashboard/mcp-view.tsx b/apps/web/src/components/dashboard/mcp-view.tsx
new file mode 100644
index 00000000..316afa24
--- /dev/null
+++ b/apps/web/src/components/dashboard/mcp-view.tsx
@@ -0,0 +1,366 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import { For, Match, Show, Switch, createResource, createSignal } from "solid-js";
+import { toast } from "somoto";
+
+import { Button } from "@/components/ui/button";
+import { Icon } from "@/components/ui/icon";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
+import {
+ AGENT_ICONS,
+ applyMcp,
+ displayPath,
+ fetchCliStatus,
+ fetchMcpStatus,
+ installCli,
+ uninstallCli,
+ type AgentId,
+ type McpAgentStatus,
+} from "@/lib/mcp";
+import { isDesktop } from "@/projects";
+
+import {
+ DashboardDividedStack,
+ DashboardInfoActionRow,
+ DashboardScrollView,
+ DashboardSurfaceCard,
+ DashboardSurfaceSection,
+ DashboardTitledSection,
+} from "./shared";
+
+function DashboardCliSection() {
+ const [status, { refetch }] = createResource(fetchCliStatus);
+ const [busy, setBusy] = createSignal(false);
+
+ const description = () => {
+ const current = status();
+ if (!current) return "Checking...";
+ if (current.installed) return `Installed at ${current.path}`;
+ if (!current.available) return "Not installed. Available in the packaged app; in development, run npm run symlink:create.";
+ return "Not installed";
+ };
+
+ const handleInstall = async () => {
+ setBusy(true);
+ try {
+ const result = await installCli();
+ if (result.status === "installed") toast("CLI installed", { description: "Run dapi --help in a terminal to get started." });
+ if (result.status === "error") toast.error("Could not install the CLI", { description: result.error });
+ } catch (e) {
+ toast.error("Could not install the CLI", { description: (e as Error).message });
+ } finally {
+ setBusy(false);
+ void refetch();
+ }
+ };
+
+ const handleUninstall = async () => {
+ setBusy(true);
+ try {
+ const result = await uninstallCli();
+ if (result.status === "removed") toast("CLI uninstalled");
+ if (result.status === "error") toast.error("Could not uninstall the CLI", { description: result.error });
+ } catch (e) {
+ toast.error("Could not uninstall the CLI", { description: (e as Error).message });
+ } finally {
+ setBusy(false);
+ void refetch();
+ }
+ };
+
+ return (
+ <DashboardSurfaceSection
+ title="Command line"
+ description="With the CLI installed, agents can launch Diffusion Studio on their own, in the background if they like."
+ >
+ <DashboardInfoActionRow
+ title="dapi"
+ leading={<Icon name="command-slash" class="text-foreground" />}
+ description={description()}
+ action={
+ <Switch>
+ <Match when={!status()}>
+ <Button variant="secondary" disabled>
+ Install
+ </Button>
+ </Match>
+ <Match when={status()?.installed && status()?.managed}>
+ <Button variant="secondary" disabled={busy()} onClick={handleUninstall}>
+ Uninstall
+ </Button>
+ </Match>
+ <Match when={status()?.installed}>
+ <Tooltip>
+ <TooltipTrigger as={Button} variant="on">
+ Installed
+ </TooltipTrigger>
+ <TooltipContent>Not a link, so it is left alone.</TooltipContent>
+ </Tooltip>
+ </Match>
+ <Match when={status()?.available}>
+ <Button disabled={busy()} onClick={handleInstall}>
+ Install
+ </Button>
+ </Match>
+ <Match when={true}>
+ <Button variant="secondary" disabled>
+ Unavailable
+ </Button>
+ </Match>
+ </Switch>
+ }
+ />
+ </DashboardSurfaceSection>
+ );
+}
+
+// --- Agents ------------------------------------------------------------------
+
+type PendingChange = "add" | "remove";
+type Pending = Partial<Record<AgentId, PendingChange>>;
+
+type AgentRowProps = {
+ agent: McpAgentStatus;
+ pending: PendingChange | undefined;
+ onToggle: () => void;
+};
+
+function AgentRow(props: AgentRowProps) {
+ const description = () => {
+ const { agent } = props;
+ if (props.pending === "add") return <span class="text-primary">Will be added</span>;
+ if (props.pending === "remove") return <span class="text-destructive">Will be removed</span>;
+ if (agent.connected) return `Connected · ${displayPath(agent.config)}`;
+ if (agent.unavailable) return agent.unavailable;
+ if (!agent.detected) return "Not found on this Mac";
+ return "Not connected";
+ };
+
+ return (
+ <DashboardInfoActionRow
+ layout="inline"
+ title={props.agent.label}
+ leading={<Icon name={AGENT_ICONS[props.agent.id]} class="text-foreground" />}
+ description={description()}
+ action={
+ <Switch>
+ <Match when={props.pending}>
+ <Button variant="secondary" onClick={props.onToggle}>
+ Undo
+ </Button>
+ </Match>
+ <Match when={props.agent.connected}>
+ <Tooltip>
+ <TooltipTrigger
+ as={Button}
+ variant="ghost"
+ size="icon"
+ aria-label={`Remove from ${props.agent.label}`}
+ onClick={props.onToggle}
+ >
+ <Icon name="minus" />
+ </TooltipTrigger>
+ <TooltipContent>Remove from {props.agent.label}</TooltipContent>
+ </Tooltip>
+ </Match>
+ <Match when={true}>
+ <Tooltip>
+ <TooltipTrigger
+ as={Button}
+ variant="ghost"
+ size="icon"
+ aria-label={`Add to ${props.agent.label}`}
+ disabled={props.agent.unavailable !== null}
+ onClick={props.onToggle}
+ >
+ <Icon name="plus-add" />
+ </TooltipTrigger>
+ <TooltipContent>Add to {props.agent.label}</TooltipContent>
+ </Tooltip>
+ </Match>
+ </Switch>
+ }
+ />
+ );
+}
+
+function DashboardAgentsSection() {
+ const [status, { refetch }] = createResource(fetchMcpStatus);
+ const [pending, setPending] = createSignal<Pending>({});
+ const [saving, setSaving] = createSignal(false);
+
+ const ids = (change: PendingChange): AgentId[] =>
+ (Object.entries(pending()) as [AgentId, PendingChange][])
+ .filter(([, value]) => value === change)
+ .map(([id]) => id);
+ const toAdd = () => ids("add");
+ const toRemove = () => ids("remove");
+ const hasChanges = () => toAdd().length + toRemove().length > 0;
+
+ const summary = () => {
+ const parts = [
+ toAdd().length > 0 ? `${toAdd().length} to add` : null,
+ toRemove().length > 0 ? `${toRemove().length} to remove` : null,
+ ].filter((part): part is string => part !== null);
+ return parts.join(" · ");
+ };
+
+ const toggle = (agent: McpAgentStatus) => {
+ setPending((current) => {
+ const next = { ...current };
+ if (next[agent.id]) delete next[agent.id];
+ else next[agent.id] = agent.connected ? "remove" : "add";
+ return next;
+ });
+ };
+
+ const discard = () => setPending({});
+
+ const labelOf = (id: AgentId) => status()?.agents.find((agent) => agent.id === id)?.label ?? id;
+
+ const save = async () => {
+ if (!hasChanges() || saving()) return;
+ setSaving(true);
+ try {
+ const result = await applyMcp({ add: toAdd(), remove: toRemove() });
+
+ // Only what failed stays pending, so a retry is one click away.
+ setPending((current) => {
+ const next: Pending = {};
+ for (const failure of result.failures) {
+ const change = current[failure.id];
+ if (change) next[failure.id] = change;
+ }
+ return next;
+ });
+
+ const changed = result.added.length + result.removed.length;
+ if (result.failures.length > 0) {
+ toast.error(changed > 0 ? "Some agents could not be updated" : "Agents could not be updated", {
+ description: result.failures.map((failure) => `${labelOf(failure.id)}: ${failure.error}`).join("\n"),
+ });
+ } else {
+ toast("Agents updated", { description: "Restart the agent to pick up the change." });
+ }
+ } catch (e) {
+ toast.error("Could not update the agents", { description: (e as Error).message });
+ } finally {
+ setSaving(false);
+ void refetch();
+ }
+ };
+
+ return (
+ <DashboardTitledSection
+ title="Agents"
+ description="Adds Diffusion Studio as an MCP server to each agent's configuration, so the agent can inspect, generate, and edit your projects."
+ >
+ <DashboardSurfaceCard class="flex flex-col gap-3">
+ <Show
+ when={status()}
+ fallback={<p class="text-xs text-muted-foreground">Checking agents...</p>}
+ >
+ {(current) => (
+ <DashboardDividedStack>
+ <For each={current().agents}>
+ {(agent) => (
+ <AgentRow agent={agent} pending={pending()[agent.id]} onToggle={() => toggle(agent)} />
+ )}
+ </For>
+ </DashboardDividedStack>
+ )}
+ </Show>
+ </DashboardSurfaceCard>
+ <Show when={hasChanges()}>
+ <div class="flex items-center gap-2 px-2 pt-3">
+ <p class="min-w-0 flex-1 truncate text-xs text-muted-foreground">{summary()}</p>
+ <Button variant="ghost" disabled={saving()} onClick={discard}>
+ Discard
+ </Button>
+ <Button disabled={saving()} onClick={save}>
+ Save changes
+ </Button>
+ </div>
+ </Show>
+ </DashboardTitledSection>
+ );
+}
+
+// --- Any other agent ---------------------------------------------------------
+
+function DashboardEndpointSection() {
+ const [status] = createResource(fetchMcpStatus);
+
+ const copy = async () => {
+ const url = status()?.url;
+ if (!url) return;
+ try {
+ await navigator.clipboard.writeText(url);
+ toast("Copied!", { description: "The MCP endpoint has been copied to your clipboard." });
+ } catch (e) {
+ toast.error("Failed to copy", { description: (e as Error).message });
+ }
+ };
+
+ return (
+ <DashboardSurfaceSection title="Other agents">
+ <DashboardInfoActionRow
+ title="MCP endpoint"
+ description={
+ <>
+ Any agent that speaks Streamable HTTP can be pointed at{" "}
+ <span class="font-mono text-foreground">{status()?.url ?? "..."}</span> while the app is running.
+ </>
+ }
+ action={
+ <Tooltip>
+ <TooltipTrigger
+ as={Button}
+ variant="ghost"
+ size="icon"
+ aria-label="Copy the MCP endpoint"
+ disabled={!status()}
+ onClick={copy}
+ >
+ <Icon name="clipboard" />
+ </TooltipTrigger>
+ <TooltipContent>Copy</TooltipContent>
+ </Tooltip>
+ }
+ />
+ </DashboardSurfaceSection>
+ );
+}
+
+export function DashboardMcpView() {
+ return (
+ <DashboardScrollView>
+ <Show
+ when={isDesktop()}
+ fallback={
+ <DashboardSurfaceSection title="MCP & CLI">
+ <p class="text-xs text-muted-foreground">
+ Connecting coding agents and installing the command line tool is available in the desktop app.
+ </p>
+ </DashboardSurfaceSection>
+ }
+ >
+ <DashboardCliSection />
+ <DashboardAgentsSection />
+ <DashboardEndpointSection />
+ </Show>
+ <div class="px-2 pt-1 text-xs text-muted-foreground">
+ <span>Other agents can be connected by hand. </span>
+ <a
+ href="https://modelcontextprotocol.io/docs/2026-07-28/develop/connect-local-servers"
+ target="_blank"
+ class="text-primary hover:underline"
+ >
+ Learn more
+ </a>
+ </div>
+ </DashboardScrollView>
+ );
+}
diff --git a/apps/web/src/components/dashboard/shared.tsx b/apps/web/src/components/dashboard/shared.tsx
index 0b4f3d3d..21ec916d 100644
--- a/apps/web/src/components/dashboard/shared.tsx
+++ b/apps/web/src/components/dashboard/shared.tsx
@@ -60,6 +60,7 @@ export function DashboardSurfaceCard(props: DashboardSurfaceCardProps) {
type DashboardTitledSectionProps = {
title: string;
+ description?: string;
class?: string;
children: JSX.Element;
};
@@ -68,8 +69,13 @@ type DashboardTitledSectionProps = {
export function DashboardTitledSection(props: DashboardTitledSectionProps) {
return (
<section class={cx("flex flex-col", props.class)}>
- <div class={cx("flex h-9 items-center px-2 text-sm leading-5 font-450 text-foreground", props.class)}>
- {props.title}
+ <div class="p-2 gap-1 flex flex-col">
+ <span class={cx("flex items-center text-sm leading-5 font-450 text-foreground", props.class)}>
+ {props.title}
+ </span>
+ <Show when={props.description}>
+ <p class="pb-1 text-xs text-muted-foreground">{props.description}</p>
+ </Show>
</div>
{props.children}
</section>
@@ -78,13 +84,14 @@ export function DashboardTitledSection(props: DashboardTitledSectionProps) {
type DashboardSurfaceSectionProps = {
title: string;
+ description?: string;
class?: string;
children: JSX.Element;
};
export function DashboardSurfaceSection(props: DashboardSurfaceSectionProps) {
return (
- <DashboardTitledSection title={props.title} class={props.class}>
+ <DashboardTitledSection title={props.title} description={props.description} class={props.class}>
<DashboardSurfaceCard class="flex flex-col gap-3">
{props.children}
</DashboardSurfaceCard>
diff --git a/apps/web/src/components/dashboard/sidebar.tsx b/apps/web/src/components/dashboard/sidebar.tsx
index 72097d89..0a600ea5 100644
--- a/apps/web/src/components/dashboard/sidebar.tsx
+++ b/apps/web/src/components/dashboard/sidebar.tsx
@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { Show, type JSX } from "solid-js";
+import { Button } from "@/components/ui/button";
import { Icon } from "@/components/ui/icon";
import { useAuth } from "@/context/auth";
import { useAvatar } from "@/hooks/use-avatar";
@@ -76,6 +77,7 @@ export function DashboardSidebarTopSpacer() {
type DashboardSidebarNavProps = {
children: JSX.Element;
+ footer?: JSX.Element;
};
/** The scrolling middle of the sidebar: stacked sections, then empty space. */
@@ -84,6 +86,32 @@ export function DashboardSidebarNav(props: DashboardSidebarNavProps) {
<div class="flex min-h-0 flex-1 flex-col gap-2 px-3">
{props.children}
<div class="min-h-0 flex-1" />
+ {props.footer}
+ </div>
+ );
+}
+
+type DashboardSidebarConnectCardProps = {
+ onInstall: () => void;
+};
+
+/** The nudge towards the agent setup, shown until an agent is connected. */
+export function DashboardSidebarConnectCard(props: DashboardSidebarConnectCardProps) {
+ return (
+ <div class="flex w-full shrink-0 flex-col items-center gap-1 rounded-md bg-accent py-3">
+ <div class="flex w-full flex-col gap-3 px-3">
+ <div class="flex w-full flex-col gap-1">
+ <div class="flex w-full items-center pb-0.5">
+ <p class="min-w-0 flex-1 truncate text-xs font-450 text-foreground">Connect your agent</p>
+ </div>
+ <p class="w-full text-xs text-muted-foreground">
+ Edit your videos with coding agents like Claude Code, Codex, or Cursor.
+ </p>
+ </div>
+ <Button variant="secondary" class="w-full" onClick={props.onInstall}>
+ Install agent tools
+ </Button>
+ </div>
</div>
);
}
diff --git a/apps/web/src/components/dashboard/types.ts b/apps/web/src/components/dashboard/types.ts
index 29f35b7c..0a55e26e 100644
--- a/apps/web/src/components/dashboard/types.ts
+++ b/apps/web/src/components/dashboard/types.ts
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-export type DashboardView = "home" | "projects" | "templates" | "ai-credits" | "billing" | "account" | "settings" | "preferences" | "help";
+export type DashboardView = "home" | "projects" | "templates" | "ai-credits" | "billing" | "account" | "settings" | "mcp" | "preferences" | "help";
export type ProjectSortOption = | "last-viewed" | "alphabetical" | "date-created";
export type TemplateSourceOption = "official" | "custom";
export type TemplatePreviewKind = "landscape" | "portrait" | "square";
diff --git a/apps/web/src/lib/mcp.ts b/apps/web/src/lib/mcp.ts
new file mode 100644
index 00000000..5f67447a
--- /dev/null
+++ b/apps/web/src/lib/mcp.ts
@@ -0,0 +1,76 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// The renderer's view of the agent setup main keeps: which agents carry the
+// app's MCP entry, and whether `dapi` is on PATH. Desktop only — in the
+// browser there are no configs to write, and every call here says so by
+// resolving to null.
+
+import { createSignal } from "solid-js";
+
+import { MAIN_CHANNELS } from "@desktop/main-channels";
+import { mainBridge } from "@/lib/ipc";
+import { isDesktop } from "@/projects";
+
+import type {
+ AgentId,
+ CliInstallResult,
+ CliStatus,
+ CliUninstallResult,
+ McpApplyRequest,
+ McpApplyResult,
+ McpStatus,
+} from "@desktop/main-channels";
+
+export type { AgentId, McpAgentStatus, McpStatus, CliStatus } from "@desktop/main-channels";
+
+/** The icon each agent is drawn with, by the name in `assets/icons`. */
+export const AGENT_ICONS: Record<AgentId, string> = {
+ "claude-code": "claude-code",
+ "claude-desktop": "claude",
+ cursor: "agent-cursor",
+ vscode: "github-copilot",
+ codex: "codex",
+ antigravity: "antigravity",
+ "gemini-cli": "gemini-cli",
+ windsurf: "windsurf",
+};
+
+const [connectedAgents, setConnectedAgents] = createSignal<number | null>(null);
+
+/**
+ * How many agents carry the app's entry, as of the last status fetch; null
+ * until one has happened. What the sidebar's nudge card hides on, so it is
+ * kept here where every fetch can update it.
+ */
+export { connectedAgents };
+
+export async function fetchMcpStatus(): Promise<McpStatus | null> {
+ if (!isDesktop()) return null;
+ const status = await mainBridge.call(MAIN_CHANNELS.MCP_STATUS, undefined);
+ setConnectedAgents(status.agents.filter((agent) => agent.connected).length);
+ return status;
+}
+
+export function applyMcp(request: McpApplyRequest): Promise<McpApplyResult> {
+ return mainBridge.call(MAIN_CHANNELS.MCP_APPLY, request);
+}
+
+export async function fetchCliStatus(): Promise<CliStatus | null> {
+ if (!isDesktop()) return null;
+ return mainBridge.call(MAIN_CHANNELS.CLI_STATUS, undefined);
+}
+
+export function installCli(): Promise<CliInstallResult> {
+ return mainBridge.call(MAIN_CHANNELS.CLI_INSTALL, undefined);
+}
+
+export function uninstallCli(): Promise<CliUninstallResult> {
+ return mainBridge.call(MAIN_CHANNELS.CLI_UNINSTALL, undefined);
+}
+
+/** A config path with the home folder shortened, for the row under an agent. */
+export function displayPath(path: string): string {
+ return path.replace(/^\/Users\/[^/]+/, "~").replace(/^\/home\/[^/]+/, "~");
+}
diff --git a/apps/web/src/pages/dashboard.tsx b/apps/web/src/pages/dashboard.tsx
index fe07a3bc..0dd573a8 100644
--- a/apps/web/src/pages/dashboard.tsx
+++ b/apps/web/src/pages/dashboard.tsx
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { useSearchParams } from "@solidjs/router";
-import { Match, Show, Switch, createEffect, createSignal } from "solid-js";
+import { Match, Show, Switch, createEffect, createSignal, onMount } from "solid-js";
import { DashboardAccountView } from "@/components/dashboard/account-view";
import { DashboardAiCreditsView } from "@/components/dashboard/ai-credits-view";
@@ -11,9 +11,11 @@ import { DashboardBillingView } from "@/components/dashboard/billing-view";
import { DashboardGetDesktopApp } from "@/components/dashboard/get-desktop-app";
import { DashboardHelpView } from "@/components/dashboard/help-view";
import { DashboardHomeView } from "@/components/dashboard/home-view";
+import { DashboardMcpView } from "@/components/dashboard/mcp-view";
import { DashboardProjectsView } from "@/components/dashboard/projects-view";
import { DashboardSettingsView } from "@/components/dashboard/settings-view";
import {
+ DashboardSidebarConnectCard,
DashboardSidebarHeader,
DashboardSidebarItem,
DashboardSidebarNav,
@@ -23,6 +25,8 @@ import {
} from "@/components/dashboard/sidebar";
import { Separator } from "@/components/ui/separator";
import { useFullscreenState } from "@/hooks/use-fullscreen-state";
+import { connectedAgents, fetchMcpStatus } from "@/lib/mcp";
+import { isDesktop } from "@/projects";
import type { DashboardView } from "@/components/dashboard/types";
@@ -34,6 +38,7 @@ const DASHBOARD_VIEWS: readonly DashboardView[] = [
"billing",
"account",
"settings",
+ "mcp",
"preferences",
"help",
];
@@ -42,6 +47,7 @@ const DASHBOARD_VIEWS: readonly DashboardView[] = [
const SETTINGS_VIEWS: readonly DashboardView[] = [
"account",
"settings",
+ "mcp",
"ai-credits",
"billing",
"help",
@@ -66,14 +72,26 @@ export function DashboardPage() {
// Which navigation the sidebar shows. Landing on a settings view (deep link,
// reload) opens the settings navigation; the user row opens it by itself.
const [settingsNavOpen, setSettingsNavOpen] = createSignal(isSettingsView(view()));
+
createEffect(() => {
- if (isSettingsView(view())) setSettingsNavOpen(true);
+ if (isSettingsView(view())) {
+ setSettingsNavOpen(true);
+ }
});
const openProfile = () => {
setSettingsNavOpen(true);
setView("account");
};
+ const openAgentSetup = () => {
+ setSettingsNavOpen(true);
+ setView("mcp");
+ };
+
+ onMount(() => fetchMcpStatus().catch(() => { }));
+
+ const showConnectCard = () => isDesktop() && connectedAgents() === 0;
+
const backToDashboard = () => {
setSettingsNavOpen(false);
if (isSettingsView(view())) setView("home");
@@ -88,7 +106,13 @@ export function DashboardPage() {
<Show when={!settingsNavOpen()} fallback={<DashboardSidebarTopSpacer />}>
<DashboardSidebarHeader />
</Show>
- <DashboardSidebarNav>
+ <DashboardSidebarNav
+ footer={
+ <Show when={!settingsNavOpen() && showConnectCard()}>
+ <DashboardSidebarConnectCard onInstall={openAgentSetup} />
+ </Show>
+ }
+ >
<Show
when={settingsNavOpen()}
fallback={
@@ -104,6 +128,7 @@ export function DashboardPage() {
<DashboardSidebarSection title="Settings">
<DashboardSidebarItem active={view() === "account"} onClick={() => setView("account")} icon="user" label="Account" />
<DashboardSidebarItem active={view() === "settings"} onClick={() => setView("settings")} icon="settings" label="General" />
+ <DashboardSidebarItem active={view() === "mcp"} onClick={() => setView("mcp")} icon="ai-mcp-cli" label="MCP & CLI" />
<DashboardSidebarItem active={view() === "ai-credits"} onClick={() => setView("ai-credits")} icon="ai-generate" label="AI credits" />
<DashboardSidebarItem active={view() === "billing"} onClick={() => setView("billing")} icon="billing" label="Billing" />
<DashboardSidebarItem active={view() === "help"} onClick={() => setView("help")} icon="help" label="Help" />
@@ -135,6 +160,9 @@ export function DashboardPage() {
<Match when={view() === "settings"}>
<DashboardSettingsView />
</Match>
+ <Match when={view() === "mcp"}>
+ <DashboardMcpView />
+ </Match>
<Match when={view() === "help"}>
<DashboardHelpView />
</Match>