mcp-use
Version:
Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.
55 lines • 1.61 kB
TypeScript
/**
* Session Helper Utilities
*
* Common utilities for working with MCP sessions.
*/
import type { SessionData } from "../sessions/session-manager.js";
/**
* Get a session from the sessions map, or return null if not found
*
* This is a safe session lookup helper that ensures consistent handling
* of missing sessions across the codebase.
*
* @param sessions - Map of active sessions
* @param sessionId - The session ID to look up
* @returns The session data if found, null otherwise
*
* @example
* ```typescript
* const session = getSessionOrNull(sessions, sessionId);
* if (!session) {
* return createSessionNotFoundError();
* }
* // Use session safely
* ```
*/
export declare function getSessionOrNull(sessions: Map<string, SessionData>, sessionId: string): SessionData | null;
/**
* Check if a session exists
*
* @param sessions - Map of active sessions
* @param sessionId - The session ID to check
* @returns true if the session exists, false otherwise
*
* @example
* ```typescript
* if (hasSession(sessions, sessionId)) {
* console.log('Session exists');
* }
* ```
*/
export declare function hasSession(sessions: Map<string, SessionData>, sessionId: string): boolean;
/**
* Get all active session IDs
*
* @param sessions - Map of active sessions
* @returns Array of session IDs
*
* @example
* ```typescript
* const sessionIds = getAllSessionIds(sessions);
* console.log(`${sessionIds.length} active sessions`);
* ```
*/
export declare function getAllSessionIds(sessions: Map<string, SessionData>): string[];
//# sourceMappingURL=session-helpers.d.ts.map