Skip to main content
Glama
lucas-1000

MCP Glucose Server

by lucas-1000

get_latest_glucose

Retrieve the most recent glucose reading for a user, including value, unit, timestamp, and source, to monitor blood sugar levels for diabetes management.

Instructions

Get the most recent glucose/blood sugar reading for a user. Returns value, unit, timestamp, and source.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdNoUser identifier. Defaults to user_12345abcdef67890 if not specified.

Implementation Reference

  • Core handler implementation in HealthDataAPI class. Fetches the latest glucose reading via HTTP GET to backend /api/samples/latest endpoint, handles 404 by returning null, maps response to GlucoseReading interface.
    async getLatestGlucose(userId: string): Promise<GlucoseReading | null> {
      try {
        const response = await this.client.get('/api/samples/latest', {
          params: {
            userId,
            type: 'BloodGlucose',
          },
        });
    
        const sample = response.data;
        return {
          value: sample.value,
          unit: sample.unit,
          date: sample.start_date,
          source: sample.source,
        };
      } catch (error: any) {
        if (error.response?.status === 404) {
          return null;
        }
        throw error;
      }
    }
  • Type definition for GlucoseReading, used as return type for getLatestGlucose and structure for response data.
    export interface GlucoseReading {
      value: number;
      unit: string;
      date: string;
      source: string;
  • src/index.ts:57-71 (registration)
    MCP Tool registration in stdio server, defines name, description, and input schema for get_latest_glucose.
    {
      name: 'get_latest_glucose',
      description:
        'Get the most recent glucose/blood sugar reading for a user. Returns value, unit, timestamp, and source.',
      inputSchema: {
        type: 'object',
        properties: {
          userId: {
            type: 'string',
            description: `User identifier. Defaults to ${DEFAULT_USER_ID || 'configured user'} if not specified.`,
          },
        },
        required: [],
      },
    },
  • MCP tool call dispatcher in stdio server. Calls api.getLatestGlucose, handles null response, formats JSON output for MCP response.
    case 'get_latest_glucose': {
      const reading = await api.getLatestGlucose(userId);
    
      if (!reading) {
        return {
          content: [
            {
              type: 'text',
              text: 'No glucose readings found for this user.',
            },
          ],
        };
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(
              {
                value: reading.value,
                unit: reading.unit,
                date: reading.date,
                source: reading.source,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • MCP Tool registration in HTTP SSE server.
    name: 'get_latest_glucose',
    description:
      'Get the most recent glucose/blood sugar reading for a user. Returns value, unit, timestamp, and source.',
    inputSchema: {
      type: 'object',
      properties: {
        userId: {
          type: 'string',
          description: `User identifier. Defaults to ${DEFAULT_USER_ID || 'configured user'} if not specified.`,
        },
      },
      required: [],
    },

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