UNPKG

@builder.io/dev-tools

Version:

Builder.io Visual CMS Devtools

101 lines (100 loc) 3.49 kB
/** * Claude-Code-style management commands for `mcp.json` entries. * * Mirrors `claude mcp add|list|get|remove` semantics but persists to the * Builder MCP config files: * * - `--scope user` (default) → `~/.builder/mcp.json` * - `--scope project` → `<cwd>/mcp.json` * * Both paths are already loaded by `loadMCPConfig` in `mcp-local.ts` * (project overrides user), so entries written here automatically apply to * the next `builder code` session. * * Unlike `mcp-commands.ts` (which handles OAuth + remote sync), this module * is plain config: no probing, no auth flow, no network. The user supplies * everything via flags; we just validate and persist. */ export type McpScope = "user" | "project"; export type McpTransport = "http" | "sse" | "stdio"; export interface AddRemoteOptions { name: string; transport: "http" | "sse"; url: string; scope?: McpScope; headers?: Record<string, string>; } export interface AddStdioOptions { name: string; transport: "stdio"; command: string; args?: string[]; env?: Record<string, string>; scope?: McpScope; } export type AddOptions = AddRemoteOptions | AddStdioOptions; interface RemoteMcpEntry { type: "http" | "sse"; url: string; headers?: Record<string, string>; [key: string]: unknown; } interface StdioMcpEntry { command: string; args?: string[]; env?: Record<string, string>; [key: string]: unknown; } type McpEntry = RemoteMcpEntry | StdioMcpEntry; /** * Resolve the on-disk path for a given scope. Reads `process.cwd()` / * `homedir()` at call time so tests can chdir or override `$HOME` without * re-importing. */ export declare function mcpJsonPathForScope(scope: McpScope): string; /** * `builder mcp add` — write a new entry to the chosen scope's `mcp.json`. * * Refuses to overwrite an existing entry; the user should `remove` first. * This matches what `claude mcp add` does and keeps the command idempotent * from a "no surprises" standpoint. */ export declare function runMcpAdd(options: AddOptions): { scope: McpScope; path: string; name: string; entry: McpEntry; }; /** * `builder mcp list` — print all entries across both scopes. Project entries * shadow user entries with the same name (mirrors the loader's precedence in * `loadMCPConfig`). */ export declare function runMcpList(): void; /** * `builder mcp get <name>` — print the JSON entry. If `--scope` is given, * only that scope is consulted; otherwise project is checked first, then * user (matching loader precedence). */ export declare function runMcpGet(name: string, scope?: McpScope): void; /** * Toggle the `disabled` flag on an existing `mcp.json` entry. The `/mcp` * slash command's "Disable" / "Enable" actions wire through here; the next * `createLocalMCPClientManager` rebuild reads the flag and either skips the * transport entirely (when `disabled: true`) or reconnects normally. * * Returns the new state so callers can include it in their step emission. */ export declare function setMcpDisabled(name: string, scope: McpScope, disabled: boolean): { scope: McpScope; path: string; name: string; disabled: boolean; }; /** * `builder mcp remove <name>` — delete the entry from the chosen scope. * Defaults to `user` to mirror `add`; pass `--scope project` to drop from * `<cwd>/mcp.json`. */ export declare function runMcpRemove(name: string, scope?: McpScope): void; export {};