get-activity-weather
Retrieve weather conditions recorded during a specific activity by providing its activity ID.
Instructions
Get weather conditions during an activity
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| activityId | Yes | The activity ID |
Implementation Reference
- src/tools.ts:245-258 (registration)Registration + handler for the get-activity-weather tool. Defined via server.tool() with a Zod schema (activityId: string) and an async handler that calls the Garmin API endpoint activity-service/activity/{activityId}/weather.
server.tool( "get-activity-weather", "Get weather conditions during an activity", { activityId: z.string().describe("The activity ID"), }, async ({ activityId }) => { const client = getClient(); const data = await client.get( `activity-service/activity/${activityId}/weather` ); return jsonResult(data); } ); - src/tools.ts:248-250 (schema)Input schema for get-activity-weather: takes a single required string parameter 'activityId'.
{ activityId: z.string().describe("The activity ID"), }, - src/tools.ts:251-258 (handler)Handler function that gets a GarminClient via getClient(), makes a GET request to activity-service/activity/{activityId}/weather, and returns the JSON result.
async ({ activityId }) => { const client = getClient(); const data = await client.get( `activity-service/activity/${activityId}/weather` ); return jsonResult(data); } ); - src/tools.ts:32-39 (helper)Helper function getClient() checks for an existing session, then returns the shared GarminClient instance used by the handler.
function getClient() { if (!sessionExists()) { throw new Error( "No Garmin session found. The user needs to run: npx garmin-connect-mcp login" ); } return getSharedClient(); } - src/tools.ts:14-18 (helper)Helper jsonResult() formats the API response as a JSON text content block, used by the handler.
function jsonResult(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; }