get_sleep_details
Retrieve detailed sleep analysis data including sleep phases from Withings Health API to monitor sleep patterns and quality over specified date ranges.
Instructions
Get detailed sleep data with all sleep phases
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| startdate | No | Start date (YYYY-MM-DD) or Unix timestamp | |
| enddate | No | End date (YYYY-MM-DD) or Unix timestamp |
Implementation Reference
- The core handler function `_get_sleep_details` that constructs the API parameters (action='get', startdate/enddate parsed to timestamps) and calls `_make_request` to the Withings `/v2/sleep` endpoint to retrieve detailed sleep data including phases.async def _get_sleep_details(self, args: dict) -> dict: """Get detailed sleep data.""" params = {"action": "get"} if "startdate" in args: params["startdate"] = self._parse_date(args["startdate"]) if "enddate" in args: params["enddate"] = self._parse_date(args["enddate"]) return await self._make_request("/v2/sleep", params)
- src/withings_mcp_server/server.py:124-140 (registration)Registration of the `get_sleep_details` tool in the `list_tools()` function, defining its name, description, and input schema for startdate and enddate parameters.Tool( name="get_sleep_details", description="Get detailed sleep data with all sleep phases", inputSchema={ "type": "object", "properties": { "startdate": { "type": "string", "description": "Start date (YYYY-MM-DD) or Unix timestamp", }, "enddate": { "type": "string", "description": "End date (YYYY-MM-DD) or Unix timestamp", }, }, }, ),
- Input schema definition for the `get_sleep_details` tool, specifying object type with optional startdate and enddate as strings (YYYY-MM-DD or Unix timestamp).inputSchema={ "type": "object", "properties": { "startdate": { "type": "string", "description": "Start date (YYYY-MM-DD) or Unix timestamp", }, "enddate": { "type": "string", "description": "End date (YYYY-MM-DD) or Unix timestamp", }, }, },
- Dispatch logic in the main `call_tool` handler that routes 'get_sleep_details' calls to the `_get_sleep_details` implementation.elif name == "get_sleep_details": result = await self._get_sleep_details(arguments)