Skip to main content

Trackline MCP Client — Device Flow Auth + stdio<->SSE Bridge for the Trackline railway data platform

Project description

trackline-mcp

PyPI Test & Lint

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

  1. On first run (--auth), the client performs a Device Authorization Grant with Keycloak, opening a short URL for you to approve.
  2. The token (including an offline refresh token) is cached at ~/.pyrail/token.json.
  3. On subsequent runs, the client reads the cached token, refreshes it automatically if needed, then opens an SSE connection to the Trackline MCP server.
  4. 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

trackline_mcp-0.1.0.tar.gz (47.7 kB view details)

Uploaded Source

Built Distribution

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

trackline_mcp-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

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

Hashes for trackline_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3986c03f6b37e1a8154d7c129e44dd106f2413eaf61d8f064124bf711e275da0
MD5 380f3f29655932e0a4e215017c5545a4
BLAKE2b-256 0b5dca60fb031c059f68e39627b29f223905ebda6d0b2bd495399e955fea5078

See more details on using hashes here.

Provenance

The following attestation bundles were made for trackline_mcp-0.1.0.tar.gz:

Publisher: release.yml on Trackline-Live/trackline-mcp

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

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

Hashes for trackline_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f396a681fcab9dd23de1988f9b5444a790fae0b7292a3c8c2cf46026bdac82d6
MD5 ea5d475969539439a44a9443115dbbc6
BLAKE2b-256 b69ad200acc606a0a8a1917af0db6d987d684f8c9c5472c2679730760f13795a

See more details on using hashes here.

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

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