Skip to main content
Glama

xunji-mcp

CI Pages Release License: MIT MCP

A small, self-hosted Model Context Protocol bridge that connects your Xunji (训记) training history to ChatGPT and other MCP clients.

Explore your training in one conversation: an overview, a movement's progress, or a grouped query over your history. The bridge runs on Cloudflare Workers with OAuth and a rebuildable D1 analytics index. Your Xunji key stays in Worker secrets; you approve client access.

Project site · 简体中文 · Documentation · Get started · Releases

What you can ask

Question

Tool

How has my training changed?

xunji_training_overview

How is one movement progressing?

xunji_movement_progress

Compare volume by week, month, or muscle group.

xunji_query_training

What happened on this day?

xunji_get_training_day

Which dates are covered? Backfill this window.

xunji_history

Which tools and domains are available here?

xunji_capabilities

The bridge also reads the movement catalog and official plans. The tool reference covers arguments, units, errors, and the bounded tools retained for v0.1 clients.

Results include metric definitions, coverage, and freshness. Empty days and unscanned days are separate states. Optional MCP_UI_ENABLED=true adds a sandboxed overview view for hosts that support MCP Apps; text remains available.

Related MCP server: Garmin Personal MCP

How it works

flowchart LR
    X["Xunji · original records"] --> W["Your Cloudflare Worker"]
    W --> I["D1 · derived analytics"]
    I --> W
    W --> C["Authorized MCP client"]
    O["You · Access or passphrase"] -->|approve OAuth| W

One deployment serves one Xunji account. Xunji remains the source of truth. A Durable Object scans the history window you select, and D1 computes aggregates without sending every set to the model.

The upstream exposes daily reads with observed 15-second light / 30-second full pacing. Backfill is resumable and defaults to 100 attempted dates per UTC day. Historical reads and scans do not write the KV cache; today and yesterday use a short-lived cache with a default 300-attempt daily cache budget. OAuth storage writes are separate.

See architecture, the upstream contract, and privacy for the full data path.

Smaller results

The synthetic benchmark compares the v0.1 per-day tool shape with an indexed overview:

History

Per-day calls

Per-day output

Overview calls

Overview output

1 year

183

~43.8k tokens

1

~552 tokens

3 years

548

~131.4k tokens

1

~555 tokens

The index must be backfilled first. These figures measure synthetic output and local index queries; they are not production latency measurements. Method, limitations, and reproduction.

Get started

You need Node.js 20+, a Cloudflare account, and a training Open API key from Xunji.

git clone https://github.com/DeliciousBuding/xunji-mcp.git
cd xunji-mcp
npm install
cp wrangler.example.jsonc wrangler.jsonc
npx wrangler types
npm run check

Then follow the deployment guide to create KV and D1, configure your HTTPS origin and operator gate, and provide secrets through Wrangler's secret input. Your private wrangler.jsonc is gitignored.

Connect your client through OAuth at https://your-domain.example/mcp, call xunji_capabilities, and start a history backfill:

{ "action": "backfill", "start": "2024-01-01" }

Use xunji_history with action=status to follow progress. The selected start defines the covered window; earlier days are not implied. Once indexed, ask for an overview.

Deploy · Connect ChatGPT and other clients · Tool reference

Access and supported scope

Area

Current boundary

Training reads

Daily reads, indexed queries, PR/e1RM, movement catalog, and official plans

Authorization

OAuth code flow with PKCE S256, exact redirects, resource audience, refresh rotation, and revocation

Operator gate

Access JWT plus email allowlist, or a deployment passphrase; no identity means no grant

Body and nutrition

Separate keys required; adapters remain unverified against live data

Training writes

Disabled by default; explicit enablement, xunji:write, and confirmed: true required

Delete

No upstream delete API

Xunji's training write endpoint ignores dry_run. The bridge never sends it; an accepted write is real. Write behavior has been tested with stubs, not through a production write.

Read SECURITY.md, the threat model, and the coverage matrix before exposing your instance.

Verification and contributing

The suite runs unit, contract, and integration tests inside workerd with stubbed upstream HTTP. CI checks types, ESLint, formatting, tests, credentials in the tree and history, runtime dependencies, and a Worker dry run.

ChatGPT OAuth connection and training reads have been verified in a private deployment. Each new deployment and client needs its own connection check. The optional MCP Apps view's registration is tested; ChatGPT rendering remains unverified. Acceptance status.

Contributing · Support · Code of conduct · Changelog

License

MIT. Independent project; Xunji and 训记 belong to their respective owners.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables ChatGPT or another MCP client to query a self-hosted, email-restricted Garmin Connect running archive — latest and listed runs, lap and chart details, run comparisons, trends, recovery and training context — all served read-only from a Cloudflare Worker cache with one explicit, rate-limited manual refresh. Garmin credentials are never stored, and no tool can modify the Garmin account.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables users to connect ChatGPT or remote MCP clients to their own Garmin cloud health and activity data through a self-hosted, read-only OAuth-protected Cloudflare Worker.
      MIT
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables Claude and other remote MCP clients to query your own read-only Garmin Connect data — recovery trends, sleep, HRV, Body Battery, stress, heart rate, and activities — through Garmin's official Personal API, with OAuth sign-in that works from the mobile apps as well as desktop. Deploys on Cloudflare Workers' free tier with no password sharing or scraping.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables connecting your own Garmin Connect data to Claude or another MCP client so you can ask about sleep, training, heart rate, weight, and more through read-only tools running on a Cloudflare Worker.
      1
      MIT