import type { Cli } from "../internals/clis.js"; import type { McpServer } from "./servers.js"; /** * Per-CLI MCP config RENDERING — turns aih's canonical {@link McpServer} blueprint * into the exact on-disk shape each tool reads. This is what lets `aih mcp --apply` * WRITE a correct config for tools that used to be guidance-only ("fallback"): the * server map is the same, but the per-tool field names / nesting differ, and writing * the wrong shape would be worse than emitting guidance. Shapes verified against each * tool's current docs: * - claude / cursor / kiro / kimi → the canonical `mcpServers` JSON aih already * emits (identity — byte-preserves the existing `.mcp.json` golden output); * - gemini → `mcpServers` `{command, args}` / `{httpUrl}` (~/.gemini/settings.json); * - windsurf→ `mcpServers` `{command, args}` / `{serverUrl}`; * - antigravity → `mcpServers` `{command, args}` / `{url}`; * - copilot → `servers` `{type, command, args}` / `{type:"http", url}` (.vscode/mcp.json); * - opencode→ `mcp` `{type:"local", command:[cmd, ...args], enabled}` / `{type:"remote", url, enabled}`; * - zed → `context_servers` `{command, args}` / `{url}`; * - codex → TOML `[mcp_servers."name"]` tables (see {@link mcpTomlBody}). * A stdio server's optional `env` rides along under each tool's env key (`env`, or * `environment` for OpenCode, or a `[mcp_servers.NAME.env]` sub-table for Codex); * http servers never carry env. Pure data transforms — no IO, no network. */ /** One tool-shaped MCP server entry (the value under the tool's server-map key). */ export type McpEntry = Record; /** Render one canonical server into `cli`'s entry shape. */ export declare function mcpEntryFor(cli: Cli, s: McpServer): McpEntry; /** Render the whole server map into `cli`'s server-map object (for JSON configs). */ export declare function mcpEntries(cli: Cli, servers: Record): Record; /** * Render the server map as Codex `config.toml` `[mcp_servers."name"]` tables (no * markers — {@link upsertTextBlock} wraps these in the aih-managed region). The * server NAME is always a quoted key so a dotted name (`awslabs.core-mcp-server`) * stays one table instead of splitting into nested tables. stdio → `command`/`args`; * http → `url` (Codex's streamable_http transport). */ export declare function mcpTomlBody(servers: Record): string; /** A tool whose MCP config lives outside the repo (a `~/home` or absolute path). */ export declare function isExternalMcp(configPath: string): boolean; /** Resolve a registry config path to an absolute one, expanding a leading `~`. */ export declare function mcpConfigAbs(home: string, configPath: string): string; /** Count direct `[mcp_servers.NAME]` server tables (ignores `.env`/sub-tables). */ export declare function tomlServerCount(raw: string): number; /** * The server names already defined as top-level `[mcp_servers.NAME]` tables in a * Codex config, IGNORING aih's own managed `scope` region (those are ours, replaced * each run). aih filters its blueprint against this set before writing: a second * `[mcp_servers.playwright]` when the user already has one is a TOML duplicate-table * PARSE ERROR — so the user's own servers always win and aih only adds what's absent. */ export declare function existingMcpTomlNames(existing: string, scope: string): Set; export declare function removeMcpTomlServers(existing: string, names: readonly string[]): string;