Trackline MCP Client — Device Flow Auth + stdio<->SSE Bridge for the Trackline railway data platform
Project description
trackline-mcp
A zero-dependency Python MCP client that bridges Claude Code (and other MCP hosts) to the Trackline railway data platform via SSE. Distributed as a uvx-runnable package — no manual installation or virtualenv required.
Installation
Via uvx (recommended)
No installation needed. Run directly:
uvx trackline-mcp --auth
Via pip
pip install trackline-mcp
trackline-mcp --auth
Authentication
Trackline MCP uses OAuth 2.0 Device Authorization Grant (no browser redirect required). You authenticate once and the token is cached at ~/.pyrail/token.json with automatic refresh via an offline token.
Step 1 — Authenticate in a terminal:
uvx trackline-mcp --auth
This opens a URL. Visit it, log in, and the token is cached automatically.
Step 2 — Connect from Claude Code (see config below — no manual step needed).
Claude Code / MCP Configuration
Add to your .mcp.json (project or global):
{
"mcpServers": {
"trackline": {
"command": "uvx",
"args": ["trackline-mcp"]
}
}
}
Dev Environment Overrides
For local development or custom deployments, you can override the default URLs:
Via CLI flags
uvx trackline-mcp --auth-url https://auth.local --mcp-url http://localhost:8080/sse
Via environment variables
export TRACKLINE_AUTH_URL=https://auth.local
export TRACKLINE_MCP_URL=http://localhost:8080/sse
uvx trackline-mcp
Config priority: CLI flag > environment variable > hardcoded default
In .mcp.json with overrides
{
"mcpServers": {
"trackline-dev": {
"command": "uvx",
"args": ["trackline-mcp", "--mcp-url", "http://localhost:8080/sse"],
"env": {
"TRACKLINE_AUTH_URL": "https://auth.local"
}
}
}
}
CLI Reference
usage: trackline-mcp [-h] [--auth] [--auth-url AUTH_URL] [--mcp-url MCP_URL]
options:
--auth Authenticate via device flow and cache token, then exit
--auth-url URL Override Keycloak base URL
(default: TRACKLINE_AUTH_URL env or https://auth.trackline.live)
--mcp-url URL Override MCP SSE URL
(default: TRACKLINE_MCP_URL env or https://mcp.trackline.live/sse)
Development
Setup
git clone https://github.com/Trackline-Live/trackline-mcp
cd trackline-mcp
uv venv && uv pip install -e ".[dev]"
Run tests
pytest --cov=src --cov-report=term-missing
Lint
ruff check src/ tests/
ruff format src/ tests/
How It Works
- On first run (
--auth), the client performs a Device Authorization Grant with Keycloak, opening a short URL for you to approve. - The token (including an offline refresh token) is cached at
~/.pyrail/token.json. - On subsequent runs, the client reads the cached token, refreshes it automatically if needed, then opens an SSE connection to the Trackline MCP server.
- JSON-RPC messages from Claude Code arrive on stdin and are POSTed to the server; server SSE events are forwarded to stdout.
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
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 trackline_mcp-0.1.0.tar.gz.
File metadata
- Download URL: trackline_mcp-0.1.0.tar.gz
- Upload date:
- Size: 47.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3986c03f6b37e1a8154d7c129e44dd106f2413eaf61d8f064124bf711e275da0
|
|
| MD5 |
380f3f29655932e0a4e215017c5545a4
|
|
| BLAKE2b-256 |
0b5dca60fb031c059f68e39627b29f223905ebda6d0b2bd495399e955fea5078
|
Provenance
The following attestation bundles were made for trackline_mcp-0.1.0.tar.gz:
Publisher:
release.yml on Trackline-Live/trackline-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trackline_mcp-0.1.0.tar.gz -
Subject digest:
3986c03f6b37e1a8154d7c129e44dd106f2413eaf61d8f064124bf711e275da0 - Sigstore transparency entry: 1252208181
- Sigstore integration time:
-
Permalink:
Trackline-Live/trackline-mcp@1c45349e58c37602bb7995f831cc64976d80a3a0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Trackline-Live
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1c45349e58c37602bb7995f831cc64976d80a3a0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file trackline_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trackline_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f396a681fcab9dd23de1988f9b5444a790fae0b7292a3c8c2cf46026bdac82d6
|
|
| MD5 |
ea5d475969539439a44a9443115dbbc6
|
|
| BLAKE2b-256 |
b69ad200acc606a0a8a1917af0db6d987d684f8c9c5472c2679730760f13795a
|
Provenance
The following attestation bundles were made for trackline_mcp-0.1.0-py3-none-any.whl:
Publisher:
release.yml on Trackline-Live/trackline-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trackline_mcp-0.1.0-py3-none-any.whl -
Subject digest:
f396a681fcab9dd23de1988f9b5444a790fae0b7292a3c8c2cf46026bdac82d6 - Sigstore transparency entry: 1252208329
- Sigstore integration time:
-
Permalink:
Trackline-Live/trackline-mcp@1c45349e58c37602bb7995f831cc64976d80a3a0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Trackline-Live
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1c45349e58c37602bb7995f831cc64976d80a3a0 -
Trigger Event:
push
-
Statement type: