MCP Nightscout

MCP Nightscout

Connects AI assistants to Nightscout for real-time glucose monitoring, analysis, and treatment logging, enabling natural language interaction with CGM data.

Category
访问服务器

README

MCP Nightscout

An MCP (Model Context Protocol) server that connects AI assistants to Nightscout — the open-source CGM remote monitoring platform for Type 1 Diabetes management.

Built with FastMCP, this server exposes Nightscout data as MCP tools, enabling AI assistants like Claude to read glucose data, analyze patterns, log treatments, and more.

Features

Glucose Monitoring

  • get_current_glucose — latest CGM reading with value, trend arrow, and device info
  • get_recent_glucose — recent readings (default: last 3 hours)
  • get_glucose_by_date_range — readings for a specific date range

Analytics

  • calculate_time_in_range — TIR stats with breakdown (in range, below, above, very low, very high), estimated A1C, and coefficient of variation
  • get_daily_glucose_stats — daily stats with hourly averages
  • analyze_glucose_patterns — multi-day pattern analysis to identify recurring highs/lows by time of day

Treatments

  • get_recent_treatments — recent insulin boluses, carb entries, temp basals, notes
  • get_treatments_by_date — treatments for a specific date range
  • log_treatment — log a new treatment (bolus, carbs, exercise, note, etc.)
  • remove_treatment — delete a treatment by ID

Device & Profile

  • get_insulin_on_board — current IOB from loop/pump device status
  • get_latest_device_status — pump status, loop decisions, CGM status
  • server_status — Nightscout server version, plugins, thresholds, units
  • get_current_profile — basal rates, ISF, IC ratios, target BG, DIA
  • update_nightscout_profile — update profile settings

Quick Start

1. Clone and configure

git clone https://github.com/easyweek/mcp-nightscout.git
cd mcp-nightscout
cp .env.example .env

Edit .env with your Nightscout instance details:

NIGHTSCOUT_URL=https://your-nightscout.example.com
NIGHTSCOUT_TOKEN=your-readable-token
MCP_AUTH_TOKEN=your-secret-mcp-token

2. Run with Docker

docker compose up --build

The server starts on http://localhost:8000.

3. Connect to Claude

Claude Code (CLI)

Add to your MCP settings:

{
  "mcpServers": {
    "nightscout": {
      "type": "http",
      "url": "http://localhost:8000/mcp",
      "headers": {
        "Authorization": "Bearer your-secret-mcp-token"
      }
    }
  }
}

Claude.ai (remote)

When deployed to a public URL, connect using the token-in-path format:

https://your-server.example.com/mcp/your-secret-mcp-token

Authentication

The server supports two auth modes for MCP clients:

Method Format Use case
Bearer header Authorization: Bearer <token> Claude Code CLI
Token in path POST /mcp/<token> Claude.ai connectors

The /health endpoint is always open (no auth required).

Set MCP_AUTH_TOKEN to enable authentication. If unset, the server runs without auth (suitable for local development only).

Nightscout Authentication

Connect to your Nightscout instance using either:

  • API secret (NIGHTSCOUT_API_SECRET) — SHA1 hash of your plaintext secret:
    echo -n "your-secret" | shasum -a 1 | awk '{print $1}'
    
  • Readable token (NIGHTSCOUT_TOKEN) — created in Nightscout Admin Tools

Development

Run locally (without Docker)

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn src.server:app --host 0.0.0.0 --port 8000 --log-config src/log_config.yaml

Run tests

pip install pytest pytest-asyncio
pytest tests/

Project structure

src/
  server.py             # MCP tools, auth middleware, health endpoint
  nightscout_client.py  # HTTP client for Nightscout REST API v1
  log_filter.py         # Filters /health from access logs
  log_config.yaml       # JSON logging configuration
tests/
  test_auth.py          # Auth middleware tests

Adding a new tool

  1. Add the API call to src/nightscout_client.py if needed
  2. Add a @mcp.tool() function in src/server.py with a clear docstring
  3. Test with docker compose up --build

Environment Variables

Variable Required Default Description
NIGHTSCOUT_URL Yes — Nightscout instance base URL
NIGHTSCOUT_API_SECRET No* — API secret (SHA1 hash)
NIGHTSCOUT_TOKEN No* — Readable token
NIGHTSCOUT_TIMEOUT No 30 Request timeout in seconds
MCP_AUTH_TOKEN No — MCP server auth token

* One of NIGHTSCOUT_API_SECRET or NIGHTSCOUT_TOKEN is required.

License

MIT — Copyright (c) 2026 EasyWeek GmbH

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选