# LibreLink Up (CGM) — how to use (mcp.ai)

Leituras de glicose do teu sensor LibreLink Up: gráfico, logbook, estatísticas e resumos (apenas leitura). Ligação segura e com o teu consentimento, a tua senha não fica guardada.

## Option A — via MCP (recommended)
Remote MCP endpoint (HTTP, streamable): `https://api.mcp.ai/p_librelink?ms=1781044800000`
Add it as a custom/remote MCP connector in your client (Claude, Cursor, VS Code…), then authenticate when prompted. Once connected, ask the agent to use the server's tools (e.g. `librelink_get_connection`).

## Option B — via direct REST API
Base URL: `https://api.mcp.ai/api/librelink`
Auth: `Authorization: Bearer sk_live_…` — create a workspace API key at https://mcp.ai/settings/api-keys
Discover endpoints: `GET https://api.mcp.ai/api/librelink/_endpoints`

### Endpoints
- `POST https://api.mcp.ai/api/librelink/get/connection` — Get a specific LibreLink Up connection by patient (returns target range, sensor info, latest glucose measurement envelope). Read-only CGM data — not for medical decisions without clinician review.
  - body: { patient_id?: string, account?: string, patient_ids?: string[] }
- `POST https://api.mcp.ai/api/librelink/get/current/glucose` — Get the latest single glucose reading for a connection (value, trend, color, isHigh/isLow flags). Read-only CGM data — not for medical decisions without clinician review.
  - body: { patient_id?: string, account?: string, patient_ids?: string[] }
- `POST https://api.mcp.ai/api/librelink/get/glucose/graph` — Get the high-resolution ~12h glucose graph for a connection (raw graphData array of measurement points). Read-only CGM data — not for medical decisions without clinician review.
  - body: { patient_id?: string, account?: string, patient_ids?: string[] }
- `POST https://api.mcp.ai/api/librelink/get/glucose/logbook` — Get the manual-scan logbook for a connection (~14 days of spot readings and notes). Read-only CGM data — not for medical decisions without clinician review.
  - body: { patient_id?: string, account?: string, patient_ids?: string[] }
- `POST https://api.mcp.ai/api/librelink/get/glucose/stats` — Compute time-in-range, average, min/max, and latest-point snapshot from the current graph window (~12h) for a connection. Defaults: target 70-180 mg/dL. Read-only CGM data — not for medical decisions 
  - body: { patient_id?: string, target_low?: number, target_high?: number, account?: string, patient_ids?: string[] }
- `POST https://api.mcp.ai/api/librelink/get/last/hours` — Last N hours of normalized points [{ ts, mg_dl, trend }] from the current graph window (max ~12h). Read-only CGM data — not for medical decisions without clinician review.
  - body: { patient_id?: string, hours?: integer, account?: string, patient_ids?: string[] }
- `POST https://api.mcp.ai/api/librelink/get/latest/reading` — Normalized latest reading: { mg_dl, trend_arrow, timestamp, minutes_ago, has_active_sensor }. Read-only CGM data — not for medical decisions without clinician review.
  - body: { patient_id?: string, account?: string, patient_ids?: string[] }
- `POST https://api.mcp.ai/api/librelink/get/today/summary` — Same shape as librelink_get_glucose_stats but filtered to "today" in a chosen IANA timezone, plus hypo_events_70 / hyper_events_180 counts. Read-only CGM data — not for medical decisions without clini
  - body: { patient_id?: string, timezone?: string, target_low?: number, target_high?: number, account?: string, patient_ids?: string[] }
- `POST https://api.mcp.ai/api/librelink/list/accounts` — List patients linked to this install (id = patient_id, label, name). Read-only CGM data — not for medical decisions without clinician review.
  - body: { account?: string }
- `POST https://api.mcp.ai/api/librelink/list/connections` — List patients whose LibreLink Up readings are accessible to this install (alias of librelink_list_accounts; same data). Read-only CGM data — not for medical decisions without clinician review.
  - body: { account?: string }

## Example prompts
- "Qual minha glicose agora e o resumo de hoje?"
- "Mostre o gráfico das últimas 6 horas"
- "Calcule meu tempo no alvo na última semana"

## More
- Page: https://mcp.ai/librelink
- Agent spec (llms.txt): https://mcp.ai/librelink/llms.txt
- Postman collection: https://mcp.ai/librelink/postman.json
