Support non-containerized MCP servers via externalUrl field and add streamable-http session management for HA MCP proof of concept. - Add externalUrl, command, containerPort fields to McpServer schema - Skip Docker orchestration for external servers (virtual instances) - Implement streamable-http proxy with Mcp-Session-Id session management - Parse SSE-framed responses from streamable-http endpoints - Add command passthrough to Docker container creation - Create HA MCP example manifest (examples/ha-mcp.yaml) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67 lines
2.0 KiB
TypeScript
67 lines
2.0 KiB
TypeScript
/**
|
|
* Container orchestrator abstraction. Implementations can back onto Docker, Podman, or Kubernetes.
|
|
*/
|
|
|
|
export interface ContainerSpec {
|
|
/** Docker/OCI image reference */
|
|
image: string;
|
|
/** Human-readable name (used as container name prefix) */
|
|
name: string;
|
|
/** Custom command to run (overrides image CMD) */
|
|
command?: string[];
|
|
/** Environment variables */
|
|
env?: Record<string, string>;
|
|
/** Host port to bind (null = auto-assign) */
|
|
hostPort?: number | null;
|
|
/** Container port to expose */
|
|
containerPort?: number;
|
|
/** Memory limit in bytes (default: 512 MB) */
|
|
memoryLimit?: number;
|
|
/** CPU period quota (nanoCPUs, default: 0.5 CPU) */
|
|
nanoCpus?: number;
|
|
/** Labels for identification / filtering */
|
|
labels?: Record<string, string>;
|
|
/** Network name to attach to */
|
|
network?: string;
|
|
}
|
|
|
|
export interface ContainerInfo {
|
|
containerId: string;
|
|
name: string;
|
|
state: 'running' | 'stopped' | 'starting' | 'error' | 'unknown';
|
|
port?: number;
|
|
createdAt: Date;
|
|
}
|
|
|
|
export interface ContainerLogs {
|
|
stdout: string;
|
|
stderr: string;
|
|
}
|
|
|
|
export interface McpOrchestrator {
|
|
/** Pull an image if not present locally */
|
|
pullImage(image: string): Promise<void>;
|
|
|
|
/** Create and start a container */
|
|
createContainer(spec: ContainerSpec): Promise<ContainerInfo>;
|
|
|
|
/** Stop a running container */
|
|
stopContainer(containerId: string, timeoutSeconds?: number): Promise<void>;
|
|
|
|
/** Remove a stopped container */
|
|
removeContainer(containerId: string, force?: boolean): Promise<void>;
|
|
|
|
/** Get container info */
|
|
inspectContainer(containerId: string): Promise<ContainerInfo>;
|
|
|
|
/** Get container logs */
|
|
getContainerLogs(containerId: string, opts?: { tail?: number; since?: number }): Promise<ContainerLogs>;
|
|
|
|
/** Check if the orchestrator runtime is available */
|
|
ping(): Promise<boolean>;
|
|
}
|
|
|
|
/** Default resource limits */
|
|
export const DEFAULT_MEMORY_LIMIT = 512 * 1024 * 1024; // 512 MB
|
|
export const DEFAULT_NANO_CPUS = 500_000_000; // 0.5 CPU
|