import type { Readable, Writable } from "node:stream"; export declare const H2A_MCP_CENTRAL_ENV = "H2A_MCP_CENTRAL"; export declare const H2A_MCP_CENTRAL_ENDPOINT_ENV = "H2A_MCP_CENTRAL_ENDPOINT"; export type CentralMcpMarker = Readonly<{ endpoint: string; generation: string; pid: number; startedAt: string; token: string; }>; /** Only explicit values opt into central routing; all other values preserve stdio. */ export declare function centralMcpEnabled(env?: Readonly>): boolean; /** * Validate and canonicalize the one endpoint both launcher and clients use. * Central MCP is plain Streamable HTTP; TLS termination belongs outside this * local process, so https URLs are deliberately refused rather than half-served. */ export declare function parseCentralMcpEndpoint(value: string | undefined): string; export type CentralMcpClientEndpoint = Readonly<{ command: string; args: string[]; }>; /** Returns the central URL only when the explicit opt-in is enabled. */ export declare function centralMcpClientEndpoint(env?: Readonly>, paths?: CentralMcpPathsOptions): CentralMcpClientEndpoint | undefined; export interface CentralMcpPathsOptions { /** Test seam. Production always uses /run/user/; it is never env-derived. */ runtimeBase?: string; } /** * Fixed UID-only marker path. `runtimeBase` is a test seam, never an env input. */ export declare function centralMcpMarkerPath(options?: CentralMcpPathsOptions): string; /** * Read the protected central marker without exposing its token to callers that * only need liveness/generation metadata. A missing marker is the sole * non-error absence case; malformed or insecure state remains a hard failure. */ export declare function readCentralMcpMarker(paths?: CentralMcpPathsOptions): Omit | undefined; export interface CentralMcpStdioBridgeOptions extends CentralMcpPathsOptions { /** The endpoint persisted in the rendered command; it must match the marker. */ endpoint: string; stdin: Readable; stdout: Writable; signal?: AbortSignal; } /** * Proxy one stdio MCP client to the current central Streamable-HTTP server. * The bridge reads the private marker once at connect time, so a config never * contains the bearer token and a newly launched bridge observes a restarted * owner's current credential. */ export declare function bridgeCentralMcpStdio(options: CentralMcpStdioBridgeOptions): Promise; export type CentralMcpPingResult = Readonly<{ kind: "generation"; generation: string; }> | Readonly<{ kind: "dead"; }> | Readonly<{ kind: "ambiguous"; }>; export declare function centralMcpPing(endpoint: string, timeoutMs?: number): Promise; export interface StartCentralMcpServerOptions extends CentralMcpPathsOptions { root: string; env?: Readonly>; /** Test seam for forcing scheduling around a successful marker claim. */ afterMarkerClaim?: () => Promise; /** Test seam for scheduling contenders after identity-CAS and before rename. */ beforeMarkerReclaimReplace?: (candidate: CentralMcpMarker) => Promise; /** Test seam for scheduling exclusive publication after staging complete content. */ beforeExclusiveMarkerPublish?: () => Promise; } export type StartedCentralMcpServer = Readonly<{ kind: "reused"; endpoint: string; generation: string; markerPath: string; }> | Readonly<{ kind: "started"; endpoint: string; generation: string; markerPath: string; stop(): Promise; }>; /** * Start exactly one full-surface MCP server at the explicit endpoint. * The endpoint begins answering its generation ping before that generation is * recorded in the marker, so a contender never mistakes a starting owner for * a dead registration. */ export declare function startCentralMcpServer(options: StartCentralMcpServerOptions): Promise; //# sourceMappingURL=mcp-central.d.ts.map