UNPKG

tarot-mcp-server

Version:

Model Context Protocol server for Rider-Waite tarot card readings

70 lines (69 loc) 1.8 kB
/** * Manages tarot reading sessions */ export class TarotSessionManager { sessions; constructor() { this.sessions = new Map(); } /** * Create a new session */ createSession() { const sessionId = this.generateSessionId(); const session = { id: sessionId, readings: [], createdAt: new Date(), lastActivity: new Date() }; this.sessions.set(sessionId, session); return session; } /** * Get an existing session */ getSession(sessionId) { return this.sessions.get(sessionId); } /** * Add a reading to a session */ addReadingToSession(sessionId, reading) { const session = this.sessions.get(sessionId); if (session) { session.readings.push(reading); session.lastActivity = new Date(); } } /** * Get all readings from a session */ getSessionReadings(sessionId) { const session = this.sessions.get(sessionId); return session ? session.readings : []; } /** * Clean up old sessions (older than 24 hours) */ cleanupOldSessions() { const cutoffTime = new Date(Date.now() - 24 * 60 * 60 * 1000); // 24 hours ago for (const [sessionId, session] of this.sessions.entries()) { if (session.lastActivity < cutoffTime) { this.sessions.delete(sessionId); } } } /** * Generate a unique session ID */ generateSessionId() { return `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`; } /** * Get session count (for debugging/monitoring) */ getSessionCount() { return this.sessions.size; } }