|
7 | 7 | from mcp.server.fastmcp import FastMCP |
8 | 8 |
|
9 | 9 |
|
10 | | -__version__ = "0.0.9" |
| 10 | +__version__ = "0.0.10.dev0" |
11 | 11 |
|
12 | 12 | # Type alias for functions that return data from garth.connectapi |
13 | 13 | ConnectAPIResponse = str | dict | list | int | float | bool | None |
@@ -155,24 +155,44 @@ def daily_sleep( |
155 | 155 |
|
156 | 156 | @server.tool() |
157 | 157 | @requires_garth_session |
158 | | -def get_activities( |
159 | | - start_date: str | None = None, limit: int | None = None |
160 | | -) -> ConnectAPIResponse: |
161 | | - """ |
162 | | - Get list of activities from Garmin Connect. |
163 | | - start_date: Start date for activities (YYYY-MM-DD format) |
164 | | - limit: Maximum number of activities to return |
165 | | - """ |
166 | | - params = {} |
167 | | - if start_date: |
168 | | - params["startDate"] = start_date |
169 | | - if limit: |
170 | | - params["limit"] = str(limit) |
171 | | - |
| 158 | +def get_activities(start: int = 0, limit: int = 20) -> ConnectAPIResponse: |
| 159 | + """ |
| 160 | + Lists activities from Garmin Connect. |
| 161 | +
|
| 162 | + Parameters |
| 163 | + ---------- |
| 164 | + start : int, optional |
| 165 | + The zero-based index in the activity list from which to start returning results (default: 0). |
| 166 | + limit : int, optional |
| 167 | + The maximum number of activities to retrieve starting from 'start' (default: 20). |
| 168 | +
|
| 169 | + Returns |
| 170 | + ------- |
| 171 | + activities : list |
| 172 | + List of activity records. |
| 173 | +
|
| 174 | + Notes |
| 175 | + ----- |
| 176 | + Use 'start' and 'limit' to paginate through your activities, e.g. set start=0, limit=20 for the first page, |
| 177 | + start=20, limit=20 for the next page, etc. |
| 178 | + """ |
| 179 | + params = { |
| 180 | + "start": start, |
| 181 | + "limit": limit, |
| 182 | + } |
172 | 183 | endpoint = "activitylist-service/activities/search/activities" |
173 | | - if params: |
174 | | - endpoint += "?" + urlencode(params) |
175 | | - return garth.connectapi(endpoint) |
| 184 | + endpoint += "?" + urlencode(params) |
| 185 | + activities = garth.connectapi(endpoint) |
| 186 | + |
| 187 | + # remove user roles and profile image urls |
| 188 | + for activity in activities: |
| 189 | + activity.pop("userRoles") |
| 190 | + activity.pop("ownerDisplayName") |
| 191 | + activity.pop("ownerProfileImageUrlSmall") |
| 192 | + activity.pop("ownerProfileImageUrlMedium") |
| 193 | + activity.pop("ownerProfileImageUrlLarge") |
| 194 | + |
| 195 | + return activities |
176 | 196 |
|
177 | 197 |
|
178 | 198 | @server.tool() |
|
0 commit comments