Sapphire Wellness MCP Server
Sapphire Wellness MCP Server
一个 Python Model Context Protocol (MCP) 服务器,向 AI 助手提供来自 Sapphire Wellness App 的健康指标。
暴露的指标
指标 | 工具 | 数据点 |
活动 |
| 步数、卡路里、距离、活跃分钟数 |
血压 |
| 收缩压/舒张压(mmHg)、AHA 分类 |
血糖 |
| 血糖(mg/dL)、餐食背景、目标范围内时间 |
心率 |
| BPM 读数、平均/最小/最大、静息心率 |
睡眠 |
| 时长、深睡/浅睡/快速眼动/清醒阶段、效率 |
血氧 |
| 血氧饱和度 %、低饱和度事件计数 |
汇总 |
| 单次调用返回全部 6 项指标 |
Related MCP server: Sapphire Wellness MCP Server
架构
Agent Container
│ HTTP SSE
▼
sapphire-mcp:8000 ──asyncpg──▶ PostgreSQL:5432传输:HTTP SSE — 多容器部署所必需(stdio 仅在代理将 MCP 服务器作为子进程启动时有效)
数据库:PostgreSQL,使用 OpenTelemetry 风格的指标表(
time、metric_name、metric_value、attributes JSONB等)框架:FastMCP 搭配 Pydantic v2 响应模型
完整架构文档请参阅 Design.md。
项目结构
MCPServers/
├── sapphire_wellness/
│ ├── server.py # FastMCP app + SSE entry point
│ ├── config.py # Settings (DB_URL, HOST, PORT via env)
│ ├── models/ # Pydantic response models per metric
│ ├── db/ # asyncpg pool + shared base query
│ ├── repositories/ # DB → model mapping (one per metric)
│ └── tools/ # MCP tool definitions (one per metric)
├── Design.md # Architecture reference
├── pyproject.toml
├── Dockerfile
├── podman-compose.yml
└── .env.example前提条件
Python 3.11+
PostgreSQL 14+,并已创建 6 张健康指标表
podman-compose 或 Docker Compose(用于容器化部署)
快速开始
本地开发
# 1. Create and activate a virtual environment
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activate
# 2. Install dependencies
pip install -e .
# 3. Configure environment
cp .env.example .env
# Edit .env — set DB_URL to your PostgreSQL connection string
# 4. Run the server
python -m sapphire_wellness.server
# Server starts at http://0.0.0.0:8000容器化(podman-compose)
# Build and start all services (postgres + mcp server)
podman-compose up --build
# Tear down
podman-compose downMCP 服务器将在 http://localhost:10002/sse 上可用。
要连接您的代理容器,请设置:
MCP_SERVER_URL=http://sapphire-mcp:10002/sse配置
所有设置均从环境变量(或 .env 文件)读取:
变量 | 默认值 | 描述 |
|
| PostgreSQL 用户名 |
|
| PostgreSQL 密码 |
|
| PostgreSQL 主机(podman-compose 内为 |
|
| PostgreSQL 端口 |
|
| PostgreSQL 数据库名 |
|
| MCP 服务器绑定地址 |
|
| MCP 服务器绑定端口 |
工具参考
所有工具共享以下参数:
参数 | 类型 | 默认值 | 描述 |
|
| — | 要查询其数据的用户 |
|
|
| ISO 日期 |
|
|
|
|
get_activity
返回步数、卡路里、距离和活跃分钟数。总计按周期求和。
get_blood_pressure
返回收缩压/舒张压读数(mmHg)。每个读数按 AHA 分类:
正常 — 收缩压 <120 且舒张压 <80
升高 — 收缩压 120–129 且舒张压 <80
1 级高血压 — 收缩压 130–139 或舒张压 80–89
2 级高血压 — 收缩压 ≥140 或舒张压 ≥90
高血压危象 — 收缩压 >180 或舒张压 >120
get_glucose
返回血糖读数(mg/dL),包含餐食背景(fasting、pre_meal、post_meal、bedtime、random)以及统计信息,包括目标范围内时间(目标:70–180 mg/dL)。
get_heart_rate
返回心率读数(BPM,活跃和静息),包含平均值、最小值、最大值和平均静息 BPM。
get_sleep
返回睡眠阶段细分(深睡、浅睡、快速眼动、清醒)的分钟数、总时长和睡眠效率百分比。
get_spo2
返回 SpO2 读数(%),包含平均值、最小值、最大值以及低饱和度事件(低于 95%)的计数。
get_health_summary
并发调用全部 6 个指标仓库,并返回单个合并响应 — 非常适合每日健康简报。
检查工具
使用 MCP Inspector 探索工具架构并进行测试调用:
npx @modelcontextprotocol/inspector http://localhost:8000/sse连接到 Claude Desktop
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"sapphire-wellness": {
"url": "http://localhost:8000/sse"
}
}
}然后询问 Claude:“我本周的血压是多少?” 它将调用 get_blood_pressure,参数为 period="week"。
数据库架构
全部 6 张表(heartrate、bloodpressure、glucose、spo2、activity、sleep)共享相同的 OpenTelemetry 风格架构。metric_name 列用于区分每张表内的子指标(例如 systolic 和 diastolic 在 bloodpressure 中是单独的行)。完整 DDL 和子指标映射请参阅 Design.md。
扩展
添加新指标:
创建
sapphire_wellness/models/<metric>.py— Pydantic 模型创建
sapphire_wellness/repositories/<metric>_repo.py— 数据库查询 + 映射创建
sapphire_wellness/tools/<metric>.py—@mcp.tool()定义在
server.py中注册
更换数据库:
实现一个新类,镜像 repositories/base.py(HealthRepository)中的方法签名,并将其传递给 server.py 中的 register() 函数。
添加 check_health_alerts:
此工具计划在第二阶段实现。它将标记超出正常阈值的读数(例如血压 >140/90、SpO2 <95%),并返回带有严重程度级别的结构化警报。
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceExposes personal Garmin wellness data through MCP tools for accessing summary, sleep, HRV, heart rate, stress, body battery, and historical data.MIT
- FlicenseNot gradedqualityCmaintenanceExposes health metrics from the Sapphire Wellness App to AI assistants via MCP, enabling queries on activity, blood pressure, glucose, heart rate, sleep, and SpO2 data.
- FlicenseNot gradedqualityCmaintenanceExposes health metrics from the Sapphire Wellness App to AI assistants, enabling natural language queries for activity, blood pressure, glucose, heart rate, sleep, and SpO2 data.
- FlicenseNot gradedqualityCmaintenanceMCP server that exposes health metrics from the Sapphire Wellness App to AI assistants, enabling natural language queries for activity, blood pressure, glucose, heart rate, sleep, and SpO2 data.
Related MCP Connectors
MCP server for Withings health data — sleep, activity, heart, and body metrics.
Securely access and manage FHIR healthcare data stored in Medplum.
HealthData.gov MCP — wraps HealthData.gov CKAN API (free, no auth)
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/shantaramvernekar/sapphire-wellness-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server