/** * Discover MCP servers already configured in the user's local agent * tooling — claude-code, cursor, goose, etc. — so the daemon can * surface them in the UI without making the user re-enter the same * credentials and URLs they already painstakingly configured for * one host. * * v1 is read-only discovery: we report what's there with source * attribution. Future v1.1 ships an "import to daemon" verb that * proxies the discovered server through the daemon's own /mcp * endpoint so every operator (cloud Acme, local agents) sees a * unified set without per-host config drift. * * Sources scanned (in priority order): * - ~/.claude.json (claude-code) — `mcpServers` top-level + nested * under `projects[].mcpServers`. Most users land here. * - ~/.cursor/mcp.json (cursor) — flat `mcpServers` map. * - ~/.config/goose/config.yaml (goose) — TOML/YAML hybrid; we * only handle the YAML form for now. * - ~/.codex/config.toml (codex) — `[mcp_servers.]` tables. * - any `.mcp.json` under the user's home that follows the * standard mcpServers shape. * * Each source contributes 0..N entries. Errors are caught + logged * (broken JSON, missing files, permission denied) — partial * discovery beats failing the whole listing on one bad file. */ interface DiscoveredMcp { /** Stable id within (source, scope, name) — for de-dupe and * cross-call identity (UI treat as React key). */ id: string; /** Where we found it. Lets the UI render a source badge. */ source: "claude-code" | "cursor" | "goose" | "codex" | "workspace"; /** "global" when the entry sits at the top level of the host's * config; "project:" when it's scoped to a single * workspace. claude-code in particular nests per-project. */ scope: string; /** The host's name for the entry (key in the mcpServers map). */ name: string; /** Wire transport — `stdio` (command + args) or `http` / `sse` (url). */ type: "stdio" | "http" | "sse" | "unknown"; /** stdio entries: argv to spawn. */ command?: string; args?: string[]; /** stdio entries: env injected into the child. */ env?: Record; /** http/sse entries: target URL. */ url?: string; /** http/sse entries: extra headers (Authorization, etc.). */ headers?: Record; /** Free-form tags from the source config — claude-code's project * scope is the most common. */ tags?: string[]; /** Reason field when `type === "unknown"` — surfaces why the * parser couldn't classify the entry (e.g. neither command nor * url present). */ parseNote?: string; } export type { DiscoveredMcp as D };