feat: add get_devices, get_gear, and get_user_profile tools
This commit is contained in:
48
server.py
48
server.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user