get_user_info
Fetch user account details and profile information from Withings for integration with health data.
Instructions
Get user information from Withings account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The actual handler function that executes the tool logic. Calls _make_request to Withings API endpoint /v2/user with action=getdevice.
async def _get_user_info(self) -> dict: """Get user information.""" return await self._make_request("/v2/user", {"action": "getdevice"}) - The tool registration with input schema (empty properties, no parameters required).
Tool( name="get_user_info", description="Get user information from Withings account", inputSchema={ "type": "object", "properties": {}, }, - src/withings_mcp_server/server.py:208-209 (registration)The call_tool handler that dispatches the 'get_user_info' name to the _get_user_info method.
if name == "get_user_info": result = await self._get_user_info() - The _make_request helper that performs authenticated HTTP GET requests to the Withings API, with automatic 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", {})