Sapphire Wellness MCP Server
Sapphire Wellness MCP Server
健康メトリクスをSapphire WellnessアプリからAIアシスタントに公開する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サーバーを子プロセスとして起動する場合にのみ機能します)
データベース: OpenTelemetryスタイルのメトリクステーブル(
time、metric_name、metric_value、attributes JSONBなど)を備えたPostgreSQLフレームワーク: 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ファイル)から読み取られます:
変数 | デフォルト | 説明 |
|
| 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
食事コンテキスト(fasting、pre_meal、post_meal、bedtime、random)付きのmg/dL単位の血糖値測定値と、目標範囲内時間(目標: 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/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列は各テーブル内のサブメトリクスを区別します(例: systolicとdiastolicはbloodpressure内の別々の行です)。完全な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の追加:
このツールはフェーズ2で計画されています。正常範囲外の測定値(例: 血圧>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