get_current_glucose
Retrieve the most recent glucose reading from your FreeStyle Libre sensor. Returns current mg/dL value, trend direction, and whether within target range for real-time monitoring.
Instructions
Get the most recent glucose reading from your FreeStyle Libre sensor. Returns current glucose value in mg/dL, trend direction (rising/falling/stable), and whether the value is in target range. Use this for real-time glucose monitoring.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:253-272 (handler)Main tool handler for 'get_current_glucose'. Calls client.getCurrentGlucose() and returns a JSON response with current_glucose, timestamp, trend, status, and color.
case 'get_current_glucose': { if (!client) { throw new Error('LibreLinkUp not configured. Use configure_credentials first.'); } const reading = await client.getCurrentGlucose(); return { content: [{ type: 'text', text: JSON.stringify({ current_glucose: reading.value, timestamp: reading.timestamp, trend: reading.trend, status: reading.isHigh ? 'High' : reading.isLow ? 'Low' : 'Normal', color: reading.color }, null, 2) }] }; } - src/index.ts:80-91 (schema)Tool definition and input schema for 'get_current_glucose'. Has an empty input schema (no parameters) and readOnlyHint annotation.
const tools = [ { name: 'get_current_glucose', description: 'Get the most recent glucose reading from your FreeStyle Libre sensor. Returns current glucose value in mg/dL, trend direction (rising/falling/stable), and whether the value is in target range. Use this for real-time glucose monitoring.', inputSchema: { type: 'object', properties: {}, required: [] }, annotations: { readOnlyHint: true } - src/librelink-client.ts:399-407 (helper)LibreLinkClient.getCurrentGlucose() method. Fetches graph data and maps the current glucose measurement to a GlucoseReading via mapGlucoseItem().
/** * Get current glucose reading */ async getCurrentGlucose(): Promise<GlucoseReading> { const data = await this.getGraphData(); const current = data.connection.glucoseMeasurement; return mapGlucoseItem(current, this.config.targetLow, this.config.targetHigh); } - src/librelink-client.ts:71-84 (helper)mapGlucoseItem() helper that transforms raw API data (RawGlucoseItem) into a GlucoseReading with value, timestamp, trend, isHigh/isLow flags, and color.
/** * Convert raw glucose item to GlucoseReading */ function mapGlucoseItem(item: RawGlucoseItem, targetLow: number, targetHigh: number): GlucoseReading { return { value: item.ValueInMgPerDl, timestamp: item.Timestamp, trend: TREND_MAP[item.TrendArrow || 3] || 'Flat', trendArrow: item.TrendArrow || 3, isHigh: item.isHigh, isLow: item.isLow, color: getGlucoseColor(item.ValueInMgPerDl, targetLow, targetHigh) }; } - src/index.ts:243-245 (registration)Tool registration via ListToolsRequestSchema handler. Returns the tools array (which includes get_current_glucose) in response to list requests.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });