Skip to main content
Glama
lucas-1000

MCP Glucose Server

by lucas-1000
README.md
# MCP Glucose Server

A Model Context Protocol (MCP) server that provides glucose data query tools to AI assistants like Claude and ChatGPT. Connects to the `health-data-storage` API to retrieve glucose readings.

## 🎯 Purpose

This MCP server acts as a **specialized interface** between AI assistants and your glucose data. It provides natural language tools for querying glucose levels, trends, and statistics.

## πŸ—οΈ Architecture Position

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ health-data-storage  β”‚
β”‚  REST API            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚ HTTP GET
           β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ mcp-glucose  β”‚  ← YOU ARE HERE
    β”‚ (MCP Server) β”‚
    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚ MCP Tools
           β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ Claude/ChatGPTβ”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## πŸ”§ Available Tools

### 1. `get_glucose_readings`
Get glucose readings within a date range.

**Parameters:**
- `userId` (optional): User identifier (defaults to USER_ID env var)
- `startDate` (optional): Start date in ISO 8601 format
- `endDate` (optional): End date in ISO 8601 format
- `limit` (optional): Maximum number of readings (default: 1000)

**Example queries:**
- "What's my glucose been like today?"
- "Show me my glucose readings for the past week"
- "Get my glucose levels from October 1st to October 22nd"

### 2. `get_latest_glucose`
Get the most recent glucose reading.

**Parameters:**
- `userId` (optional): User identifier (defaults to USER_ID env var)

**Example queries:**
- "What's my current glucose?"
- "What was my last glucose reading?"
- "Check my latest blood sugar"

### 3. `get_glucose_stats`
Get glucose statistics (count, average, min, max) for a time period.

**Parameters:**
- `userId` (optional): User identifier (defaults to USER_ID env var)
- `startDate` (optional): Start date in ISO 8601 format
- `endDate` (optional): End date in ISO 8601 format

**Example queries:**
- "What's my average glucose this week?"
- "Show me my glucose stats for the past month"
- "What was my glucose range yesterday?"

## πŸš€ Setup

### Prerequisites
- Node.js 20+
- Access to a deployed `health-data-storage` instance
- API secret for authentication

### Installation

```bash
# Install dependencies
npm install

# Build TypeScript
npm run build
```

### Configuration

Create a `.env` file (or set environment variables):

```bash
STORAGE_API_URL=https://your-storage-api.run.app
API_SECRET=your-api-secret
USER_ID=user@example.com  # Optional default user
```

### Usage with Claude Desktop

Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "glucose": {
      "command": "node",
      "args": ["/path/to/mcp-glucose/build/index.js"],
      "env": {
        "STORAGE_API_URL": "https://your-storage-api.run.app",
        "API_SECRET": "your-api-secret",
        "USER_ID": "user@example.com"
      }
    }
  }
}
```

Restart Claude Desktop.

### Usage with ChatGPT

*(ChatGPT MCP support coming soon)*

## πŸ’¬ Example Conversations

Once configured, you can ask Claude:

**Simple queries:**
> "What's my latest glucose?"

```json
{
  "value": 95,
  "unit": "mg/dL",
  "date": "2025-10-22T10:30:00Z",
  "source": "Lingo"
}
```

**Time range queries:**
> "Show me my glucose for the past 24 hours"

```json
{
  "count": 48,
  "readings": [
    { "value": 95, "unit": "mg/dL", "date": "2025-10-22T10:30:00Z", "source": "Lingo" },
    ...
  ]
}
```

**Statistical queries:**
> "What's my average glucose this week?"

```json
{
  "count": 336,
  "average": 98.5,
  "min": 75,
  "max": 125,
  "unit": "mg/dL"
}
```

**Analysis queries:**
> "Analyze my glucose patterns over the last month"

Claude will use the tools to fetch data and provide intelligent analysis of your glucose trends, patterns, and insights.

## πŸ”— Related Projects

- **health-data-storage**: Storage backend that this server queries
- **health-tracking-app**: iOS app that collects the glucose data
- **mcp-activity**: (future) MCP server for activity/exercise data
- **mcp-nutrition**: (future) MCP server for food/nutrition data

## πŸ“ˆ Future Enhancements

Potential additions:
- **Trend analysis tools**: Detect glucose spikes, patterns
- **Correlation tools**: Compare glucose with meals, exercise
- **Alert tools**: Notify when glucose is out of range
- **Export tools**: Generate reports, charts
- **Multi-user support**: Query data for multiple users

## πŸ› οΈ Development

### Local Testing

```bash
# Build
npm run build

# Run (will use stdio transport)
npm start
```

The server runs on stdio (standard input/output) as per MCP specification. Use it with Claude Desktop or the MCP inspector for testing.

### Testing with MCP Inspector

```bash
npm install -g @modelcontextprotocol/inspector
npx @modelcontextprotocol/inspector node build/index.js
```

## πŸ“ License

MIT

TDQS

A3.6/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: get_glucose_readings retrieves raw readings, get_glucose_stats provides aggregated statistics, and get_latest_glucose fetches the single most recent reading. There is no overlap in functionality, making it easy for an agent to select the appropriate tool based on the specific need.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with 'get_' as the prefix and descriptive nouns (readings, stats, latest_glucose). The naming is uniform, predictable, and enhances readability, ensuring agents can easily understand and use the toolset.

Tool Count4/5

With 3 tools, the server is well-scoped for its glucose monitoring purpose, covering key retrieval operations. However, it feels slightly thin as it lacks tools for creating, updating, or deleting glucose data, which might be expected in a full CRUD lifecycle, though this is reasonable for a read-only server.

Completeness3/5

The toolset is complete for read-only operations, offering raw data, statistics, and the latest reading. However, there are notable gaps in the surface, such as missing create, update, or delete tools, which limits agents to retrieval-only workflows and could cause failures in scenarios requiring data modification.

Maintenance

ActivityInactive
ResponsivenessNo issues