/** * startServer — One-Liner Bootstrap for MCP Fusion Servers * * Abstracts the entire server startup boilerplate into a single call: * 1. Creates the MCP Server instance * 2. Attaches the tool registry with telemetry * 3. Builds the topology for Inspector TUI auto-discovery * 4. Starts the Telemetry Bus (IPC) * 5. Connects the stdio transport * * @module */ import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { type AttachOptions } from './ServerAttachment.js'; import { type TelemetryBusInstance } from '../observability/TelemetryBus.js'; import type { PromptRegistry } from '../prompt/PromptRegistry.js'; import type { ProgressSink } from '../core/execution/ProgressHelper.js'; /** Options for `startServer`. */ export interface StartServerOptions { /** Server display name (shown in MCP clients and Inspector). */ readonly name: string; /** Server version string (e.g. '1.0.0'). */ readonly version?: string; /** The tool registry to expose. */ readonly registry: ServerRegistry; /** Optional prompt registry. */ readonly prompts?: PromptRegistry; /** Factory to create per-request context. */ readonly contextFactory?: (extra: unknown) => TContext | Promise; /** Enable Inspector TUI telemetry (default: true). */ readonly telemetry?: boolean; /** Extra attach options (debug, tracing, zeroTrust, etc.). */ readonly attach?: Omit, 'contextFactory' | 'prompts' | 'telemetry'>; } /** * Minimal registry interface expected by `startServer`. * Both `ToolRegistry` and any object with `getBuilders()` + `attachToServer()` qualify. */ interface ServerRegistry { getBuilders(): Iterable; attachToServer(server: unknown, options: AttachOptions): Promise; routeCall(ctx: TContext, name: string, args: Record, progressSink?: ProgressSink, signal?: AbortSignal): Promise; } /** Minimal builder shape for topology extraction. */ interface ToolBuilderLike { getName(): string; getActionNames(): string[]; buildToolDefinition(): unknown; } /** Result returned by `startServer`. */ export interface StartServerResult { /** The MCP Server instance (`null` in edge/interceptor mode). */ readonly server: InstanceType | null; /** The Telemetry Bus (if enabled). */ readonly bus?: TelemetryBusInstance; /** Gracefully shut down everything. */ readonly close: () => Promise; } /** * Start an MCP Fusion server with a single call. * * Handles all bootstrap boilerplate: Server creation, registry attachment, * telemetry bus, and stdio transport connection. * * @example * ```typescript * import { startServer, autoDiscover } from '@vinkius-core/mcp-fusion'; * * const registry = f.registry(); * await autoDiscover(registry, new URL('./tools', import.meta.url)); * * await startServer({ * name: 'my-server', * registry, * contextFactory: () => createContext(), * }); * ``` */ export declare function startServer(options: StartServerOptions): Promise; export {}; //# sourceMappingURL=startServer.d.ts.map