feat: add get_steps and get_daily_stats tools

This commit is contained in:
Christophe Vila
2026-05-17 19:50:36 +02:00
parent 9c46a531f3
commit ccfdbbaa86
2 changed files with 69 additions and 0 deletions

View File

@@ -232,6 +232,40 @@ def get_spo2(date: str = "") -> str:
return f"Error fetching SpO2 data: {exc}"
@mcp.tool()
def get_steps(date: str = "") -> str:
"""Get step count and daily goal for a date (YYYY-MM-DD). Defaults to today."""
if err := _check_auth():
return err
cdate = date or _today()
try:
result = _client.get_steps_data(cdate)
if not result:
return f"No steps data found for {cdate}"
return json.dumps(result, indent=2)
except GarminConnectAuthenticationError:
return "Authentication error. Call authenticate() again."
except Exception as exc:
return f"Error fetching steps data: {exc}"
@mcp.tool()
def get_daily_stats(date: str = "") -> str:
"""Get daily summary for a date (YYYY-MM-DD): calories, floors, intensity minutes. Defaults to today."""
if err := _check_auth():
return err
cdate = date or _today()
try:
result = _client.get_stats(cdate)
if not result:
return f"No daily stats found for {cdate}"
return json.dumps(result, indent=2)
except GarminConnectAuthenticationError:
return "Authentication error. Call authenticate() again."
except Exception as exc:
return f"Error fetching daily stats: {exc}"
if __name__ == "__main__":
_startup_login()
mcp.run()