Skip to main content
Glama

WHOOP MCP Server

by nissand
start-mcp-server.js•3.12 kB
#!/usr/bin/env node import fs from 'fs'; import { WhoopMcpServer } from './dist/mcp-server.js'; const WHOOP_CONFIG = { clientId: '062d270e-37a8-43d3-865c-f9560c5a3e13', clientSecret: '4bbbb2fb1ce77f9f250455ff2c1fbfc862c0de100a93de22999b887aeae28bf6', redirectUri: 'http://localhost:3000/callback' }; // Function to load saved tokens function loadTokens() { try { if (fs.existsSync('whoop-tokens.json')) { const tokenData = JSON.parse(fs.readFileSync('whoop-tokens.json', 'utf8')); console.log('āœ… Loaded saved tokens from whoop-tokens.json'); console.log('šŸ“… Tokens saved on:', tokenData.timestamp); return tokenData; } else { console.log('āŒ No saved tokens found. Please run the authentication first:'); console.log(' node auth-app.js'); return null; } } catch (error) { console.error('āŒ Error loading tokens:', error.message); return null; } } // Function to test if tokens are still valid async function testTokens(accessToken) { try { const { WhoopApiClient } = await import('./dist/whoop-api.js'); const client = new WhoopApiClient(WHOOP_CONFIG); client.setAccessToken(accessToken); const userProfile = await client.getUserProfile(); console.log('āœ… Access token is valid!'); console.log('šŸ‘¤ User:', userProfile.first_name, userProfile.last_name); console.log('šŸ“§ Email:', userProfile.email); return true; } catch (error) { console.log('āŒ Access token is invalid or expired:', error.message); return false; } } // Main function async function startMcpServer() { console.log('šŸš€ Starting WHOOP MCP Server...'); console.log(''); // Load saved tokens const tokenData = loadTokens(); if (!tokenData) { process.exit(1); } // Test if tokens are still valid const isValid = await testTokens(tokenData.accessToken); if (!isValid) { console.log(''); console.log('šŸ”„ Please re-authenticate by running:'); console.log(' node auth-app.js'); process.exit(1); } console.log(''); console.log('šŸŽÆ Starting MCP server with valid tokens...'); // Create and start the MCP server const server = new WhoopMcpServer(WHOOP_CONFIG); // Set the access token server.whoopClient.setAccessToken(tokenData.accessToken); try { await server.run(); console.log('āœ… WHOOP MCP Server is ready for Claude!'); console.log(''); console.log('šŸ“‹ Next steps:'); console.log('1. Add the server to Claude (Settings → Model Context Protocol)'); console.log('2. Use path: /Users/danielnissan/Dev/whoop-mcp-server'); console.log('3. Start asking Claude about your WHOOP data!'); console.log(''); } catch (error) { console.error('āŒ Failed to start MCP server:', error.message); process.exit(1); } } // Handle graceful shutdown process.on('SIGINT', () => { console.log('\nšŸ‘‹ Shutting down WHOOP MCP Server...'); process.exit(0); }); // Start the server startMcpServer().catch((error) => { console.error('āŒ Failed to start server:', error.message); process.exit(1); });

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/nissand/whoop-mcp-server-claude'

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