Skip to main content

Self-hosted REST and MCP server for T4L Trainer agent workflows.

Project description

T4L Server

Self-hosted REST and MCP server for exchanging T4L Trainer JSON artifacts between the iPhone app and a coaching agent.

The phone remains the source of truth for accepted training state. The server stores synced context and pending agent results in SQLite so local agents, home-server agents, and private VPS agents can work through the same protocol.

Install

pipx install t4l-server
t4l-server serve --data-dir ~/T4LServerData

The command prints the server URL, MCP URL, and API key. Enter the server URL and API key in the T4L Trainer Settings screen. Pass --log-level DEBUG for verbose request and error logging (logs go to stderr; the API key is only ever printed to stdout on startup).

Agent setup

Agents should read the public instruction repo first:

https://github.com/BigSlikTobi/t4l-agent-instructions

Those instructions explain how to start or verify this server, connect through MCP, wait for fresh phone context, and write app-consumed results safely.

Safety model

  • REST and MCP endpoints require the API key, compared in constant time.
  • Request bodies over 25 MiB are rejected (413) to bound memory use.
  • JSON artifacts are stored in t4l.sqlite (WAL mode; writes use an immediate transaction so concurrent upserts cannot interleave).
  • Image blobs are stored under blobs/.
  • Path traversal and arbitrary file access are rejected.
  • Stored payloads are structurally validated before persisting.

Architecture

Zero runtime dependencies by design — the server is built on the Python standard library (http.server) so it installs and runs anywhere pipx does. Keep it dependency-free.

  • constants.py: single source of truth for artifact kinds, route maps, limits.
  • store.py: SQLite artifact store (WAL, immediate-transaction upserts).
  • server.py: REST handler, auth, body limits, logging.
  • mcp.py: JSON-RPC MCP tools (read context / write results).
  • validation.py: structural payload validation shared by REST + MCP writes.
  • cli.py: serve entrypoint and logging configuration.

Development

python -m venv .venv
. .venv/bin/activate
python -m pip install -e ".[dev]"
ruff format --check .
ruff check .
mypy
pytest
python -m build
twine check dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

t4l_server-0.2.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

t4l_server-0.2.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file t4l_server-0.2.0.tar.gz.

File metadata

  • Download URL: t4l_server-0.2.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for t4l_server-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d86d369466c62579aedfc91ea46967a0ec0e82c06550af79b9f96290eb07f5ca
MD5 ee4bcc4ffe4371f07b14ddbebaaa9bbc
BLAKE2b-256 1e208f95264459b77f8d8833456411ae582ec5f0640ff9e00a6441e9e331d58a

See more details on using hashes here.

Provenance

The following attestation bundles were made for t4l_server-0.2.0.tar.gz:

Publisher: publish.yml on BigSlikTobi/t4l-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file t4l_server-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: t4l_server-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for t4l_server-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7520155b3a0d4ca7ce22232da6340376bcd7cc2747f4330199753b03662edd5
MD5 d11f86a7840d7fefcfdf6a15e371ea7f
BLAKE2b-256 f60ea4b19a1e12531d2bb50fa6ff9c28a035e7daa6b791389884ffcbc200518d

See more details on using hashes here.

Provenance

The following attestation bundles were made for t4l_server-0.2.0-py3-none-any.whl:

Publisher: publish.yml on BigSlikTobi/t4l-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page