Sapphire User MCP Server
Sapphire User MCP Server
Sapphire Wellness App のユーザープロファイルデータを AI アシスタントに公開する Python Model Context Protocol (MCP) サーバーです。健康アラート、パーソナライズされたレコメンデーション、パートナーサービスサブスクリプションなどが含まれます。
公開ツール
ツール | 説明 |
| メトリクスのしきい値によってトリガーされる健康アラート(異常なバイタル、低活動など) |
| 関連性スコアでランク付けされたパーソナライズされたパートナーサービスレコメンデーション |
| 完全なサービス詳細を含むアクティブなパートナーサービスサブスクリプション |
Related MCP server: sapphire-user-mcp
アーキテクチャ
Agent Container
│ HTTP SSE
▼
sapphire-user-mcp:10003
│
├──httpx──▶ User Profile API:8091
│
└──httpx──▶ Partner Service API:8085Transport: HTTP SSE — マルチコンテナデプロイメントに必要(stdio は、エージェントが MCP サーバーを子プロセスとして起動する場合にのみ機能します)
上流 API: すべてのツールは HTTP 経由で REST API を呼び出します — データベースへの直接アクセスはありません
フレームワーク: FastMCP と Pydantic v2 レスポンスモデル
プロジェクト構造
SAPPHIRE-USER-MCP/
├── sapphire_user/
│ ├── server.py # FastMCP app + SSE entry point
│ ├── config.py # Settings (API URLs, HOST, PORT via env)
│ ├── models/ # Pydantic response models
│ │ ├── alerts.py
│ │ ├── recommendations.py
│ │ ├── partner_service.py
│ │ └── subscriptions.py
│ └── tools/ # MCP tool definitions
│ ├── alerts.py
│ ├── recommendations.py
│ └── subscriptions.py
├── pyproject.toml
├── Dockerfile
└── .env.example前提条件
Python 3.11+
実行中の Sapphire User Profile API(デフォルト:
http://localhost:8091)実行中の Sapphire Partner Service API(デフォルト:
http://localhost:8085)
クイックスタート
ローカル開発
# 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 USER_PROFILE_API_BASE_URL and PARTNER_SERVICE_API_BASE_URL
# 4. Run the server
python -m sapphire_user.server
# Server starts at http://0.0.0.0:8001コンテナ化(Docker)
# Build the image
docker build -t sapphire-user-mcp .
# Run the container
docker run -p 10003:10003 --env-file .env sapphire-user-mcpMCP サーバーは http://localhost:10003/sse で利用可能になります。
エージェントコンテナを接続するには、以下を設定します:
MCP_SERVER_URL=http://sapphire-user-mcp:10003/sse設定
すべての設定は環境変数(または .env ファイル)から読み取られます:
変数 | デフォルト | 説明 |
|
| MCP サーバーのバインドアドレス |
|
| MCP サーバーのバインドポート |
|
| Sapphire User Profile API のベース URL |
|
| Sapphire Partner Service API のベース URL |
ツールリファレンス
すべてのツールは単一の user_email パラメータを受け取ります。
パラメータ | 型 | 説明 |
|
| ユーザーのメールアドレス(例: |
get_user_alerts
User Profile API からユーザーの健康アラートを取得します。各アラートには以下が含まれます:
severity — アラートの緊急度レベル(例:
critical,warning)category — アラートをトリガーしたメトリクスカテゴリ
alertMessage — アラートの人間が読める説明
metricName / metricType — しきい値を超えた特定のメトリクス
get_user_recommendations
関連性スコアでランク付けされたパーソナライズされたパートナーサービスレコメンデーションを返します。各レコメンデーションには以下が含まれます:
relevanceScore — サービスがユーザーの健康プロファイルにどの程度一致するかを示す整数ランキング
partnerService — サービス名、カテゴリ、タイプ、説明
generatedAt — レコメンデーションが計算されたタイムスタンプ
get_user_subscriptions
ユーザーのアクティブなパートナーサービスサブスクリプションを取得し、Partner Service API から完全なサービス詳細を各サブスクリプションに追加します。各サブスクリプションには以下が含まれます:
partnerServiceId — 登録されたサービス識別子
isActive — サブスクリプションが現在アクティブかどうか
associationContext — 契約終了日およびその他のコンテキストメタデータ
service_details — 完全なサービス仕様、価格、可用性、契約情報
ツールの検査
MCP Inspector を使用してツールスキーマを調べ、テスト呼び出しを行います:
npx @modelcontextprotocol/inspector http://localhost:8001/sseClaude Desktop への接続
claude_desktop_config.json に追加します:
{
"mcpServers": {
"sapphire-user": {
"url": "http://localhost:8001/sse"
}
}
}次に Claude に: "sarah.chen@sapphirewellness.com にはどのような健康アラートがありますか?" と尋ねると、提供されたメールアドレスで get_user_alerts が呼び出されます。
拡張
新しいツールの追加:
sapphire_user/models/<name>.pyを作成 — Pydantic レスポンスモデルsapphire_user/tools/<name>.pyを作成 — 適切な API を呼び出す@mcp.tool()定義server.pyに登録
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect your health, fitness, nutrition, sleep, and wearable data to your AI assistant.
Your own health records from Vora, Still, Stackwell and Joiva in your AI assistant (OAuth).
Connect your wearables, rings and training apps, then ask your AI about your own health data.
Access approved FITsociety clients, schedules, bookings and coaching data with AI assistants.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to access Sapphire Wellness user data, including health alerts, personalized recommendations, and partner service subscriptions.-
- FlicenseNot gradedqualityDmaintenanceExposes user profile data from the Sapphire Wellness App to AI assistants via MCP, providing tools for fetching health alerts, personalized recommendations, and partner service subscriptions.-
- FlicenseNot gradedqualityCmaintenanceExposes user profile data from the Sapphire Wellness App to AI assistants, including health alerts, personalized recommendations, and partner service subscriptions.-
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to access Sapphire Wellness user profile data, including health alerts, personalized recommendations, and partner service subscriptions.-