Skip to main content
Glama

whoop-refresh-token

Refresh WHOOP API access tokens to maintain continuous authentication for accessing fitness data, health metrics, and workout information.

Instructions

Refresh access token using refresh token

Input Schema

NameRequiredDescriptionDefault
refreshTokenYesRefresh token to use for getting new access token

Input Schema (JSON Schema)

{ "properties": { "refreshToken": { "description": "Refresh token to use for getting new access token", "type": "string" } }, "required": [ "refreshToken" ], "type": "object" }

Implementation Reference

  • Core implementation of the 'whoop-refresh-token' tool. Performs OAuth2 token refresh by posting client credentials and refresh token to Whoop's token endpoint.
    async refreshToken(refreshToken: string): Promise<{ access_token: string; refresh_token: string; expires_in: number }> { const formData = new URLSearchParams(); formData.append('client_id', this.config.clientId); formData.append('client_secret', this.config.clientSecret); formData.append('refresh_token', refreshToken); formData.append('grant_type', 'refresh_token'); const response = await axios.post('https://api.prod.whoop.com/oauth/oauth2/token', formData, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }); return response.data; }
  • MCP server tool handler for 'whoop-refresh-token'. Validates input arguments and delegates to WhoopApiClient.refreshToken().
    case 'whoop-refresh-token': { if (!args || typeof args.refreshToken !== 'string') { throw new Error('refreshToken is required and must be a string'); } const result = await this.whoopClient.refreshToken(args.refreshToken); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • Input schema definition and tool metadata for the 'whoop-refresh-token' tool, registered with the MCP server.
    { name: 'whoop-refresh-token', description: 'Refresh access token using refresh token', inputSchema: { type: 'object', properties: { refreshToken: { type: 'string', description: 'Refresh token to use for getting new access token', }, }, required: ['refreshToken'], }, },
  • Registration of all tools including 'whoop-refresh-token' via setRequestHandler for ListToolsRequestSchema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ // User tools { name: 'whoop-get-user-profile', description: 'Get basic user profile information (name, email) for the authenticated user', inputSchema: { type: 'object', properties: {}, required: [], }, }, { name: 'whoop-get-user-body-measurements', description: 'Get body measurements (height, weight, max heart rate) for the authenticated user', inputSchema: { type: 'object', properties: {}, required: [], }, }, { name: 'whoop-revoke-user-access', description: 'Revoke the access token granted by the user', inputSchema: { type: 'object', properties: {}, required: [], }, }, // Cycle tools { name: 'whoop-get-cycle-by-id', description: 'Get the cycle for the specified ID', inputSchema: { type: 'object', properties: { cycleId: { type: 'number', description: 'ID of the cycle to retrieve', }, }, required: ['cycleId'], }, }, { name: 'whoop-get-cycle-collection', description: 'Get all physiological cycles for a user, paginated', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Limit on the number of cycles returned (max 25)', }, start: { type: 'string', description: 'Return cycles that occurred after or during this time (ISO 8601)', }, end: { type: 'string', description: 'Return cycles that intersect this time or ended before this time (ISO 8601)', }, nextToken: { type: 'string', description: 'Next token from the previous response to get the next page', }, }, required: [], }, }, { name: 'whoop-get-sleep-for-cycle', description: 'Get sleep data for a specific cycle', inputSchema: { type: 'object', properties: { cycleId: { type: 'number', description: 'ID of the cycle to get sleep data for', }, }, required: ['cycleId'], }, }, // Recovery tools { name: 'whoop-get-recovery-collection', description: 'Get all recovery data for a user, paginated', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Limit on the number of recovery records returned (max 25)', }, start: { type: 'string', description: 'Return recovery records that occurred after or during this time (ISO 8601)', }, end: { type: 'string', description: 'Return recovery records that intersect this time or ended before this time (ISO 8601)', }, nextToken: { type: 'string', description: 'Next token from the previous response to get the next page', }, }, required: [], }, }, { name: 'whoop-get-recovery-for-cycle', description: 'Get recovery data for a specific cycle', inputSchema: { type: 'object', properties: { cycleId: { type: 'number', description: 'ID of the cycle to get recovery data for', }, }, required: ['cycleId'], }, }, // Sleep tools { name: 'whoop-get-sleep-by-id', description: 'Get the sleep record for the specified ID', inputSchema: { type: 'object', properties: { sleepId: { type: 'string', description: 'ID of the sleep record to retrieve', }, }, required: ['sleepId'], }, }, { name: 'whoop-get-sleep-collection', description: 'Get all sleep records for a user, paginated', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Limit on the number of sleep records returned (max 25)', }, start: { type: 'string', description: 'Return sleep records that occurred after or during this time (ISO 8601)', }, end: { type: 'string', description: 'Return sleep records that intersect this time or ended before this time (ISO 8601)', }, nextToken: { type: 'string', description: 'Next token from the previous response to get the next page', }, }, required: [], }, }, // Workout tools { name: 'whoop-get-workout-by-id', description: 'Get the workout record for the specified ID', inputSchema: { type: 'object', properties: { workoutId: { type: 'string', description: 'ID of the workout record to retrieve', }, }, required: ['workoutId'], }, }, { name: 'whoop-get-workout-collection', description: 'Get all workout records for a user, paginated', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Limit on the number of workout records returned (max 25)', }, start: { type: 'string', description: 'Return workout records that occurred after or during this time (ISO 8601)', }, end: { type: 'string', description: 'Return workout records that intersect this time or ended before this time (ISO 8601)', }, nextToken: { type: 'string', description: 'Next token from the previous response to get the next page', }, }, required: [], }, }, // OAuth tools { name: 'whoop-get-authorization-url', description: 'Get the authorization URL for OAuth flow', inputSchema: { type: 'object', properties: {}, required: [], }, }, { name: 'whoop-exchange-code-for-token', description: 'Exchange authorization code for access token', inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'Authorization code from OAuth callback', }, }, required: ['code'], }, }, { name: 'whoop-refresh-token', description: 'Refresh access token using refresh token', inputSchema: { type: 'object', properties: { refreshToken: { type: 'string', description: 'Refresh token to use for getting new access token', }, }, required: ['refreshToken'], }, }, { name: 'whoop-set-access-token', description: 'Set the access token for API calls', inputSchema: { type: 'object', properties: { accessToken: { type: 'string', description: 'Access token to use for API calls', }, }, required: ['accessToken'], }, }, ] as Tool[], };

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

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