UNPKG

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.

82 lines 2.43 kB
/** * In-Memory Session Store * * Default session storage implementation using JavaScript Map. * Sessions are stored in memory and lost on server restart. * * For production deployments requiring session persistence across restarts, * consider implementing a custom SessionStore backed by Redis, PostgreSQL, * or another persistent storage system. */ import type { SessionStore } from "./index.js"; import type { SessionMetadata } from "../session-manager.js"; /** * In-memory session storage (default) * * Provides fast, local session management without external dependencies. * Suitable for: * - Development environments * - Single-instance deployments * - Stateful applications where session loss on restart is acceptable * * Not suitable for: * - Distributed/clustered deployments * - Applications requiring session persistence across restarts * - Horizontal scaling scenarios * * @example * ```typescript * import { MCPServer, InMemorySessionStore } from 'mcp-use/server'; * * const server = new MCPServer({ * name: 'my-server', * version: '1.0.0', * sessionStore: new InMemorySessionStore() * }); * ``` */ export declare class InMemorySessionStore implements SessionStore { /** * Internal map storing session metadata * Key: sessionId, Value: SessionMetadata */ private sessions; /** * Retrieve session metadata by ID */ get(sessionId: string): Promise<SessionMetadata | null>; /** * Store or update session metadata */ set(sessionId: string, data: SessionMetadata): Promise<void>; /** * Delete session metadata */ delete(sessionId: string): Promise<void>; /** * Check if session exists */ has(sessionId: string): Promise<boolean>; /** * List all session IDs */ keys(): Promise<string[]>; /** * Store session metadata with TTL (time-to-live) * * Note: In-memory implementation uses setTimeout for TTL. * For production TTL support, use Redis or another store with native TTL. */ setWithTTL(sessionId: string, data: SessionMetadata, ttlMs: number): Promise<void>; /** * Get the number of active sessions * Useful for monitoring and debugging */ get size(): number; /** * Clear all sessions * Useful for testing and manual cleanup */ clear(): Promise<void>; } //# sourceMappingURL=memory.d.ts.map