ragatanga-mcp-sdk
Version:
SDK for integrating with the Ragatanga Management Control Plane (MCP) with Next.js 15, React 19, WebSocket and Arrow IPC support
122 lines (119 loc) • 2.98 kB
TypeScript
import { M as MCPOptions } from '../types-CmbeEBKR.js';
type EventCallback = (event: MessageEvent) => void;
/**
* Options for the SSE Client
*/
interface SSEOptions extends MCPOptions {
eventsEndpoint?: string;
reconnectTimeout?: number;
maxReconnectAttempts?: number;
sseOptions?: EventSourceInit;
eventTypes?: string[];
heartbeatInterval?: number;
connectionTimeout?: number;
autoReconnect?: boolean;
}
/**
* Connection status for SSE client
*/
declare enum SSEConnectionStatus {
DISCONNECTED = "disconnected",
CONNECTING = "connecting",
CONNECTED = "connected",
RECONNECTING = "reconnecting",
ERROR = "error"
}
/**
* SSE Client for handling Server-Sent Events
*/
declare class MCPSSEClient {
private baseUrl;
private apiKey?;
private token?;
private tenantId?;
private eventSource;
private eventHandlers;
private reconnectTimeout;
private maxReconnectAttempts;
private reconnectAttempts;
private eventsEndpoint;
private sseOptions;
private status;
private eventTypes;
private lastEventId;
private heartbeatInterval;
private heartbeatTimer;
private connectionTimeout;
private connectionTimer;
private autoReconnect;
private statusHandlers;
/**
* Create a new SSE client
*/
constructor(options: SSEOptions);
/**
* Get the current connection status
*/
getStatus(): SSEConnectionStatus;
/**
* Register a handler for connection status changes
*/
onStatusChange(handler: (status: SSEConnectionStatus) => void): () => void;
/**
* Update connection status and notify handlers
*/
private setStatus;
/**
* Connect to the SSE endpoint
*/
connect(): void;
/**
* Disconnect from the SSE endpoint
*/
disconnect(): void;
/**
* Register an event handler for a specific event type
*/
on(eventType: string, callback: EventCallback): () => void;
/**
* Remove all event handlers for a specific event type
*/
off(eventType: string): void;
/**
* Attempt to reconnect with exponential backoff
*/
private attemptReconnect;
/**
* Start heartbeat to detect connection issues
*/
private startHeartbeat;
/**
* Handle SSE connection open
*/
private handleOpen;
/**
* Handle SSE connection error
*/
private handleError;
/**
* Handle connection initialization error
*/
private handleConnectionError;
/**
* Handle generic message event
*/
private handleMessage;
/**
* Handle specific event type
*/
private handleEvent;
/**
* Dispatch an event to all registered handlers
*/
private dispatchEvent;
}
/**
* Create a new SSE client
*/
declare function createSSEClient(options: SSEOptions): MCPSSEClient;
export { MCPSSEClient, SSEConnectionStatus, type SSEOptions, createSSEClient };