get_glucose_readings
Retrieve glucose readings for a user within a specified date range, returning values in mg/dL with timestamps and data sources for health monitoring.
Instructions
Get glucose/blood sugar readings for a user within a date range. Returns glucose values in mg/dL with timestamps and sources.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | No | User identifier. Defaults to user_12345abcdef67890 if not specified. | |
| startDate | No | Start date in ISO 8601 format (e.g., 2025-10-01T00:00:00Z). Optional. | |
| endDate | No | End date in ISO 8601 format (e.g., 2025-10-22T23:59:59Z). Optional. | |
| limit | No | Maximum number of readings to return (default: 1000) |
Implementation Reference
- src/index.ts:134-162 (handler)MCP tool handler for 'get_glucose_readings': extracts parameters, calls the API client, formats and returns the glucose readings as JSON.case 'get_glucose_readings': { const readings = await api.getGlucoseReadings({ userId, startDate: args?.startDate as string | undefined, endDate: args?.endDate as string | undefined, limit: (args?.limit as number) || 1000, }); return { content: [ { type: 'text', text: JSON.stringify( { count: readings.length, readings: readings.map((r) => ({ value: r.value, unit: r.unit, date: r.date, source: r.source, })), }, null, 2 ), }, ], }; }
- src/index.ts:30-56 (registration)Registration of the 'get_glucose_readings' tool in the MCP tools list, including name, description, and input schema.{ name: 'get_glucose_readings', description: 'Get glucose/blood sugar readings for a user within a date range. Returns glucose values in mg/dL with timestamps and sources.', inputSchema: { type: 'object', properties: { userId: { type: 'string', description: `User identifier. Defaults to ${DEFAULT_USER_ID || 'configured user'} if not specified.`, }, startDate: { type: 'string', description: 'Start date in ISO 8601 format (e.g., 2025-10-01T00:00:00Z). Optional.', }, endDate: { type: 'string', description: 'End date in ISO 8601 format (e.g., 2025-10-22T23:59:59Z). Optional.', }, limit: { type: 'number', description: 'Maximum number of readings to return (default: 1000)', }, }, required: [], }, },
- src/index.ts:34-56 (schema)Input schema definition for the 'get_glucose_readings' tool.inputSchema: { type: 'object', properties: { userId: { type: 'string', description: `User identifier. Defaults to ${DEFAULT_USER_ID || 'configured user'} if not specified.`, }, startDate: { type: 'string', description: 'Start date in ISO 8601 format (e.g., 2025-10-01T00:00:00Z). Optional.', }, endDate: { type: 'string', description: 'End date in ISO 8601 format (e.g., 2025-10-22T23:59:59Z). Optional.', }, limit: { type: 'number', description: 'Maximum number of readings to return (default: 1000)', }, }, required: [], }, },
- src/api-client.ts:46-69 (helper)Helper function in HealthDataAPI class that performs the HTTP request to fetch glucose readings from the backend API.async getGlucoseReadings(params: { userId: string; startDate?: string; endDate?: string; limit?: number; }): Promise<GlucoseReading[]> { const queryParams = new URLSearchParams({ userId: params.userId, type: 'BloodGlucose', }); if (params.startDate) queryParams.append('startDate', params.startDate); if (params.endDate) queryParams.append('endDate', params.endDate); if (params.limit) queryParams.append('limit', params.limit.toString()); const response = await this.client.get(`/api/samples?${queryParams}`); return response.data.samples.map((s: any) => ({ value: s.value, unit: s.unit, date: s.start_date, source: s.source, })); }