Socket
Book a DemoInstallSign in
Socket

mcp-tfl-journey

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mcp-tfl-journey

MCP server for TfL Journey API

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

TfL Journey MCP Server

A Model Context Protocol (MCP) server that provides journey information from Transport for London (TfL) API.

Project Structure

The project is organized into modular files following clean code principles:

mcp-tfl-journey/
├── index.js          # Main MCP server configuration and entry point
├── tfl-api.js        # TfL API communication and data fetching
├── helpers.js        # Utility functions for data extraction and processing
├── package.json      # Dependencies and project configuration
└── README.md         # This file

File Responsibilities

  • index.js: MCP server setup, tool definitions, and request handlers
  • tfl-api.js: API communication with TfL, data fetching, and response formatting
  • helpers.js: Pure utility functions for extracting and processing journey data

Features

  • Search for journey information between TfL stations
  • Extract alerts, disruptions, and stop points from journey data
  • Provide comprehensive journey summaries
  • Clean, modular, and maintainable code structure

Installation & Usage

Run directly without installation:

npx mcp-tfl-journey

Option 2: Local Installation

  • Install dependencies:

    npm install
    
  • Set your TfL API key as an environment variable:

    export TFL_API_KEY="your-api-key-here"
    
  • Run the server:

    npm start
    # or
    node index.js
    

Configuration

Set your TfL API key as an environment variable:

export TFL_API_KEY="your-api-key-here"

You can get a free API key from TfL Developer Portal.

Usage

The server provides a search_journey tool that accepts:

  • from: Source station code (e.g., "9400ZZLUKSX")
  • to: Destination station code (e.g., "9400ZZLULVT")

Publishing to npm

To publish this package to npm:

  • Update the repository URL in package.json with your actual GitHub repository

  • Login to npm:

    npm login
    
  • Publish the package:

    npm publish
    
  • After publishing, users can run:

    npx mcp-tfl-journey
    

Code Quality

This project follows clean code principles:

  • Single Responsibility: Each file has a clear, focused purpose
  • Modularity: Functions are organized by their domain and responsibility
  • Readability: Clear naming and documentation
  • Maintainability: Easy to test, modify, and extend individual components

API Endpoint

The server uses the official TfL endpoint:

https://api.tfl.gov.uk/Journey/JourneyResults/{from}/to/{to}

Station Codes

Some examples of station codes:

  • 9400ZZLUKSX: Kings Cross
  • 9400ZZLULVT: Liverpool Street
  • 9400ZZLUPAD: Paddington
  • 9400ZZLUVIC: Victoria

For more station codes, please refer to the official TfL API documentation.

Keywords

mcp

FAQs

Package last updated on 22 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.