
TrainBud
io.github.Zsadigzade由 GitHub 帳號 Zsadigzade 發布v0.9.0更新於 Oct 25, 2026
Talk to your own fitness data. Findings computed in code against your own 28-day baselines.
概覽
一個本機 MCP 伺服器,把 Garmin Connect 健身資料接進 AI 助理,讓你用自然語言詢問訓練、睡眠、心率與恢復狀況。
- 可以做什麼
- 讀取最近的運動與指定日期範圍內的活動,包含距離、配速、心率與爬升,並可把一次訓練與你自己同類型同距離的過往表現比較。查看睡眠時長、階段、分數與醒來次數,以及靜息、最高與平均心率趨勢。依 HRV、睡眠、壓力與靜息心率查看恢復狀態,並追蹤身體組成、壓力與 VO2 max 趨勢。取得合併的每週摘要、本週與上週比較(含負荷預測與睡眠債),以及依你自己 28 天基準計算並附觸發規則的發現。記錄目標、比賽、傷病與備註,並記錄一次訓練的主觀感受(RPE、痠痛、情緒)。
- 適用情境
- 適合使用 Garmin 裝置訓練、希望用自然語言查詢自己歷史資料而不是翻圖表的人。特別適合圍繞個人基準詢問恢復、睡眠與訓練負荷問題。
- 執行需求
- 在桌上型電腦上以本機程序執行,需要 Node.js 22.12 以上版本,或使用已發佈的容器映像。需要 Garmin Connect 帳號,並在本機 .env 檔案中設定 GARMIN_EMAIL 與 GARMIN_PASSWORD。不支援啟用 MFA 的帳號。ANTHROPIC_API_KEY 為選用,僅供手錶應用的 AI 功能使用。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 TrainBud,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
TrainBud
Talk to your training data.
TrainBud is an open-source MCP server that connects your Garmin Connect fitness data to Claude, Cursor, and other AI assistants. Ask about workouts, sleep, heart rate, recovery, and body composition in plain English — privately, on your machine.
Disclaimer: TrainBud is an unofficial community project. It is not affiliated with, endorsed by, or sponsored by Garmin Ltd. Garmin Connect is a trademark of Garmin Ltd.
[npm] [CI] [License: MIT] [Node 22.12+] [Trainbud MCP server — quality and maintenance score on Glama]
[Trainbud MCP server — license, quality, and maintenance card on Glama]
Try it
Once connected to your MCP client, ask things like:
- "What did I do today?"
- "How's my sleep been this week?"
- "Am I recovered enough to train hard tomorrow?"
- "Is my resting heart rate trending down?"
See examples/prompts.md for more ideas.
Why TrainBud
- Private — credentials stay in your local
.env; data is cached on your machine - Local-first — SQLite cache, session tokens in
.trainbud/ - Works everywhere — Windows, macOS, Linux (Node.js 22.12+)
- Any MCP client — Claude Desktop, Cursor, and other stdio-compatible clients
- Smart fetching — batched API calls and automatic re-auth when sessions expire
Quick start
The setup wizard walks you through credentials, authentication, and connecting Cursor or Claude Desktop — no MCP config editing required. Then restart your MCP client and ask it what you did today.
To keep trainbud on your PATH instead of typing npx every time:
Needs Node 22.12+. Full walkthrough: QUICKSTART.md
From source (for contributors, or to run an unreleased commit)
Without npm link, every trainbud <command> in this README is
node dist/index.js <command> run from the repo root. If dist/ does not exist yet,
run npm run build first.
Claude Code plugin (recommended)
Install as a Claude Code plugin — skills and MCP server in one step:
Set credentials, then restart Claude Code:
Plugin files live in plugin/. See plugin/README.md.
Claude Code skills (in-repo)
This repo also ships project skills in .claude/skills/ for development without installing the plugin:
Open the repo in Claude Code (claude in this directory) — skills load automatically.
To use skills in every project without the plugin, copy them to ~/.claude/skills/.
After setup, restart your MCP client and try /trainbud with "What did I do today?"
Dashboard
trainbud serve hosts a dashboard at /dashboard. It is phone-first, because the
pairing flow is: you are standing next to the watch holding a phone when you approve a
code.
It shows what stands out today against your own baselines, this week against last week, and resting heart rate and sleep plotted against your own 30-day median — all read from the local history store, so it paints instantly and works even when your Connect session has expired. A break in a line is a day with no measurement, not a zero.
It is also where you tell TrainBud who it is talking to:
Usage. TrainBud runs on your own AI provider key, so every question and every daily insight is charged to you. The dashboard shows the tokens and cost per call, the month to date, and a 30-day chart. A model this build has no published price for is recorded with its cost left unknown rather than as zero — a call priced at zero would make a cap that can never trip.
Nothing on this page leaves your machine. There is no endpoint to send it to.
Garmin watch widget (Connect IQ)
View recovery, sleep, activity, stress, and VO2 max on your Garmin watch via a Connect IQ widget in ciq/.
Requires: trainbud serve running + HTTPS tunnel (same setup as web AI).
- Start the server and tunnel:
- Build and sideload the widget — see ciq/README.md
- In Garmin Connect Mobile → Connect IQ → TrainBud settings, set:
- Server URL — your tunnel URL (e.g.
https://abc.trycloudflare.com)
- Server URL — your tunnel URL (e.g.
- Open the widget on your watch — it shows a pairing code. Approve it in the dashboard (
/dashboard?token=YOUR_API_KEY) to complete setup. The dashboard swaps that token for a session cookie and drops it from the URL, so the address bar is safe to screenshot afterwards.
The glance shows recovery and sleep, or the top finding in a few characters ("RHR +4 bpm"),
from the last cached summary, so it renders without waiting on the network; once that is more
than two hours old it says so. Open it and tap or swipe to cycle through the cards you left
switched on in the dashboard. The watch calls GET /api/watch — a compact JSON summary, not
the full MCP protocol.
On the Today card, START (or tap) opens a finding to the rule it fired on — "Each of the
last 3 days was at least 3 bpm and 2 deviations above your 28-day median of 48 bpm" — and from
there it can be muted for three days (POST /api/mute). The Sleep card names what moved
last night against your own nights ("Deep 40m (1h24m)"). On the Forerunner 55, whose widget has
64 KB, those two are compiled out so the rest still fits.
Detector rules
Every finding fires on a rule you can see and move. The dashboard's Detector rules section holds the bars — resting HR days/bpm/deviations, sleep-debt hours, HRV drop, the training-load ratios, and "several signals together" (resting HR up, HRV down and sleep stress up at once) — bounded so no setting makes every day, or no day, a finding. Every surface shows the rule a finding fired on, with the numbers that were in force.
Voice (/voice)
Hold a button on your phone, ask a question out loud, hear the answer read back.
Open https://YOUR-HOST/voice?token=YOUR_API_KEY once; it trades the key for a cookie
and redirects to a clean URL.
- Android / Chrome — speech recognition happens in the browser. Free, no key.
- iPhone / Safari — records audio and transcribes it server-side via Groq
(
whisper-large-v3-turbo, about $0.04 per hour of audio). Add the key on the dashboard. - Both — answers are spoken back, and Read me my day / Read today's insight cost nothing at all: they are composed in code from data already on hand, not generated.
Not a watch feature and it cannot be one: Connect IQ exposes no microphone or speaker to a widget. Not hands-free either — mobile browsers suspend the microphone when the tab is backgrounded, so the phone has to be awake with the page in front of you.
Full detail: docs/VOICE.md
Always on (/voice and the watch, without babysitting a terminal)
trainbud serve in a terminal lasts until the terminal closes. To have the server and the
tunnel come back by themselves after a reboot:
That registers a scheduled task for the server and a watchdog that checks both halves every
five minutes — because a tunnel that answers is not a server that answers: a tunnel with
nothing behind it serves its own error page under a 200, so the link looks alive while the
watch reports HTTP -400. systemd, launchd and Docker Compose recipes are in the guide.
Full detail, including Cloudflare named tunnels: docs/ALWAYS-ON.md
Connect to Claude Desktop
Edit claude_desktop_config.json:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
With trainbud on your PATH (npm install -g trainbud, or npm link from a clone),
point the client at the command instead of a path:
Restart your MCP client, then start asking questions.
Tools
CLI
rotate ai-key writes both stores on purpose. The AI key lives in .env and in
app.db, the database copy is the one actually read, and hand-editing only the file
leaves a rotated key that never took effect.
Every one of these also works as npx trainbud <command> without installing anything.
Troubleshooting: trainbud: command not found
Either use npx trainbud <command>, or install it globally with
npm install -g trainbud. Running from a clone instead? Run npm link once from the
repo root, or call the built entry point directly with node dist/index.js doctor
(after npm run build).
Configuration
Security & privacy
- Credentials live only in your local
.envfile — never sent to a third party - Session tokens in
.trainbud/session.jsonare as sensitive as a password - Tool errors are sanitized before reaching the AI client
- Uses the unofficial
garmin-connectnpm package (not Garmin's enterprise OAuth API) - MFA is not supported by the underlying library — disable MFA or use an app-specific password
- The server binds
127.0.0.1by default. It is only reachable from the internet if you point a tunnel at it, and every route except/healthneeds the API key - The dashboard takes the key once, on
/dashboard?token=…, then trades it for anHttpOnlysession cookie and redirects to a clean URL — so the key does not sit in your address bar, your history, or a screenshot - A paired watch holds a token scoped to that watch, minted at pairing and stored
on the server as a SHA-256 hash.
trainbud deviceslists them,trainbud devices revoke <id>takes one away — without logging out the dashboard,/mcp, or your other watches. A watch paired before 0.5.2 holds the API key itself; re-pair it to swap that for a scoped token - Every response carries
Content-Security-Policy,X-Content-Type-Options,X-Frame-OptionsandReferrer-Policy, including the 401s. HSTS is sent only on a request that actually arrived over TLS, so the loopback dashboard stays reachable
What TrainBud is not
- Not a hosted service. There is no TrainBud account and no TrainBud server. You run it, on your machine, against your own Garmin credentials
- Not an official Garmin integration. It drives an unofficial library against the Connect web API. Garmin can change that API without notice, and does
- Not MFA-compatible. If your Connect account has MFA on, this will not log in
- Not free to ask. The AI features run on your own Anthropic key and are billed to you. The dashboard meters every call and can refuse past a cap you set
Troubleshooting
Docker
A published image, built and exercised in CI on every push so it is not a promise that quietly rots:
Or build it yourself from this repository:
One thing matters more than the rest: mount a volume at /app/.trainbud.
That is where the SQLite history, the cached session and the log live. Without
it, every container restart throws away your downloaded history and
re-authenticates from scratch.
As an MCP server for a desktop client
The default entrypoint speaks MCP over stdio, so the client runs the container:
-i is required — without it the container has no stdin and the client sees a
server that connects and immediately goes quiet. The two -e flags with no
value pass the variables through from your own environment, so your credentials
stay out of the config file.
As an HTTP server, for the watch app or a web client
TRAINBUD_HOST=0.0.0.0 is needed inside a container: the server binds
127.0.0.1 by default, which is the right default on a laptop and unreachable
from outside a container.
Filling the history
trainbud setup is interactive and assumes a terminal, so with Docker do the
one-off backfill directly:
The same pattern runs doctor, check and devices.
Development
Use .nvmrc with nvm/fnm for Node 22. npm run test:coverage reports coverage through Node's own test runner, and npm run test:watch reruns on change.
See CONTRIBUTING.md and docs/VAULT.md for architecture and design notes (Obsidian vault, outside this repo).
Roadmap
- VO2 max trends
- Stress levels
- Training insights
- Workout comparison
- Docker image — published to
ghcr.io/zsadigzade/trainbud
License
MIT — see LICENSE.
Garmin Connect is a trademark of Garmin Ltd. This project is not affiliated with Garmin Ltd.
來源:README.md,提交 cf22892
工具
0版本歷史
2- v0.9.0最新Sep 18, 2026
- v0.8.0Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分