UNPKG

mcp-openweathermap

Version:
35 lines 1.02 kB
// Global session data for stdio transport let stdioSession = null; /** * Initialize authentication for stdio transport using environment variables * This is called once at server startup */ export async function initializeStdioAuth() { const apiKey = process.env.OPENWEATHER_API_KEY; if (!apiKey) { throw new Error("OPENWEATHER_API_KEY environment variable is required for stdio transport. " + "Please set it before starting the server."); } // Validate API key format (basic validation) if (apiKey.length < 32) { throw new Error("Invalid OPENWEATHER_API_KEY format. Please check your API key."); } // Store session data stdioSession = { apiKey, authenticatedAt: new Date(), }; } /** * Get the current stdio session */ export function getStdioSession() { return stdioSession; } /** * Clear the stdio session (for testing purposes) */ export function clearStdioSession() { stdioSession = null; } //# sourceMappingURL=stdio.js.map