/** * MCP-server registration + authentication for `@agent-native/skills`. * * This is a dependency-free port of the MCP-config-writing + device-code/OAuth * flow that lives in `@agent-native/core`'s `cli/connect.ts`. The skills package * ships standalone (no `@agent-native/core` dependency), so this module * re-implements just the registration surface against the shared on-disk * writers in `./mcp-config-writers.js`. It writes the SAME config and speaks the * SAME device-code/OAuth protocol as core. * * Two client families, exactly as in core: * - OAuth-capable (Claude Code, Cursor, OpenCode, GitHub Copilot / VS Code): * get a URL-only HTTP MCP entry (no bearer headers). The user authenticates * in-host via standard remote MCP OAuth. * - Device-code (codex, cowork): run the browser device-code flow against the * descriptor's hosted URL, then write the entry WITH the minted bearer token * + headers. Non-interactive (or no TTY) skips writing device-code configs, * surfacing the exact `agent-native connect ` fallback command. * * Server contract (identical paths + JSON field names to core): * POST /mcp/connect/device/start (no auth) * body { client?, app? } * → { device_code, user_code, verification_uri, * verification_uri_complete, interval, expires_in } * POST /mcp/connect/device/poll (no auth) * body { device_code } * → { status: "pending" } * | { status: "approved", token, mcpUrl, serverName, mcpServerEntry } * | { status: "expired" } | { status: "consumed" } * | { status: "error" | "not_found", message? } * * Node-only. Node built-ins + global fetch only; no npm deps. */ import { ClientId } from "./mcp-config-writers.js"; /** * Describes one MCP server to register. `serverName` is the canonical config * key; `aliases` are additional config keys that point at the same MCP URL * (e.g. `plan` + `agent-native-plans`). `hostedUrl` is the deployed app origin * the device-code flow authenticates against; `mcpUrl` is the resolved MCP * endpoint written into the config (defaults to `/mcp` * when only `hostedUrl` is supplied). */ export interface McpDescriptor { serverName: string; mcpUrl: string; aliases?: string[]; authMode?: "oauth" | "device" | "none"; hostedUrl?: string; } export interface RegisterMcpOptions { descriptor: McpDescriptor; clients: ClientId[]; scope: "user" | "project"; baseDir: string; interactive: boolean; log?: (m: string) => void; deviceFlowTimeoutMs?: number; deps?: { fetchImpl?: typeof fetch; now?: () => number; sleep?: (ms: number) => Promise; }; } export interface RegisterMcpResult { written: { client: ClientId; file: string; }[]; authenticated: boolean; guidance: string[]; } export declare function supportsRemoteMcpOAuth(client: ClientId): boolean; /** * Register an MCP server (plus aliases) into the requested client configs, * authenticating device-code clients via the browser flow when interactive. * * Idempotent: re-running replaces the same named entries. Never throws on a * single client/key failing — failures are collected into `guidance`. */ export declare function registerMcpServer(opts: RegisterMcpOptions): Promise; //# sourceMappingURL=connect.d.ts.map