t4l-server
t4l-server is the small trusted bridge between one T4L Trainer phone and one host-owned OpenClaw coach.
It does four jobs:
- Pair the phone through an authenticated owner channel.
- Verify every phone request with an Ed25519 device proof.
- Store phone-accepted state, chat, and reviewable agent results in SQLite.
- Expose the same data to the coach through MCP.
It does not install or manage OpenClaw. It does not accept model keys from the phone. It does not expose its MCP key to the phone.
The whole system
authenticated owner channel
|
| confirms XXXX-XXXX on the host
v
phone -- signed HTTPS --> t4l-server <-- host-only MCP key -- OpenClaw coach
|
v
SQLite
Run one isolated server and one OpenClaw coach per athlete. Put the public phone routes behind trusted HTTPS. Keep the channel-confirmation and MCP calls on the host.
Install
Python 3.11 or newer is required.
python3 -m venv .venv
.venv/bin/pip install -e '.[dev]'
Run
Set two host-only secrets:
MCP_T4L_API_KEY: used only by OpenClaw forPOST /mcp.T4L_CONNECTOR_RUNTIME_TOKEN: used only by the authenticated owner-channel adapter to confirm pairing.
Then start the server:
export MCP_T4L_API_KEY='replace-with-a-long-random-secret'
export T4L_CONNECTOR_RUNTIME_TOKEN='replace-with-another-long-random-secret'
t4l-server serve \
--data-dir /var/lib/t4l/coach-tobi \
--host 127.0.0.1 \
--port 8787 \
--api-key "$MCP_T4L_API_KEY" \
--agent-id coach-tobi \
--agent-name "T4L Gym Bro" \
--agent-runtime openclaw \
--connector-owner-id 'slack:workspace-id:user-id' \
--require-https
Bind locally and publish it through a trusted HTTPS reverse proxy. If the proxy terminates TLS, it must send Forwarded: proto=https or X-Forwarded-Proto: https.
The owner identity format is exactly channel:account:sender. Repeat --connector-owner-id if the coach has more than one authenticated owner channel.
Pairing
The normal first launch has one input: the connector address.
- The phone reads
/.well-known/t4l-agent. - It creates an Ed25519 device key and calls
POST /v1/pairing/requests. - It shows
/t4l connect XXXX-XXXX. - The user sends that command through the authenticated owner channel.
- The host adapter calls
POST /v1/pairing/channel-confirmationwith its runtime token and verified channel identity. - The phone signs the challenge and calls
POST /v1/pairing/complete.
The returned token is bound to that device key and has only chat, sync, and status scopes. Every later app request signs the token id, device id, timestamp, nonce, method, exact path, and SHA-256 body hash.
Pairing fails closed when the runtime token or owner list is missing.
Phone API
Public discovery and pairing:
| Method | Path | Auth |
|---|---|---|
| GET | /.well-known/t4l-agent |
none |
| POST | /v1/pairing/requests |
trusted HTTPS |
| POST | /v1/pairing/complete |
trusted HTTPS |
| POST | /v1/pairing/channel-confirmation |
host runtime token; loopback by default |
Signed phone routes:
| Method | Path | Scope |
|---|---|---|
| GET | /v1/session |
status |
| DELETE | /v1/devices/{deviceId} |
status |
| POST | /v1/chat/onboarding |
chat |
| GET/POST | /v1/chat/messages |
chat |
| PUT | /v2/context/bundle |
sync |
| GET | /v2/results/pending |
sync |
| GET | /v2/results/{resultId}/{revision} |
sync |
| POST | /v2/results/{resultId}/{revision}/ack |
sync |
The app publishes one atomic v2 bundle. Its only context kind is accepted_state. A fresh accepted setup may also contain exactly one training_block_request.
The only phone-review results are:
athlete_setup_drafttraining_block_plan
A result stays pending until the phone acknowledges its exact resultId and revision. Importing a training block is always an explicit user action.
MCP API
POST /mcp accepts the host-only API key through Authorization: Bearer ... or x-t4l-token.
The coach can:
- read the accepted state and current block request;
- read recent chat and standing coaching notes;
- reply in chat;
- write a pending athlete setup draft;
- write a pending training block plan.
It cannot write accepted phone state. It cannot install software. It cannot create nutrition, hydration, supplement, weight, or body-composition prescriptions. The server blocks those topics in agent output and strips old nutrition fields before they can re-enter a coach prompt.
State ownership
The phone is the source of truth.
- Server context is a copy of phone-accepted state.
- Agent writes are pending proposals.
- The phone validates and accepts or rejects them.
- Daily workout choice is local and deterministic.
- The active workout uses the frozen phone session snapshot.
- Apple Watch owns progress while it controls the session.
Development
.venv/bin/ruff check .
.venv/bin/mypy
.venv/bin/pytest -q
The production phone uses device-bound proofs. The production coach uses MCP from the host.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file t4l_server-0.8.1.tar.gz.
File metadata
- Download URL: t4l_server-0.8.1.tar.gz
- Upload date:
- Size: 120.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
996d127767b649567c00a10a532012ef3447b4cc43392ef78e6cccc3dd62fd63
|
|
| MD5 |
72feb10ef4f0e5bca74cb67e90e63e1d
|
|
| BLAKE2b-256 |
e9b02e56faf4f626e580019cb4870a9d6a7558c1f4ebe6cf064fb8028fd9fb71
|
Provenance
The following attestation bundles were made for t4l_server-0.8.1.tar.gz:
Publisher:
publish.yml on BigSlikTobi/t4l-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
t4l_server-0.8.1.tar.gz -
Subject digest:
996d127767b649567c00a10a532012ef3447b4cc43392ef78e6cccc3dd62fd63 - Sigstore transparency entry: 2573003486
- Sigstore integration time:
-
Permalink:
BigSlikTobi/t4l-server@832f8cae88843cf86cdab4587b72013060d2ec86 -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/BigSlikTobi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@832f8cae88843cf86cdab4587b72013060d2ec86 -
Trigger Event:
push
-
Statement type:
File details
Details for the file t4l_server-0.8.1-py3-none-any.whl.
File metadata
- Download URL: t4l_server-0.8.1-py3-none-any.whl
- Upload date:
- Size: 44.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7505901d4f911738c0b3aaa8f43d285aec9b8a880599cdc72477167f2db3313
|
|
| MD5 |
c258005e230306796ecb894367279eba
|
|
| BLAKE2b-256 |
7ee76cb4d036f4bd2d67e69114da47b75e4bd9dd218edf6b2e1508f198a258e4
|
Provenance
The following attestation bundles were made for t4l_server-0.8.1-py3-none-any.whl:
Publisher:
publish.yml on BigSlikTobi/t4l-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
t4l_server-0.8.1-py3-none-any.whl -
Subject digest:
a7505901d4f911738c0b3aaa8f43d285aec9b8a880599cdc72477167f2db3313 - Sigstore transparency entry: 2573004244
- Sigstore integration time:
-
Permalink:
BigSlikTobi/t4l-server@832f8cae88843cf86cdab4587b72013060d2ec86 -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/BigSlikTobi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@832f8cae88843cf86cdab4587b72013060d2ec86 -
Trigger Event:
push
-
Statement type: