sapphire-wellness-mcp
Sapphire Wellness MCP Server
AIアシスタントにSapphire Wellness Appの健康指標を公開する、Python製のModel Context Protocol (MCP)サーバーです。
公開指標
指標 | ツール | データポイント |
アクティビティ |
| 歩数、カロリー、距離、アクティブ時間 |
血圧 |
| 収縮期/拡張期(mmHg)、AHAカテゴリ |
血糖 |
| 血糖値(mg/dL)、食事コンテキスト、目標範囲内比率 |
心拍数 |
| BPM測定値、平均/最小/最大、安静時心拍数 |
睡眠 |
| 時間、深い/浅い/レム/覚醒の各段階、効率 |
血中酸素/SpO2 |
| 酸素飽和度%、低酸素飽和事象の発生回数 |
要約 |
| 6指標すべてを1回の呼び出しで取得 |
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など)フレームワーク:Pydantic v2レスポンスモデルを備えたFastMCP
アーキテクチャ全体の詳細は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以上
6つの健康指標のメトリクステーブルが作成されたPostgreSQL 14以上
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ファイル)から読み込まれます:
Variable | Default | Description |
|
| PostgreSQLのユーザー名 |
|
| PostgreSQLのパスワード |
|
| PostgreSQLのホスト(podman-compose内では |
|
| PostgreSQLのポート |
|
| PostgreSQLのデータベース名 |
|
| MCPサーバーのバインド先アドレス |
|
| MCPサーバーのバインド先ポート |
ツールリファレンス
すべてのツールが共有するパラメータは以下のとおりです。
パラメータ | 型 | デフォルト | 説明 |
|
| — | データを検索する対象のユーザー ID |
|
|
| 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)をアクティブと安静時それぞれで返し、平均、最小、最大、平均安静時心拍数も示します。
get_sleep
睡眠段階の内訳(深い睡眠、浅い睡眠、レム睡眠、覚醒)を分単位で返し、合計時間と睡眠効率(%)も示します。
get_spo2
SpO2(%)を測定値ごとに返し、平均、最小、最大、および95%未満の低酸素イベントの回数も示します。
get_health_summary
6つの指標リポジトリを同時に呼び出し、単一のまとまったレスポンスを返します。日々の健康サマリーに最適です。
ツールの確認
MCP Inspectorを利用してツールのスキーマを調べたり呼び出しテストを行うことができます。
npx @modelcontextprotocol/inspector http://localhost:8000/sseClaude 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列は各テーブル内のサブメトリクスを区別します(例:bloodpressureテーブル内ではsystolicとdiastolicは別々の行として保存されます)。完全なDDLとサブメトリクスの対応はDesign.mdを参照してください。
拡張方法
新しい指標の追加:
sapphire_wellness/models/<metric>.pyを作成 — Pydanticモデルsapphire_wellness/repositories/<metric>_repo.pyを作成 — DBクエリとマッピングsapphire_wellness/tools/<metric>.pyを作成 —@mcp.tool()定義server.pyに登録
データベースを変更する場合:
repositories/base.pyのHealthRepositoryのメソッドシグネチャを実装した新しいクラスを作成し、server.py内のregister()関数に渡してください。
check_health_alertsを追加する場合:
このツールはPhase 2で計画されています。正常範囲外の値(例:血圧140/90超、SpO2 95%未満)を検出し、重大度レベル付きの構造化アラートを返すものです。
This server cannot be installed
Maintenance
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
- FlicenseNot gradedqualityCmaintenanceExposes health metrics (activity, blood pressure, glucose, heart rate, sleep, SpO2) from the Sapphire Wellness App to AI assistants via the Model Context Protocol.
- 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.
- AlicenseNot gradedqualityCmaintenanceExposes Apple Health data as three read-only MCP tools (now, detail, trends) for AI to query health metrics, sleep, and trends via HTTP.MIT
Related MCP Connectors
63 tools for Apple Health, Fitbit, Oura & Health Connect data in Claude, ChatGPT, Grok & Mistral.
Garmin data in Claude & ChatGPT via the Garmin Health API. OAuth sign-in, no password sharing.
WHOOP recovery, strain, sleep and workouts in Claude via official WHOOP OAuth. Free, open source.
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/IBMC-WORK-REDESIGN-FDE-COHORT-SB/sapphire-wellness-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server