Skip to main content
Glama
Gowtham-3004

MCP Kynhood Events Server

by Gowtham-3004
tokenCache.ts1.02 kB
/** * In-memory token cache with TTL awareness */ interface TokenData { token: string; expiresAt: number; } let cachedToken: TokenData | null = null; // Default TTL: 55 minutes (assuming 1-hour token validity) const DEFAULT_TTL_MS = 55 * 60 * 1000; export const tokenCache = { /** * Get cached token if valid, otherwise null */ getToken(): string | null { if (!cachedToken) { return null; } const now = Date.now(); if (now >= cachedToken.expiresAt) { // Token expired, clear cache cachedToken = null; return null; } return cachedToken.token; }, /** * Store token with TTL */ setToken(token: string, ttlMs: number = DEFAULT_TTL_MS): void { cachedToken = { token, expiresAt: Date.now() + ttlMs }; }, /** * Clear cached token */ clearToken(): void { cachedToken = null; }, /** * Check if token exists and is valid */ hasValidToken(): boolean { return this.getToken() !== null; } };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Gowtham-3004/mcp-kyn-event'

If you have feedback or need assistance with the MCP directory API, please join our Discord server