import { MCPRequest, MCPResponse, MCPNotification, JSONRPCId, ErrorCode } from './types.js'; /** * Message formatter for MCP protocol */ export declare class MessageFormatter { private requestId; /** * Generate a unique request ID */ private generateId; /** * Format a request message */ formatRequest(method: string, params?: Record): MCPRequest; /** * Format a notification message (no ID, no response expected) */ formatNotification(method: string, params?: Record): MCPNotification; /** * Format a success response */ formatResponse(id: JSONRPCId, result: unknown): MCPResponse; /** * Format an error response */ formatError(id: JSONRPCId, code: ErrorCode, message: string, data?: unknown): MCPResponse; /** * Parse and validate an incoming message */ parseMessage(data: string): MCPRequest | MCPResponse | MCPNotification; /** * Serialize a message to JSON string */ serialize(message: MCPRequest | MCPResponse | MCPNotification): string; /** * Check if a message is a request */ isRequest(message: unknown): message is MCPRequest; /** * Check if a message is a notification */ isNotification(message: unknown): message is MCPNotification; /** * Check if a message is a response */ isResponse(message: unknown): message is MCPResponse; /** * Check if a response is an error */ isErrorResponse(response: MCPResponse): boolean; } /** * Message router for handling different message types */ export declare class MessageRouter { private handlers; private formatter; /** * Register a method handler */ registerHandler(method: string, handler: (_params: unknown) => Promise): void; /** * Route a request to the appropriate handler */ handleRequest(request: MCPRequest): Promise; /** * Handle a notification (no response) */ handleNotification(notification: MCPNotification): Promise; } /** * Correlation tracker for matching requests with responses */ export declare class CorrelationTracker { private pendingRequests; /** * Track a request and return a promise that resolves with the response */ trackRequest(id: JSONRPCId, timeoutMs?: number): Promise; /** * Resolve a pending request with a response */ resolveRequest(response: MCPResponse): void; /** * Cancel a pending request */ cancelRequest(id: JSONRPCId): void; /** * Cancel all pending requests */ cancelAll(): void; } //# sourceMappingURL=messages.d.ts.map