Sapphire User MCP Server
Sapphire User MCP Server
一个 Python Model Context Protocol (MCP) 服务器,向 AI 助手公开 Sapphire Wellness App 的用户档案数据——包括健康警报、个性化推荐和合作伙伴服务订阅。
公开的工具
工具 | 描述 |
| 由指标阈值触发的健康警报(异常生命体征、低活动量等) |
| 按相关度评分排序的个性化合作伙伴服务推荐 |
| 包含完整服务详情的活跃合作伙伴服务订阅 |
Related MCP server: sapphire-user-mcp
架构
Agent Container
│ HTTP SSE
▼
sapphire-user-mcp:10003
│
├──httpx──▶ User Profile API:8091
│
└──httpx──▶ Partner Service API:8085传输:HTTP SSE — 多容器部署所必需(仅当代理将 MCP 服务器作为子进程启动时,stdio 才有效)
上游 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/sse连接到 Claude 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…
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.-