whoop-get-sleep-by-id
Retrieve detailed sleep analysis data from WHOOP using a specific sleep record ID to access sleep metrics, stages, and recovery insights.
Instructions
Get the sleep record for the specified ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sleepId | Yes | ID of the sleep record to retrieve |
Implementation Reference
- src/whoop-api.ts:102-105 (handler)Core handler function that executes the API call to retrieve sleep data by ID from the Whoop API endpoint.async getSleepById(sleepId: string): Promise<WhoopSleep> { const response = await this.client.get(`/activity/sleep/${sleepId}`); return response.data; }
- src/mcp-server.ts:419-431 (handler)MCP server dispatch handler that validates input arguments and delegates to the WhoopApiClient.case 'whoop-get-sleep-by-id': { if (!args || typeof args.sleepId !== 'string') { throw new Error('sleepId is required and must be a string'); } const result = await this.whoopClient.getSleepById(args.sleepId); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], };
- src/mcp-server.ts:159-171 (registration)Tool registration in the MCP server, defining name, description, and input schema.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'], }, },
- src/types.ts:95-107 (schema)TypeScript interface for the output type WhoopSleep, defining the structure of the sleep record data.export interface WhoopSleep { id: string; v1_id: number; user_id: number; created_at: string; updated_at: string; start: string; end: string; timezone_offset: string; nap: boolean; score_state: string; score?: WhoopSleepScore; }