/** * Hand remote MCP servers to an agent at launch. * * For each server whose `mcp:` allowlist admits the agent's role, the * agent gets the backend's proxy (`/api/connectors/remote-mcp//mcp`, * see remote-mcp-proxy.controller) rather than the server itself: the * server URL (Zoho's carries its key) and OAuth tokens never reach an agent * config. The only credential in the files is the agent's own identity * (`X-Agent-Session` + badge), which the proxy checks against the allowlist. * * | Runtime | How | * |---|---| * | Claude Code | `--mcp-config '/runtime/remote-mcp//claude-mcp.json'` (adds to the project `.mcp.json`; no `--strict-mcp-config`) | * | Codex | `-c "mcp_servers..url=$(cat '')"` (+ `http_headers`), so the secret never appears on the typed command line | * | Gemini CLI, Antigravity, OpenCode, crewly-agent | skipped with a log line | * * Every file is written under CREWLY_HOME with mode 0600 (directory 0700), * never into the project. The returned flags carry only file paths. * * @module services/connector/remote-mcp-launch.service */ import { RemoteMcpService, type RemoteMcpServer } from './remote-mcp.service.js'; /** Input for {@link buildRemoteMcpLaunchFlags}. */ export interface RemoteMcpLaunchInput { /** PTY session name. */ sessionName: string; /** Agent role (decides the allowlists). */ role: string; /** Runtime being launched. */ runtimeType: string; /** Override CREWLY_HOME (tests). */ crewlyHome?: string; /** Override the store (tests). */ service?: RemoteMcpService; /** Override the backend base URL (tests). */ apiBaseUrl?: string; } /** What {@link buildRemoteMcpLaunchFlags} decided. */ export interface RemoteMcpLaunchResult { /** Flags to add to the launch command (already shell-quoted). */ flags: string[]; /** Server ids handed to the agent. */ servers: string[]; /** Why nothing was added, when nothing was. */ skipped?: 'no-servers' | 'unsupported-runtime' | 'error'; } /** * The per-session directory for launch files. * * @param crewlyHome - CREWLY_HOME * @param sessionName - PTY session name * @returns Absolute directory */ export declare function remoteMcpSessionDir(crewlyHome: string, sessionName: string): string; /** * The proxy URL an agent uses for a server. * * @param apiBaseUrl - Backend base, e.g. `http://localhost:8787` * @param id - Server id * @returns `/api/connectors/remote-mcp//mcp` */ export declare function remoteMcpProxyUrl(apiBaseUrl: string, id: string): string; /** * Headers that identify the agent to the proxy. * * @param sessionName - Agent session * @returns `X-Agent-Session` and `X-Agent-Badge` */ export declare function proxyIdentityHeaders(sessionName: string): Record; /** * Claude Code's `--mcp-config` body: every server through the proxy. * * @param servers - Allowed servers * @param sessionName - Agent session (identity headers) * @param apiBaseUrl - Backend base URL * @returns `{ mcpServers: { : { type: 'http', url: , headers } } }` */ export declare function buildClaudeMcpConfig(servers: RemoteMcpServer[], sessionName: string, apiBaseUrl: string): { mcpServers: Record; }>; }; /** * A TOML inline table of headers (JSON strings are valid TOML basic strings). * * @param headers - Header map * @returns e.g. `{ "Authorization" = "Bearer x" }` */ export declare function toTomlInlineTable(headers: Record): string; /** * Write the launch files for one agent and return the flags that load them. * Never throws: on any failure the agent launches without remote MCP and * the error is logged (without secrets). * * @param input - Session, role, runtime * @returns Flags and the server ids handed over */ export declare function buildRemoteMcpLaunchFlags(input: RemoteMcpLaunchInput): Promise; //# sourceMappingURL=remote-mcp-launch.service.d.ts.map