export type Platform = 'windows' | 'macos' | 'linux'; export interface McpServerSpec { command: string; args: string[]; env?: Record; } export interface McpHttpServerSpec { url: string; headers?: Record; } export interface McpServerVariants { windows?: Partial; macos?: Partial; linux?: Partial; /** HTTP MCP server — platform-independent, always included. */ http?: McpHttpServerSpec; /** Shared env merged into the platform-specific env. */ env?: Record; } export interface McpSecretSpec { /** Human-readable label shown in the prompt. Falls back to the KEY itself. */ label?: string; /** Issuance URL opened in the user's browser before the prompt. */ issuanceUrl?: string; } export interface McpConfig { servers: Record; /** * Per-platform default values for `{KEY}` placeholders. User-supplied * explicit flags (`--mcp-url`, `--mcp-client-path`) overrides defaults at substitution time. Keys * covered by a default for the current platform are excluded from * `requiredPlaceholders()` so init/mcp do not prompt for them. */ defaults?: Partial>>; /** * Keys that represent user-issued secrets (API tokens, etc). Interactive * `mswai mcp` prompts for these *even when a default exists*; the default * is treated as an issuance hint, not a real value. Each entry may carry an * `issuanceUrl` (opened in the browser) and a `label` (shown in the prompt). * Silent / non-TTY runs ignore this section and fall through to the existing * default-as-placeholder behavior. */ secrets?: Record; } /** * Read mcp.yaml from templates/mcp/. Missing or empty file is OK — returns * `{ servers: {} }` so init can no-op cleanly. * * Environment-specific URLs no longer come from forked yaml files; the * Unity client supplies them at invocation time via repeated `--mcp-var` * (MSW_MCP_URL / MSW_MCP_TOKEN / MSW_MAKER_MCP_PATH). The yaml's * `defaults` block carries prod URLs as fallback for end-user invocations * that pass no flags. */ export declare function loadMcpConfig(): McpConfig; /** * Expand Windows-style `%VAR%` references using `process.env`. We do this at * generation time rather than relying on cmd.exe to expand at launch — MCP * clients quote args before spawning, which prevents cmd.exe from seeing the * unquoted form it expects, so `%LOCALAPPDATA%\foo\bar with space\baz.bat` * arrives at the launcher unexpanded and breaks. Resolving here yields a * concrete absolute path that every MCP client handles uniformly. * * Unknown vars are left as-is (e.g. `%LOCALAPPDATA%` on macOS where it isn't * set) so platform-specific defaults are not silently corrupted. */ export declare function expandWinEnvVars(s: string): string; /** * Returns the default placeholder map for `platform` (empty if none). * Values have `%VAR%` references expanded against `process.env`. */ export declare function defaultsForPlatform(config: McpConfig, platform: Platform): Record; export declare function currentPlatform(): Platform; /** * Pick the platform-specific spec, merge shared env, and validate shape. * Returns null when the server has no entry for the requested platform — * caller should treat that as "skip this server here". */ export declare function resolveServerForPlatform(variants: McpServerVariants, platform: Platform): McpServerSpec | null; /** * Find every `{KEY}` placeholder referenced by servers that have a spec for * `platform`. `mswai mcp` errors out when any of these keys is unprovided, * since the generated `.mcp.json` would otherwise contain a bare `{KEY}` * literal and the MCP server would just fail to launch. Servers without a * variant for `platform` are filtered out (they wouldn't be written for * this platform anyway). * * Keys covered by `defaults[platform]` are filtered out: a default value * exists, so the command can run without any flags. Users override per * placeholder via dedicated flags (`--mcp-url`, `--mcp-client-path`), * which win over defaults at substitution time. For keys the user is * expected to replace by hand (e.g. API tokens), put a hint value — like * the credentials issuance URL — in `defaults` so the slot is never left * as a bare `{KEY}` literal in the generated file. */ export declare function requiredPlaceholders(config: McpConfig, platform: Platform): string[]; /** * Secret placeholders that are actively referenced by a server on `platform`, * paired with their issuance metadata. Interactive `mswai mcp` prompts for * these — bypassing the defaults filter — and opens `issuanceUrl` in the * user's browser before the prompt. Silent runs ignore this list (defaults * still substitute, leaving the URL as a placeholder the user can replace). */ export declare function interactiveSecretsForPlatform(config: McpConfig, platform: Platform): Array<{ key: string; label: string; issuanceUrl?: string; }>; /** Replace `{KEY}` placeholders inside command/args/env values from `vars`. */ export declare function substituteVars(spec: McpServerSpec, vars: Record): McpServerSpec; /** * Parse `KEY=VALUE` strings (as supplied via repeated `--mcp-var`). Kept for * backward compatibility with the Unity client which still emits * `--mcp-var "MSW_MAKER_MCP_PATH=..."` and `--mcp-var "MSW_MCP_TOKEN=..."`. * New code prefers the dedicated `--mcp-url` / `--mcp-client-path` flags; * both forms feed into the same substitution map. Throws on malformed * entries so the user sees the problem immediately. */ export declare function parseMcpVars(entries: string[]): Record;