vaultbeat-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fino-wind (Tether — AI Health Sync)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: vaultbeat-mcp
3
+ Version: 0.1.0
4
+ Summary: Local MCP server for Vaultbeat — AI Health Sync: your AI agent reads your end-to-end-encrypted Apple Health data (sleep, cycle, weight, water), decrypted only on your machine
5
+ Requires-Python: >=3.11
6
+ License-File: LICENSE
7
+ Requires-Dist: cryptography<47.0.0,>=42.0.0
8
+ Requires-Dist: httpx<1.0.0,>=0.28.0
9
+ Requires-Dist: keyring>=24
10
+ Requires-Dist: mcp<2.0.0,>=1.13.0
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest<9.0.0,>=8.3.0; extra == "dev"
13
+ Requires-Dist: ruff<1.0.0,>=0.11.0; extra == "dev"
14
+ Requires-Dist: mypy<2.0.0,>=1.13.0; extra == "dev"
15
+ Provides-Extra: qr
16
+ Requires-Dist: qrcode<9.0.0,>=8.0.0; extra == "qr"
17
+ Dynamic: license-file
@@ -0,0 +1,123 @@
1
+ # Vaultbeat MCP Server
2
+
3
+ **Let your own AI agent read your health data — without the cloud ever seeing it.**
4
+
5
+ This is the official local [MCP](https://modelcontextprotocol.io) server for [Vaultbeat — AI Health Sync](https://apps.apple.com/us/app/tether-ai-health-sync/id6759241985) (formerly named *Tether*), the iOS app that syncs Apple Health data (sleep, heart rate, menstrual cycle, weight, water, symptoms) between partners and to your own AI — end-to-end encrypted.
6
+
7
+ Vaultbeat embeds no AI and runs no model on your phone. Intelligence lives where you control it: Claude Code, Claude Desktop, or any MCP-capable agent running on your own machine. This server is the bridge — it holds a private key that never leaves your computer, pulls ciphertext from the cloud, and decrypts **only locally**.
8
+
9
+ ```
10
+ iPhone (Apple Health) ──E2EE──▶ cloud (ciphertext only) ──E2EE──▶ this server (your machine) ──▶ your AI agent
11
+ ```
12
+
13
+ ## Requirements
14
+
15
+ - [Vaultbeat — AI Health Sync](https://apps.apple.com/us/app/tether-ai-health-sync/id6759241985) on iOS, with a **Pro** subscription (the AI-agent interface is the Pro tier)
16
+ - Python 3.11+ on the machine where your agent runs (macOS / Linux / Windows)
17
+
18
+ ## Quick start
19
+
20
+ ### 1. Install
21
+
22
+ With [uv](https://docs.astral.sh/uv/) (recommended — no clone needed):
23
+
24
+ ```bash
25
+ uvx vaultbeat-mcp status
26
+ ```
27
+
28
+ Or with pip:
29
+
30
+ ```bash
31
+ pip install 'vaultbeat-mcp[qr]'
32
+ ```
33
+
34
+ > Upgrading from the old `tether-mcp` package? Same code, new name — your existing binding and config carry over unchanged. Just swap the package name in your install command and MCP client config.
35
+
36
+ ### 2. Bind your phone
37
+
38
+ ```bash
39
+ vaultbeat-mcp bind
40
+ ```
41
+
42
+ This generates a keypair on your machine and prints a QR code. In the Vaultbeat iOS app, open **Settings → Data & AI → MCP Server** and scan it (or import a QR screenshot from Photos). The app authorizes this machine and starts sealing your health envelopes to its public key. The private key stays in `~/.tether/mcp-local/` (owner-only `0600` permissions, OS keychain where available) — it is never uploaded anywhere. (The directory keeps its original pre-rename path so existing bindings survive upgrades.)
43
+
44
+ ### 3. Connect your agent
45
+
46
+ **Claude Code** (one line):
47
+
48
+ ```bash
49
+ claude mcp add vaultbeat-health -- uvx vaultbeat-mcp serve --transport stdio
50
+ ```
51
+
52
+ **Claude Desktop** (`claude_desktop_config.json`):
53
+
54
+ ```json
55
+ {
56
+ "mcpServers": {
57
+ "vaultbeat-health": {
58
+ "command": "uvx",
59
+ "args": ["vaultbeat-mcp", "serve", "--transport", "stdio"]
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ Any other MCP client: run `vaultbeat-mcp serve --transport stdio`, or `serve --transport http` for a loopback streamable-HTTP endpoint with bearer-token auth.
66
+
67
+ > **Claude Desktop note**: it does not inherit your shell `PATH`. If `uvx` isn't found, use the absolute path (`which uvx`) as `command`.
68
+
69
+ Debugging: `npx @modelcontextprotocol/inspector uvx vaultbeat-mcp serve --transport stdio`
70
+
71
+ Then just ask your agent: *“How did we sleep last night?”*
72
+
73
+ ## MCP tools (16)
74
+
75
+ | Tool | Returns |
76
+ |---|---|
77
+ | `vaultbeat_status` | Local binding state (never exposes keys or tokens) |
78
+ | `vaultbeat_start_binding` | A fresh QR binding payload for the iOS app to scan |
79
+ | `vaultbeat_poll_binding` | One poll for the iOS authorization to complete binding |
80
+ | `vaultbeat_sync_sleep` | Recent sleep sessions incl. heart-rate samples, per-day primary-session selection matching the iOS app |
81
+ | `get_sleep_detail` | Per-night heart-rate + respiratory-rate + sleep-stage timeline |
82
+ | `get_water_intake` | Daily water intake + computed daily average |
83
+ | `get_weight_trend` | Daily weights + latest/avg/min/max + weekly trend rate |
84
+ | `get_menstrual_cycle` | Cycle samples + next-period prediction *(sensitive — explicit iOS opt-in required)* |
85
+ | `get_symptoms` | HealthKit symptom days grouped by data owner *(sensitive)* |
86
+ | `get_notes` | Free-text day annotations with their writer *(sensitive)* |
87
+ | `get_activity` | Daily activity rings: steps / energy / exercise minutes / stand hours / distance |
88
+ | `get_resting_hr` | Resting heart-rate records + window mean |
89
+ | `get_workouts` | Workout records: type / duration / calories / distance |
90
+ | `get_mindfulness` | Mindful sessions and minutes per day |
91
+ | `get_hrv` | Heart-rate variability (SDNN) records + window mean |
92
+ | `get_wrist_temp` | Sleeping wrist-temperature baseline deviation |
93
+
94
+ Every data tool accepts `owner` (a user-ID prefix) to filter to one person — the server may hold both your and your partner's shared records, and omitting `owner` mixes them into one pool, so per-person questions should always pass it. (Earlier releases named some tools `get_partner_*` / `tether_*`; they were renamed in the 16-tool and Vaultbeat releases.)
95
+
96
+ Reads are cache-first: decrypted records are cached locally (owner-only files, 600 s TTL, `VAULTBEAT_MCP_CACHE_TTL` to override — the pre-rename `TETHER_MCP_*` spellings still work) so repeat queries answer in ~0.2 s with zero network; pass `fresh=true` to force a cloud round trip. The same service layer backs a full CLI (`vaultbeat-mcp sleep / water / weight / …` — every data subcommand takes `--owner` too) if you prefer scripts over MCP.
97
+
98
+ ## Privacy & security model
99
+
100
+ - **End-to-end encryption**: Curve25519 ECDH + HKDF-SHA256 + AES-GCM. Every health record is sealed on-device to each authorized recipient's public key (your partner, and this server once bound).
101
+ - **The cloud only ever holds ciphertext.** Vaultbeat's backend cannot read your health data — architecturally, not just by policy.
102
+ - **Decryption happens here**, on hardware you own. The private key and server token are never exposed through any tool result.
103
+ - **Sensitive kinds** (menstrual cycle, symptoms, notes) reach this server only if explicitly opted in inside the iOS app, and are never re-exported by the server.
104
+ - HTTP transport binds to loopback by default and requires a bearer token; binding a non-loopback address fails closed unless explicitly allowed — front it with TLS if you must expose it.
105
+
106
+ You can audit all of the above in this repository — that is why it is open source.
107
+
108
+ ## Development
109
+
110
+ ```bash
111
+ pip install -e '.[dev,qr]'
112
+ pytest
113
+ ```
114
+
115
+ ## License
116
+
117
+ [MIT](LICENSE). The Vaultbeat iOS app and cloud service are separate proprietary components; this repository covers the local MCP server only.
118
+
119
+ ---
120
+
121
+ *Website: [tetherme.app](https://tetherme.app) · App Store: [Vaultbeat — AI Health Sync](https://apps.apple.com/us/app/tether-ai-health-sync/id6759241985) · Bugs & feedback: [vaultbeat-community](https://github.com/Fino-wind/vaultbeat-community/issues)*
122
+
123
+ <!-- mcp-name: io.github.fino-wind/vaultbeat -->
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "vaultbeat-mcp"
7
+ version = "0.1.0"
8
+ description = "Local MCP server for Vaultbeat — AI Health Sync: your AI agent reads your end-to-end-encrypted Apple Health data (sleep, cycle, weight, water), decrypted only on your machine"
9
+ requires-python = ">=3.11"
10
+ dependencies = [
11
+ "cryptography>=42.0.0,<47.0.0",
12
+ "httpx>=0.28.0,<1.0.0",
13
+ "keyring>=24",
14
+ "mcp>=1.13.0,<2.0.0",
15
+ ]
16
+
17
+ [project.optional-dependencies]
18
+ dev = [
19
+ "pytest>=8.3.0,<9.0.0",
20
+ "ruff>=0.11.0,<1.0.0",
21
+ "mypy>=1.13.0,<2.0.0",
22
+ ]
23
+ qr = [
24
+ "qrcode>=8.0.0,<9.0.0",
25
+ ]
26
+
27
+ [project.scripts]
28
+ vaultbeat-mcp = "vaultbeat_mcp_local.cli:main"
29
+ # Back-compat alias: pre-rename installs and docs invoke vaultbeat-mcp-local.
30
+ vaultbeat-mcp-local = "vaultbeat_mcp_local.cli:main"
31
+
32
+ [tool.pytest.ini_options]
33
+ # src-layout: make vaultbeat_mcp_local importable for the test run without depending
34
+ # on an editable install being present. The editable .pth can silently drop out
35
+ # when the venv is rebuilt (e.g. via `uv sync`), which otherwise breaks collection.
36
+ pythonpath = ["src"]
37
+
38
+ [tool.ruff]
39
+ line-length = 100
40
+ target-version = "py311"
41
+
42
+ [tool.mypy]
43
+ python_version = "3.11"
44
+ check_untyped_defs = true
45
+ warn_unused_ignores = true
46
+ warn_return_any = true
47
+
48
+ [tool.setuptools.packages.find]
49
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: vaultbeat-mcp
3
+ Version: 0.1.0
4
+ Summary: Local MCP server for Vaultbeat — AI Health Sync: your AI agent reads your end-to-end-encrypted Apple Health data (sleep, cycle, weight, water), decrypted only on your machine
5
+ Requires-Python: >=3.11
6
+ License-File: LICENSE
7
+ Requires-Dist: cryptography<47.0.0,>=42.0.0
8
+ Requires-Dist: httpx<1.0.0,>=0.28.0
9
+ Requires-Dist: keyring>=24
10
+ Requires-Dist: mcp<2.0.0,>=1.13.0
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest<9.0.0,>=8.3.0; extra == "dev"
13
+ Requires-Dist: ruff<1.0.0,>=0.11.0; extra == "dev"
14
+ Requires-Dist: mypy<2.0.0,>=1.13.0; extra == "dev"
15
+ Provides-Extra: qr
16
+ Requires-Dist: qrcode<9.0.0,>=8.0.0; extra == "qr"
17
+ Dynamic: license-file
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/vaultbeat_mcp.egg-info/PKG-INFO
5
+ src/vaultbeat_mcp.egg-info/SOURCES.txt
6
+ src/vaultbeat_mcp.egg-info/dependency_links.txt
7
+ src/vaultbeat_mcp.egg-info/entry_points.txt
8
+ src/vaultbeat_mcp.egg-info/requires.txt
9
+ src/vaultbeat_mcp.egg-info/top_level.txt
10
+ src/vaultbeat_mcp_local/__init__.py
11
+ src/vaultbeat_mcp_local/cache.py
12
+ src/vaultbeat_mcp_local/cli.py
13
+ src/vaultbeat_mcp_local/client.py
14
+ src/vaultbeat_mcp_local/crypto.py
15
+ src/vaultbeat_mcp_local/mcp_server.py
16
+ src/vaultbeat_mcp_local/service.py
17
+ src/vaultbeat_mcp_local/store.py
18
+ tests/test_cache.py
19
+ tests/test_cli.py
20
+ tests/test_crypto.py
21
+ tests/test_mcp_server.py
22
+ tests/test_service.py
23
+ tests/test_store.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ vaultbeat-mcp = vaultbeat_mcp_local.cli:main
3
+ vaultbeat-mcp-local = vaultbeat_mcp_local.cli:main
@@ -0,0 +1,12 @@
1
+ cryptography<47.0.0,>=42.0.0
2
+ httpx<1.0.0,>=0.28.0
3
+ keyring>=24
4
+ mcp<2.0.0,>=1.13.0
5
+
6
+ [dev]
7
+ pytest<9.0.0,>=8.3.0
8
+ ruff<1.0.0,>=0.11.0
9
+ mypy<2.0.0,>=1.13.0
10
+
11
+ [qr]
12
+ qrcode<9.0.0,>=8.0.0
@@ -0,0 +1 @@
1
+ vaultbeat_mcp_local
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ __all__ = ["__version__"]
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,159 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import logging
5
+ import os
6
+ import time
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+ from vaultbeat_mcp_local.store import write_secret_file
11
+
12
+ _LOG = logging.getLogger("vaultbeat_mcp_local.cache")
13
+
14
+ # Cache freshness window. Health data lands in the cloud at the phone's
15
+ # background-sync cadence (minutes-to-hours), so an agent asking twice within a
16
+ # few minutes should not pay a second cloud round trip. Override with
17
+ # VAULTBEAT_MCP_CACHE_TTL (seconds); 0 disables the cache entirely.
18
+ DEFAULT_TTL_SECONDS = 600.0
19
+ TTL_ENV = "VAULTBEAT_MCP_CACHE_TTL"
20
+ # Pre-rename env var, honored as a fallback so existing setups keep working.
21
+ _LEGACY_TTL_ENV = "TETHER_MCP_CACHE_TTL"
22
+
23
+
24
+ def _ttl_from_env(default: float) -> float:
25
+ raw = os.getenv(TTL_ENV, "").strip() or os.getenv(_LEGACY_TTL_ENV, "").strip()
26
+ if not raw:
27
+ return default
28
+ try:
29
+ return max(float(raw), 0.0)
30
+ except ValueError:
31
+ _LOG.warning("Ignoring non-numeric %s=%r", TTL_ENV, raw)
32
+ return default
33
+
34
+
35
+ class LocalRecordCache:
36
+ """Decrypted-record cache on the user's own machine.
37
+
38
+ Stores DECRYPTED plaintext JSON — acceptable by design: the whole point of
39
+ the local MCP server is that decryption happens in the user's trusted
40
+ environment, and the files are owner-only (0600 via `write_secret_file`,
41
+ 0700 directory). E2EE protects the wire and the cloud, not the user's own
42
+ disk from the user.
43
+
44
+ One file per metric_type (plus one for the unfiltered "all" set), each
45
+ stamped with the server_id it was fetched for, a fetch timestamp, and the
46
+ fetch's decrypt-error list (a cache hit must report the same errors the
47
+ fetch did): a bind to a different server or an expired TTL reads as a miss.
48
+ """
49
+
50
+ def __init__(self, directory: Path, *, ttl_seconds: float | None = None):
51
+ self.directory = directory
52
+ # An explicit ttl_seconds always wins; the env var only replaces the
53
+ # built-in default — so `LocalRecordCache(dir, ttl_seconds=0)` really
54
+ # disables the cache regardless of the caller's shell environment.
55
+ self.ttl_seconds = (
56
+ _ttl_from_env(DEFAULT_TTL_SECONDS) if ttl_seconds is None else max(ttl_seconds, 0.0)
57
+ )
58
+
59
+ @property
60
+ def enabled(self) -> bool:
61
+ return self.ttl_seconds > 0
62
+
63
+ def _path(self, metric_type: str | None) -> Path:
64
+ return self.directory / f"records-{metric_type or 'all'}.json"
65
+
66
+ def load(
67
+ self, *, server_id: str, metric_type: str | None
68
+ ) -> tuple[list[dict[str, Any]], list[str]] | None:
69
+ """Cached (records, errors), or None on miss/stale/mismatch/disabled.
70
+
71
+ The early `return None`s below are ordinary cache-miss control flow,
72
+ not swallowed failures — the caller answers a miss with a cloud fetch.
73
+ """
74
+
75
+ if not self.enabled:
76
+ return None
77
+ path = self._path(metric_type)
78
+ try:
79
+ raw = json.loads(path.read_text(encoding="utf-8"))
80
+ except FileNotFoundError:
81
+ return None
82
+ except (OSError, json.JSONDecodeError) as error:
83
+ _LOG.warning("Discarding unreadable cache %s: %s", path.name, type(error).__name__)
84
+ return None
85
+
86
+ if not isinstance(raw, dict) or raw.get("server_id") != server_id:
87
+ return None
88
+ fetched_at = raw.get("fetched_at")
89
+ if not isinstance(fetched_at, (int, float)):
90
+ return None
91
+ if (time.time() - float(fetched_at)) > self.ttl_seconds:
92
+ return None
93
+ records = raw.get("records")
94
+ if not isinstance(records, list):
95
+ return None
96
+ errors = raw.get("errors")
97
+ if not isinstance(errors, list):
98
+ errors = []
99
+ return (
100
+ [row for row in records if isinstance(row, dict)],
101
+ [str(item) for item in errors],
102
+ )
103
+
104
+ def save(
105
+ self,
106
+ records: list[dict[str, Any]],
107
+ *,
108
+ server_id: str,
109
+ metric_type: str | None,
110
+ errors: list[str] | None = None,
111
+ ) -> None:
112
+ """Persist a FULL (never limit-truncated) result set; best-effort.
113
+
114
+ `errors` carries the fetch's per-envelope decrypt failures so a cache
115
+ hit reports the same problem set the underlying fetch did — without it,
116
+ a poisoned envelope's error (and the CLI's exit code 3) would flap
117
+ with cache warmth.
118
+ """
119
+
120
+ if not self.enabled:
121
+ return
122
+ payload = {
123
+ "server_id": server_id,
124
+ "metric_type": metric_type,
125
+ "fetched_at": time.time(),
126
+ "records": records,
127
+ "errors": errors or [],
128
+ }
129
+ try:
130
+ write_secret_file(
131
+ self._path(metric_type),
132
+ json.dumps(payload, separators=(",", ":"), sort_keys=True) + "\n",
133
+ harden_parent=True,
134
+ )
135
+ except OSError as error:
136
+ _LOG.warning("Cache write failed (%s); continuing uncached", type(error).__name__)
137
+
138
+ def clear(self) -> None:
139
+ """Drop every cached record file (used when (re)binding)."""
140
+
141
+ try:
142
+ entries = list(self.directory.glob("records-*.json"))
143
+ except OSError as error:
144
+ _LOG.warning(
145
+ "Cache clear could not list %s (%s); stale plaintext may remain",
146
+ self.directory,
147
+ type(error).__name__,
148
+ )
149
+ return
150
+ for path in entries:
151
+ try:
152
+ path.unlink()
153
+ except OSError as error:
154
+ _LOG.warning(
155
+ "Cache clear could not remove %s (%s); stale plaintext may remain",
156
+ path.name,
157
+ type(error).__name__,
158
+ )
159
+ continue