Skip to main content
Glama
Schimmilab

Withings MCP Server

by Schimmilab

get_sleep_summary

Retrieve sleep summary data including duration, deep sleep, REM, wake count, apnea, and breathing disturbances for specified dates.

Instructions

Get sleep summary data (duration, deep sleep, REM, wake up count, breathing disturbances, apnea, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startdateymdNoStart date in YYYY-MM-DD format
enddateymdNoEnd date in YYYY-MM-DD format
lastupdateNoGet sleep data modified since this timestamp
data_fieldsNoComma-separated list of data fields to include (e.g., 'breathing_disturbances_intensity,apnea_hypopnea_index,snoring,rr_average'). If not specified, returns default fields.

Implementation Reference

  • The async method _get_sleep_summary that implements the sleep summary tool logic. It builds API parameters (action=getsummary, startdateymd, enddateymd, lastupdate, data_fields) and calls the Withings /v2/sleep endpoint.
    async def _get_sleep_summary(self, args: dict) -> dict:
        """Get sleep summary."""
        params = {"action": "getsummary"}
    
        if "startdateymd" in args:
            params["startdateymd"] = args["startdateymd"]
        if "enddateymd" in args:
            params["enddateymd"] = args["enddateymd"]
        if "lastupdate" in args:
            params["lastupdate"] = self._parse_date(args["lastupdate"])
        if "data_fields" in args:
            params["data_fields"] = args["data_fields"]
    
        return await self._make_request("/v2/sleep", params)
  • The Tool registration with inputSchema for get_sleep_summary. Defines parameters: startdateymd, enddateymd, lastupdate, data_fields.
    Tool(
        name="get_sleep_summary",
        description="Get sleep summary data (duration, deep sleep, REM, wake up count, breathing disturbances, apnea, etc.)",
        inputSchema={
            "type": "object",
            "properties": {
                "startdateymd": {
                    "type": "string",
                    "description": "Start date in YYYY-MM-DD format",
                },
                "enddateymd": {
                    "type": "string",
                    "description": "End date in YYYY-MM-DD format",
                },
                "lastupdate": {
                    "type": "string",
                    "description": "Get sleep data modified since this timestamp",
                },
                "data_fields": {
                    "type": "string",
                    "description": "Comma-separated list of data fields to include (e.g., 'breathing_disturbances_intensity,apnea_hypopnea_index,snoring,rr_average'). If not specified, returns default fields.",
                },
            },
        },
    ),
  • The dispatch routing that maps the tool name 'get_sleep_summary' to the handler method _get_sleep_summary.
    elif name == "get_sleep_summary":
        result = await self._get_sleep_summary(arguments)
  • The _make_request helper used by _get_sleep_summary. It performs the authenticated HTTP request to the Withings API endpoint with token refresh on 401.
    async def _make_request(self, endpoint: str, params: dict, retry_on_401: bool = True) -> dict:
        """Make authenticated request to Withings API."""
        headers = self.auth.get_headers()
        async with httpx.AsyncClient() as client:
            response = await client.get(
                f"{self.base_url}{endpoint}",
                headers=headers,
                params=params,
            )
    
            # Don't raise for status yet - check for 401 first
            data = response.json()
    
            # Handle 401 - token expired, try refresh and retry once
            if data.get("status") == 401 and retry_on_401:
                await self.auth.refresh_access_token()
                # Retry the request with new token
                return await self._make_request(endpoint, params, retry_on_401=False)
    
            # Check for other API errors
            if data.get("status") != 0:
                raise Exception(f"API error: {data}")
    
            return data.get("body", {})
Behavior2/5

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

No annotations provided. The description only lists data fields and does not disclose behavioral traits such as read-only nature, authentication requirements, rate limits, or what happens when no data exists.

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

Conciseness4/5

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

Single sentence is concise and directly states purpose with examples, though it could be structured slightly better for readability.

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

Completeness3/5

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

The description provides a reasonable list of returned data but lacks explanation of date range behavior, pagination, or handling of missing data. No output schema exists, so description must carry more load.

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 coverage is 100% with descriptions for all parameters. The description adds examples for data_fields, but overall does not significantly enhance understanding beyond schema.

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 tool retrieves sleep summary data and lists typical data fields. However, it does not differentiate from sibling tools like get_sleep_details, which may provide more detailed sleep data.

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?

No guidance on when to use this tool versus alternatives. No context on required parameters or typical use cases, despite 0 required parameters.

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/Schimmilab/withings-mcp-server'

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