get_device_solar_data
Retrieve solar charging data from your Garmin device for a specified date range. Monitor solar energy contribution to battery life.
Instructions
Get solar charging data for solar-equipped Garmin devices
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | Yes | The Garmin device ID | |
| startDate | Yes | Start date in YYYY-MM-DD format | |
| endDate | Yes | End date in YYYY-MM-DD format |
Implementation Reference
- src/client/garmin.client.ts:476-481 (handler)The handler function that executes the tool logic: makes an HTTP request to the Garmin Connect API endpoint for solar data, passing deviceId, startDate, endDate, and optionally a singleDayView flag.
async getDeviceSolarData(deviceId: string, startDate: string, endDate: string): Promise<unknown> { const singleDay = startDate === endDate ? '&singleDayView=true' : ''; return this.request( `${DEVICE_SOLAR_ENDPOINT}/${deviceId}?startDate=${startDate}&endDate=${endDate}${singleDay}`, ); } - src/dtos/devices.dto.ts:18-22 (schema)Input validation schema using Zod: defines deviceId (string), startDate and endDate (YYYY-MM-DD format strings).
export const getDeviceSolarSchema = z.object({ deviceId: z.string().describe('The Garmin device ID'), startDate: dateString.describe('Start date in YYYY-MM-DD format'), endDate: dateString.describe('End date in YYYY-MM-DD format'), }); - src/tools/profile.tools.ts:92-104 (registration)Registration of the 'get_device_solar_data' tool on the MCP server with description and input schema, delegating to the client handler.
server.registerTool( 'get_device_solar_data', { description: 'Get solar charging data for solar-equipped Garmin devices', inputSchema: getDeviceSolarSchema.shape, }, async ({ deviceId, startDate, endDate }) => { const data = await client.getDeviceSolarData(deviceId, startDate, endDate); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, ); - src/constants/validations.ts:1-3 (helper)Reusable Zod validation for date strings in YYYY-MM-DD format, used by the device solar schema.
import { z } from 'zod'; export const dateString = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Must be YYYY-MM-DD format'); - API endpoint constant DEVICE_SOLAR_ENDPOINT = '/web-gateway/solar' used by the handler to make the HTTP request.
export const DEVICE_SOLAR_ENDPOINT = '/web-gateway/solar';