Skip to main content
Glama
lucas-1000

MCP Glucose Server

by lucas-1000

get_glucose_stats

Calculate glucose statistics including count, average, minimum, and maximum values for a user within a specified date range to analyze trends and patterns.

Instructions

Get glucose statistics (count, average, min, max) for a user within a date range. Useful for understanding glucose trends and patterns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdNoUser identifier. Defaults to user_12345abcdef67890 if not specified.
startDateNoStart date in ISO 8601 format. Optional.
endDateNoEnd date in ISO 8601 format. Optional.

Implementation Reference

  • Core tool logic: Fetches glucose statistics (count, avg, min, max, unit) from backend API /api/samples/stats endpoint using query params for userId, date range, and BloodGlucose type.
    async getGlucoseStats(params: {
      userId: string;
      startDate?: string;
      endDate?: string;
    }): Promise<GlucoseStats | null> {
      try {
        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);
    
        const response = await this.client.get(`/api/samples/stats?${queryParams}`);
    
        return {
          count: parseInt(response.data.count),
          average: parseFloat(response.data.average),
          min: parseFloat(response.data.min),
          max: parseFloat(response.data.max),
          unit: response.data.unit,
        };
      } catch (error: any) {
        if (error.response?.status === 404) {
          return null;
        }
        throw error;
      }
    }
  • MCP stdio server tool handler: Dispatches get_glucose_stats calls to api.getGlucoseStats, handles null response, and returns JSON-formatted stats.
    case 'get_glucose_stats': {
      const stats = await api.getGlucoseStats({
        userId,
        startDate: args?.startDate as string | undefined,
        endDate: args?.endDate as string | undefined,
      });
    
      if (!stats) {
        return {
          content: [
            {
              type: 'text',
              text: 'No glucose data found for the specified time range.',
            },
          ],
        };
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(stats, null, 2),
          },
        ],
      };
    }
  • src/index.ts:72-95 (registration)
    Tool registration in stdio server's tools list: Defines name, description, and inputSchema (userId optional, startDate/endDate optional).
      {
        name: 'get_glucose_stats',
        description:
          'Get glucose statistics (count, average, min, max) for a user within a date range. Useful for understanding glucose trends and patterns.',
        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. Optional.',
            },
            endDate: {
              type: 'string',
              description: 'End date in ISO 8601 format. Optional.',
            },
          },
          required: [],
        },
      },
    ];
  • TypeScript interface defining the output schema for glucose statistics returned by getGlucoseStats.
    export interface GlucoseStats {
      count: number;
      average: number;
      min: number;
      max: number;
      unit: string;
    }
  • HTTP SSE server tool handler: Similar to index.ts, calls api.getGlucoseStats with logging.
    case 'get_glucose_stats': {
      console.log(`📊 Fetching glucose stats for user: ${userId}`);
      const stats = await api.getGlucoseStats({
        userId,
        startDate: args?.startDate as string | undefined,
        endDate: args?.endDate as string | undefined,
      });
    
      if (!stats) {
        return {
          content: [
            {
              type: 'text',
              text: 'No glucose data found for the specified time range.',
            },
          ],
        };
      }
    
      console.log(`✅ Glucose stats: avg ${stats.average} ${stats.unit}`);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(stats, null, 2),
          },
        ],
      };
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It implies a read-only operation ('Get') and adds useful context about the purpose ('understanding glucose trends and patterns'), but doesn't disclose behavioral traits like authentication requirements, rate limits, error handling, or what happens if parameters are omitted. The description doesn't contradict annotations (none provided).

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?

The description is appropriately sized with two sentences: the first states the purpose and parameters, and the second adds contextual value about usage. Every sentence earns its place, and it's front-loaded with the core functionality.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is adequate but has gaps. It covers the purpose and usage context well, but lacks details on behavioral aspects (e.g., authentication, errors) and doesn't explain the return format (statistics structure), which is important since there's 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?

Schema description coverage is 100%, so the schema already documents all three parameters (userId, startDate, endDate) with their types and optionality. The description adds marginal value by implying date-range filtering and user-specific statistics, but doesn't provide additional syntax, format details, or examples beyond what the schema specifies.

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?

The description clearly states the specific action ('Get glucose statistics') and resource ('for a user within a date range'), listing the exact metrics (count, average, min, max). It distinguishes from sibling tools like 'get_glucose_readings' and 'get_latest_glucose' by focusing on aggregated statistics rather than raw readings or latest values.

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?

The description provides clear context ('Useful for understanding glucose trends and patterns'), indicating when this tool is appropriate. However, it doesn't explicitly state when to use alternatives like 'get_glucose_readings' or 'get_latest_glucose', nor does it mention exclusions or prerequisites.

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/lucas-1000/mcp-glucose'

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