Skip to main content
Glama

get_glucose_trends

Read-only

Analyzes glucose data to detect patterns like dawn phenomenon, meal responses, and overnight stability. Identifies recurring issues that may require treatment adjustments.

Instructions

Analyze glucose patterns including dawn phenomenon (early morning rise), meal responses, and overnight stability. Helps identify recurring patterns that may need attention or treatment adjustments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
periodNoAnalysis period for pattern detection. Default: weekly. Use daily for detailed patterns, weekly for typical patterns.

Implementation Reference

  • src/index.ts:127-144 (registration)
    Tool 'get_glucose_trends' is registered in the tools array with its name, description, and inputSchema. The schema accepts an optional 'period' parameter (enum: daily/weekly/monthly, default: weekly).
    {
      name: 'get_glucose_trends',
      description: 'Analyze glucose patterns including dawn phenomenon (early morning rise), meal responses, and overnight stability. Helps identify recurring patterns that may need attention or treatment adjustments.',
      inputSchema: {
        type: 'object',
        properties: {
          period: {
            type: 'string',
            enum: ['daily', 'weekly', 'monthly'],
            description: 'Analysis period for pattern detection. Default: weekly. Use daily for detailed patterns, weekly for typical patterns.'
          }
        },
        required: []
      },
      annotations: {
        readOnlyHint: true
      }
    },
  • Handler for 'get_glucose_trends' tool in the CallToolRequestSchema switch. It takes the period argument, fetches glucose history data from the LibreLink client for the relevant number of days, then calls analytics.analyzeTrends() to get the trend analysis.
    case 'get_glucose_trends': {
      if (!client || !analytics) {
        throw new Error('LibreLinkUp not configured. Use configure_credentials first.');
      }
    
      const period = (args?.period as 'daily' | 'weekly' | 'monthly') || 'weekly';
      const daysToAnalyze = period === 'daily' ? 1 : period === 'weekly' ? 7 : 30;
      const readings = await client.getGlucoseHistory(daysToAnalyze * 24);
      const trends = analytics.analyzeTrends(readings, period);
    
      return {
        content: [{
          type: 'text',
          text: JSON.stringify({
            period: period,
            patterns: trends.patterns,
            dawn_phenomenon: trends.dawnPhenomenon,
            meal_response_average: trends.mealResponse,
            overnight_stability: trends.overnightStability
          }, null, 2)
        }]
      };
    }
  • The analyzeTrends() method in GlucoseAnalytics class performs the actual trend analysis. It groups readings by hour, detects dawn phenomenon, calculates overnight stability (stdev), analyzes meal responses (average rise after breakfast/lunch/dinner), checks time-in-range, and measures variability.
    analyzeTrends(readings: GlucoseReading[], period: 'daily' | 'weekly' | 'monthly'): GlucoseTrends {
      const patterns: string[] = [];
      let dawnPhenomenon = false;
      let mealResponse = 0;
      let overnightStability = 0;
    
      if (readings.length === 0) {
        return { patterns, dawnPhenomenon, mealResponse, overnightStability };
      }
    
      // Group readings by hour of day
      const byHour = this.groupByHour(readings);
    
      // Check for dawn phenomenon (rise between 3am-8am)
      dawnPhenomenon = this.detectDawnPhenomenon(byHour);
      if (dawnPhenomenon) {
        patterns.push('Dawn phenomenon detected - glucose rises in early morning');
      }
    
      // Calculate overnight stability (10pm-6am)
      overnightStability = this.calculateOvernightStability(byHour);
      if (overnightStability < 10) {
        patterns.push('Excellent overnight glucose stability');
      } else if (overnightStability < 20) {
        patterns.push('Good overnight glucose stability');
      } else {
        patterns.push('Variable overnight glucose - consider reviewing evening routine');
      }
    
      // Analyze meal responses (approximate based on typical meal times)
      mealResponse = this.analyzeMealResponse(byHour);
      if (mealResponse < 30) {
        patterns.push('Good postprandial glucose control');
      } else if (mealResponse < 50) {
        patterns.push('Moderate postprandial glucose rises');
      } else {
        patterns.push('High postprandial glucose spikes - consider meal composition');
      }
    
      // Check time in range trend
      const stats = this.calculateGlucoseStats(readings);
      if (stats.timeInRange >= 70) {
        patterns.push(`Excellent time in range: ${stats.timeInRange.toFixed(1)}%`);
      } else if (stats.timeInRange >= 50) {
        patterns.push(`Good time in range: ${stats.timeInRange.toFixed(1)}%`);
      } else {
        patterns.push(`Time in range needs improvement: ${stats.timeInRange.toFixed(1)}%`);
      }
    
      // Check variability
      if (stats.coefficientOfVariation < 33) {
        patterns.push('Low glucose variability - stable control');
      } else {
        patterns.push('High glucose variability - consider consistency improvements');
      }
    
      return {
        patterns,
        dawnPhenomenon,
        mealResponse: Math.round(mealResponse * 100) / 100,
        overnightStability: Math.round(overnightStability * 100) / 100
      };
    }
  • Helper method groupByHour() that groups glucose readings by the hour of day (0-23) for pattern analysis.
    private groupByHour(readings: GlucoseReading[]): Map<number, number[]> {
      const byHour = new Map<number, number[]>();
    
      for (let i = 0; i < 24; i++) {
        byHour.set(i, []);
      }
    
      for (const reading of readings) {
        const hour = new Date(reading.timestamp).getHours();
        const values = byHour.get(hour) || [];
        values.push(reading.value);
        byHour.set(hour, values);
      }
    
      return byHour;
    }
  • The GlucoseTrends interface defines the return type for analyzeTrends() with fields: patterns (string array), dawnPhenomenon (boolean), mealResponse (number), overnightStability (number).
    export interface GlucoseTrends {
      patterns: string[];
      dawnPhenomenon: boolean;
      mealResponse: number;
      overnightStability: number;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only indicate read-only; description adds meaningful behavioral context by specifying the types of patterns analyzed (dawn phenomenon, meal responses, overnight stability), which goes beyond structured fields.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with purpose and examples, no fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers the main purpose and pattern types, but lacks details on return format or how results are presented, which would be helpful since there is no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema fully describes the period parameter (enum, description), so description adds no additional semantic value. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it analyzes glucose patterns, listing specific examples (dawn phenomenon, meal responses, overnight stability), and distinguishes from sibling tools that focus on raw data or statistics.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says it helps identify recurring patterns needing attention, implying when to use, but does not explicitly exclude scenarios or mention alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sedoglia/librelink-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server