personal-health-mcp
# personal-health-mcp
タニタ ヘルスプラネット API から体組成データ(体重・体脂肪率)を取得し、MCP ツールとして Claude Desktop 等の AI エージェントに提供します。
## セットアップ
### 1. インストール
```bash
pip install -e .
```
### 2. .env を作成
```bash
cp .env.example .env
```
`.env` を編集して `HEALTH_PLANET_CLIENT_ID`・`HEALTH_PLANET_CLIENT_SECRET`・`HEALTH_PLANET_REDIRECT_URI` を設定してください。
### 3. 初回認証
```bash
python -m health_mcp.tanita.auth
```
表示された URL をブラウザで開き、「アクセスを許可する」をクリック後、リダイレクト URL を貼り付けると `.env` にトークンが保存されます。
### 4. Claude Desktop に MCP サーバーを登録
`claude_desktop_config.json` に以下を追加してください。`command` には venv 内の Python 実行ファイルのフルパスを指定します。
**Windows:**
```json
{
"mcpServers": {
"personal-health": {
"command": "C:/Users/<username>/path/to/personal-health-mcp/venv/Scripts/python.exe",
"args": ["-m", "health_mcp.server"]
}
}
}
```
**macOS / Linux:**
```json
{
"mcpServers": {
"personal-health": {
"command": "/path/to/personal-health-mcp/venv/bin/python",
"args": ["-m", "health_mcp.server"]
}
}
}
```
> `cwd` の指定は不要です。サーバーは `__file__` を基点にプロジェクトルートを自動解決します。
## MCP ツール一覧
| ツール | 説明 |
|---|---|
| `get_latest_body_composition` | 最新の体重・体脂肪率を取得(直近30日対象) |
| `get_body_composition` | 指定期間(最大92日)の体組成データを取得 |
| `get_measurements_range` | キャッシュ内データの日付範囲と件数を確認 |
| `get_profile` | 生年月日・身長・性別を取得 |
| `list_available_metrics` | 取得可能なメトリクス一覧を表示 |
## プロフィールの再取得
タニタアプリでプロフィール情報を変更した場合:
```bash
python -m health_mcp.tanita.auth --reset-profile
```
## 開発
```bash
pip install -e ".[dev]"
pytest # テスト
mypy src # 型チェック
ruff check src # リント
```
TDQS
Scored across 5 tools
Most tools are clearly distinct: get_latest_body_composition, get_body_composition, get_measurements_range, get_profile, and list_available_metrics each target different data or metadata. The minor overlap between 'latest' and 'range' variants is manageable due to clear descriptions.
Tool names predominantly follow a get_<resource> pattern, which is consistent and readable. The exception is list_available_metrics, which uses 'list_' instead of 'get_', a minor deviation that does not impede understanding.
Five tools is well within the ideal 3-15 range and appropriately scoped for a personal-health MCP focused on body composition and profile retrieval. No unnecessary tools are present.
The tool set covers read access to body composition data, profile information, and available metrics, but lacks write operations or management of cached data. Since the domain appears to be read-only retrieval from an external source, the core needs are met, though a few potential gaps exist (e.g., no single-metric query).