feat: add get_devices, get_gear, and get_user_profile tools

This commit is contained in:
Christophe Vila
2026-05-17 19:51:54 +02:00
parent ccfdbbaa86
commit c0d6713c3e
2 changed files with 97 additions and 0 deletions

View File

@@ -266,6 +266,54 @@ def get_daily_stats(date: str = "") -> str:
return f"Error fetching daily stats: {exc}"
@mcp.tool()
def get_devices() -> str:
"""List paired Garmin devices with model name and firmware version."""
if err := _check_auth():
return err
try:
result = _client.get_devices()
if not result:
return "No devices found."
return json.dumps(result, indent=2)
except GarminConnectAuthenticationError:
return "Authentication error. Call authenticate() again."
except Exception as exc:
return f"Error fetching devices: {exc}"
@mcp.tool()
def get_gear() -> str:
"""List gear items (shoes, bikes) with mileage and usage stats."""
if err := _check_auth():
return err
try:
result = _client.get_gear(_client.display_name)
if not result:
return "No gear found."
return json.dumps(result, indent=2)
except GarminConnectAuthenticationError:
return "Authentication error. Call authenticate() again."
except Exception as exc:
return f"Error fetching gear: {exc}"
@mcp.tool()
def get_user_profile() -> str:
"""Get Garmin user profile: display name, age, weight, and HR zones."""
if err := _check_auth():
return err
try:
result = _client.get_user_profile()
if not result:
return "No user profile found."
return json.dumps(result, indent=2)
except GarminConnectAuthenticationError:
return "Authentication error. Call authenticate() again."
except Exception as exc:
return f"Error fetching user profile: {exc}"
if __name__ == "__main__":
_startup_login()
mcp.run()