Skip to main content
Glama
nissand

WHOOP MCP Server

by nissand

whoop-exchange-code-for-token

Exchange an OAuth authorization code for an access token to authenticate with WHOOP fitness and health data APIs.

Instructions

Exchange authorization code for access token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesAuthorization code from OAuth callback

Implementation Reference

  • MCP tool handler for 'whoop-exchange-code-for-token': validates 'code' argument and calls WhoopApiClient.exchangeCodeForToken, returning JSON stringified result.
    case 'whoop-exchange-code-for-token': {
      if (!args || typeof args.code !== 'string') {
        throw new Error('code is required and must be a string');
      }
      const result = await this.whoopClient.exchangeCodeForToken(args.code);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Registers the 'whoop-exchange-code-for-token' tool in the listTools response, including name, description, and input schema.
    {
      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'],
      },
    },
  • Core implementation: exchanges OAuth code for access/refresh tokens by sending POST request to Whoop's token endpoint with client credentials.
    async exchangeCodeForToken(code: 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('code', code);
      formData.append('grant_type', 'authorization_code');
      formData.append('redirect_uri', this.config.redirectUri);
    
      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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the core function but lacks critical details: it doesn't specify authentication requirements, rate limits, error conditions, or what the access token enables. For a security-sensitive OAuth tool, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly conveys the tool's purpose without any fluff. It's appropriately sized and front-loaded, with every word earning its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of OAuth token exchange and the lack of annotations or output schema, the description is incomplete. It doesn't explain the return value (e.g., token structure, expiration), error handling, or security implications, which are essential for proper agent usage in this context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'code' documented as 'Authorization code from OAuth callback'. The description adds no additional meaning beyond this, as it only restates the schema's purpose without elaborating on format, source, or validation. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Exchange') and the resources involved ('authorization code for access token'), which is specific and unambiguous. It distinguishes from siblings like 'whoop-get-authorization-url' (which provides the code) and 'whoop-refresh-token' (which uses a refresh token), though it doesn't explicitly name these alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an authorization code from OAuth callback), exclusions, or contextual triggers, leaving the agent to infer usage from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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