/** * MCP server lifecycle span helpers. * * Tracks the full MCP server state machine: * MCP_CONFIGURED → MCP_CONNECTING → MCP_CONNECTED → MCP_DEGRADED * Terminal states: MCP_DISCONNECTED | MCP_AUTH_REQUIRED (when not reconnecting) * * One span per MCP server connection lifecycle. */ import type { Span, SpanAttributes } from '../types.js'; import type { RuntimeTracer } from '../tracer.js'; /** Context supplied when starting an MCP server lifecycle span. */ export interface McpSpanContext { /** MCP server ID. */ readonly serverId: string; /** Transport type (e.g. 'stdio', 'sse', 'websocket'). */ readonly transport: string; /** Optional server URL for network transports. */ readonly url?: string | undefined; /** Trace ID for cross-span correlation. */ readonly traceId: string; } /** Phase transitions that can be recorded on an MCP lifecycle span. */ export type McpPhase = 'connecting' | 'connected' | 'degraded' | 'auth_required' | 'reconnecting'; /** Result context supplied when ending an MCP lifecycle span. */ export interface McpSpanEndContext { /** Final outcome of the MCP server connection. */ readonly outcome: 'connected' | 'disconnected' | 'auth_failed'; /** Reason for disconnection if known. */ readonly reason?: string | undefined; /** Whether a reconnect will be attempted. */ readonly willRetry?: boolean | undefined; /** Number of tools available when connected. */ readonly toolCount?: number | undefined; /** Number of resources available when connected. */ readonly resourceCount?: number | undefined; } /** * Start an MCP server lifecycle span. * * @param tracer - RuntimeTracer instance. * @param ctx - Context from MCP_CONFIGURED event. */ export declare function startMcpSpan(tracer: RuntimeTracer, ctx: McpSpanContext): Span; /** * Record an MCP server phase transition event. * * @param span - The active MCP lifecycle span. * @param phase - The phase reached. * @param attrs - Optional additional attributes. */ export declare function recordMcpPhase(span: Span, phase: McpPhase, attrs?: SpanAttributes): void; /** * End an MCP server lifecycle span. * * @param span - The span returned by `startMcpSpan`. * @param ctx - MCP lifecycle end context. */ export declare function endMcpSpan(span: Span, ctx: McpSpanEndContext): void; //# sourceMappingURL=mcp.d.ts.map