### Install Project Dependencies Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Run this command in your project directory to install the necessary npm packages. ```bash npm install ``` -------------------------------- ### Run Development Server Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Use this command to start the MCP server in development mode. Ensure you have the necessary dependencies installed. ```bash npm run dev ``` -------------------------------- ### Troubleshoot Container Not Starting Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md View logs for the 'mcp-malaysiatransit' container to diagnose startup issues. ```bash docker-compose logs mcp-malaysiatransit ``` -------------------------------- ### Build and Start Docker Container Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Build the Docker image and start the MCP server container in detached mode. ```bash docker-compose up -d --build ``` -------------------------------- ### Self-Hosting MCP Server with npm Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Run these commands to build and start the MCP server directly using npm scripts. ```bash npm run build npm run start:http ``` -------------------------------- ### Add New MCP Server Location Block Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Example Nginx configuration for adding a new MCP server to a different path and port. ```nginx location /another-mcp/ { proxy_pass http://127.0.0.1:8081/; # ... same proxy settings } ``` -------------------------------- ### get_stop_arrivals Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Get real-time arrival predictions for a specific stop. This includes a disclaimer and confidence levels for predictions. ```APIDOC ## get_stop_arrivals ### Description Get real-time arrival predictions at a stop. ### Parameters #### Path Parameters - `area` (string): Service area ID - `stopId` (string): Stop ID from search results ### Returns Includes a comprehensive disclaimer about prediction methodology, followed by arrival data with: - Calculation method (shape-based or straight-line) - Confidence level (high, medium, or low) - ETA in minutes - Vehicle information ### Prediction Methodology: - **Shape-Based Distance** (Preferred): Uses actual route geometry, accurate within ±2-4 minutes - **Straight-Line Distance** (Fallback): Conservative estimates with 1.4x multiplier - Includes GPS speed validation, time-of-day adjustments, and stop dwell time - Conservative bias: Better to arrive early than miss the bus ### Request Example ```typescript const arrivals = await tools.get_stop_arrivals({ area: "penang", stopId: "stop_123" }); // Returns disclaimer + arrival data with confidence levels ``` ``` -------------------------------- ### Get Real-time Stop Arrivals Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieve live arrival predictions for a specific transit stop. The response includes a disclaimer, confidence levels, and ETA. ```typescript const arrivals = await tools.get_stop_arrivals({ area: "penang", stopId: "stop_123" }); // Returns disclaimer + arrival data with confidence levels ``` -------------------------------- ### Find Bus Arrival Times Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Detect the area from a location, search for a specific stop, and then get real-time arrival information for that stop. Ensure you have the stop ID from a previous search. ```typescript // 1. Detect area from location const areaResult = await tools.detect_location_area({ location: "KTM Alor Setar" }); // 2. Search for your stop const stops = await tools.search_stops({ area: areaResult.area, query: "KTM Alor Setar" }); // 3. Get real-time arrivals const arrivals = await tools.get_stop_arrivals({ area: areaResult.area, stopId: stops[0].id }); // Returns: "Bus K100(I) arrives in 1 minute, Bus K100(O) in 2 minutes" ``` -------------------------------- ### Search Stops Before Getting Details Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Always search for stops or routes before requesting their details to ensure you have a valid ID. Avoid guessing stop IDs. ```typescript // ✅ CORRECT const stops = await tools.search_stops({ area: "penang", query: "Komtar" }); const arrivals = await tools.get_stop_arrivals({ area: "penang", stopId: stops[0].id }); // ❌ WRONG - Don't guess stop IDs const arrivals = await tools.get_stop_arrivals({ area: "penang", stopId: "random_id" }); ``` -------------------------------- ### Get KTM Komuter Utara Stations Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves all stations for the KTM Komuter Utara line. Returns station codes, names, and coordinates. ```typescript const stations = await tools.get_ktm_komuter_stations(); // Returns: [{ code: "PB", name: "Padang Besar", ... }, ...] ``` -------------------------------- ### Get Penang Ferry Fare Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves fare information and accepted payment methods for the Penang Ferry service. ```typescript const fare = await tools.get_penang_ferry_fare(); // Returns: { adult: "1.40", child: "0.70", ... } ``` -------------------------------- ### get_route_stops Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Get a list of all stops associated with a specific route ID within a given service area. ```APIDOC ## get_route_stops ### Description Get all stops served by a specific route. ### Parameters #### Path Parameters - `area` (string): Service area ID - `routeId` (string): Route ID from `list_routes` ``` -------------------------------- ### get_live_vehicles Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Get the real-time positions of vehicles (buses or rail) within a specified service area. Can be filtered by vehicle type. ```APIDOC ## get_live_vehicles ### Description Get real-time vehicle positions. ### Parameters #### Path Parameters - `area` (string): Service area ID - `type` (enum, optional): Filter by type ('bus' or 'rail') ### Request Example ```typescript const vehicles = await tools.get_live_vehicles({ area: "penang" }); ``` ``` -------------------------------- ### Get KTM Station Departures Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetches departure times for a specific KTM station. Specify the station name and the type of schedule (ktm-komuter-utara or ktm-intercity). ```typescript const departures = await tools.get_ktm_station_departures({ stationName: "Butterworth", type: "ktm-komuter-utara" }); ``` -------------------------------- ### Get Live Vehicle Positions Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetch the real-time locations of transit vehicles within a specified area. You can optionally filter by vehicle type (bus or rail). ```typescript const vehicles = await tools.get_live_vehicles({ area: "penang" }); ``` -------------------------------- ### Get API Analytics Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves API usage analytics from the Malaysia Transit middleware. The 'type' parameter allows fetching different levels of detail, from a summary to client-specific usage. ```typescript // Get summary analytics const summary = await tools.get_api_analytics({ type: "summary" }); // Get client usage (see which apps use the API) const clients = await tools.get_api_analytics({ type: "clients" }); ``` -------------------------------- ### Get Service Area Information Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Use this function to fetch detailed information for a specific transit service area. Provide the `areaId` as a string parameter. ```typescript const info = await tools.get_area_info({ areaId: "penang" }); ``` -------------------------------- ### Get Route Departures Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves the next N departures for a specific route in both directions. Specify the service area, route ID, and optionally the number of departures. ```typescript const departures = await tools.get_route_departures({ area: "ipoh", routeId: "A32", count: 5 }); ``` -------------------------------- ### Get Area Analytics Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetches detailed API usage analytics for a specific service area within the Malaysia Transit system. Requires the service area ID. ```typescript const penangStats = await tools.get_area_analytics({ area: "penang" }); ``` -------------------------------- ### Create MCP Server Directory Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Create a directory on the VPS to store the MCP server files and navigate into it. ```bash mkdir -p /opt/mcp-servers/malaysiatransit cd /opt/mcp-servers/malaysiatransit ``` -------------------------------- ### Build for Deployment Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Execute this command to build the MCP server for production deployment. This prepares the application for distribution. ```bash npm run build ``` -------------------------------- ### hello Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md A simple test tool designed to verify the operational status of the server. ```APIDOC ## hello ### Description Simple test tool to verify server is working. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None provided in source. ### Response #### Success Response (200) None provided in source. #### Response Example None provided in source. ### Errors None provided in source. ``` -------------------------------- ### Configure Nginx for MCP Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Copy the Nginx configuration, enable the site, test the configuration, and reload Nginx. ```bash # Copy the nginx config sudo cp deploy/nginx-mcp.conf /etc/nginx/sites-available/mcp.techmavie.digital # Enable the site sudo ln -s /etc/nginx/sites-available/mcp.techmavie.digital /etc/nginx/sites-enabled/ # Test nginx config sudo nginx -t # Reload nginx sudo systemctl reload nginx ``` -------------------------------- ### Test MCP Connection - Call Hello Tool Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Send a POST request to the MCP endpoint to call the 'hello' tool. ```bash curl -X POST https://mcp.techmavie.digital/malaysiatransit/mcp \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"hello","arguments":{}}}' ``` -------------------------------- ### Test MCP Connection - List Tools Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Send a POST request to the MCP endpoint to list available tools. ```bash curl -X POST https://mcp.techmavie.digital/malaysiatransit/mcp \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' ``` -------------------------------- ### SSH into VPS Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Connect to your VPS using SSH. Ensure you have the correct IP address. ```bash ssh root@202.61.238.12 ``` -------------------------------- ### View MCP Server Logs Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Navigate to the MCP server directory and view the logs using docker-compose. ```bash cd /opt/mcp-servers/malaysiatransit docker-compose logs -f ``` -------------------------------- ### Obtain SSL Certificate Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Use Certbot to obtain an SSL certificate for your domain. ```bash sudo certbot certonly --nginx -d mcp.techmavie.digital ``` -------------------------------- ### Client Configuration for Claude/Cursor/Windsurf Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Configure MCP clients like Claude Desktop, Cursor, or Windsurf to connect to the Malaysia Transit MCP server. ```json { "mcpServers": { "malaysia-transit": { "transport": "streamable-http", "url": "https://mcp.techmavie.digital/malaysiatransit/mcp" } } } ``` -------------------------------- ### Clone MCP Repository Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Clone the Malaysia Transit MCP repository into the created directory. ```bash git clone https://github.com/hithereiamaliff/mcp-malaysiatransit.git . ``` -------------------------------- ### Self-Hosting MCP Server with Docker Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Use this command to build and run the MCP server in detached mode using Docker Compose. ```bash docker compose up -d --build ``` -------------------------------- ### Project Structure Overview Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md This is a file tree representation of the malaysiatransit-mcp project. It shows the organization of source files, deployment scripts, and configuration files. ```plaintext malaysiatransit-mcp/ ├── src/ │ ├── index.ts # Main MCP server entry point │ ├── http-server.ts # Streamable HTTP server with analytics │ ├── transit.tools.ts # Transit tool implementations │ ├── geocoding.utils.ts # Location detection utilities │ ├── inspector.ts # MCP Inspector entry point │ └── server.ts # HTTP server for testing ├── deploy/ │ ├── DEPLOYMENT.md # VPS deployment guide │ └── nginx-mcp.conf # Nginx reverse proxy config ├── .github/ │ └── workflows/ │ └── deploy-vps.yml # GitHub Actions auto-deploy ├── docker-compose.yml # Docker deployment config ├── Dockerfile # Container build config ├── package.json # Project dependencies ├── tsconfig.json # TypeScript configuration ├── .env.sample # Environment variables template ├── README.md # This file └── LICENSE # MIT License ``` -------------------------------- ### MCP Inspector Connection Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Connect to the MCP server using the MCP Inspector tool. Select 'Streamable HTTP' and provide the server URL. ```bash npx @modelcontextprotocol/inspector # Select "Streamable HTTP" # Enter URL: https://mcp.techmavie.digital/malaysiatransit/mcp ``` -------------------------------- ### Restart MCP Server Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Restart the MCP server using docker-compose. ```bash docker-compose restart ``` -------------------------------- ### Troubleshoot Nginx 502 Bad Gateway Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Check container status, logs, and port binding to resolve Nginx 502 errors. ```bash # Check if container is running: `docker-compose ps` # Check container logs: `docker-compose logs` # Verify port binding: `docker port mcp-malaysiatransit` ``` -------------------------------- ### Plan a Multi-Modal Journey Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Use this tool to plan a journey across Malaysia using various transport modes like bus, rail, and ferry. It composes legs via Google Directions and computes fares locally. Note that ETAs are scheduled times and fares might be missing for some legs. ```typescript const plan = await tools.plan_journey({ originText: "Penang Airport", destinationText: "Komtar", }); ``` -------------------------------- ### get_penang_ferry_overview Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Provides an overview of the Penang Ferry service, including route details, operator information, and general service facts. ```APIDOC ## get_penang_ferry_overview ### Description Get Penang Ferry service overview including route, operator, and general info. ### Parameters None ``` -------------------------------- ### Verify Docker Container Status Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Check the status of the running Docker containers and view live logs. ```bash docker-compose ps docker-compose logs -f ``` -------------------------------- ### get_fare_structures Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves the fare structure definitions utilized by the middleware. This includes details on distance-based pricing (BAS.MY), staged zones for Rapid Penang, and free routes for Penang CAT services. ```APIDOC ## get_fare_structures ### Description Get the fare structure definitions used by the middleware. Returns BAS.MY distance-based pricing, Rapid Penang staged zones, and free Penang CAT routes (CAT, CT13, C13A/B/C, CT14, CT15). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None provided in source. ### Response #### Success Response (200) None provided in source. #### Response Example None provided in source. ### Errors None provided in source. ### Use case Explain to a user *how* a fare is computed before calling `calculate_fare`. ``` -------------------------------- ### get_debug_info Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves comprehensive debug information for the Malaysia Transit middleware service. ```APIDOC ## get_debug_info ### Description Get comprehensive debug information about the middleware service. ### Parameters None ``` -------------------------------- ### Update MCP Server Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Update the MCP server to the latest version by pulling changes and rebuilding the Docker image. ```bash git pull origin main docker-compose up -d --build ``` -------------------------------- ### Stop MCP Server Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Stop the MCP server using docker-compose. ```bash docker-compose down ``` -------------------------------- ### Test Local Health Endpoint Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Verify the MCP server is running by curling its local health endpoint. ```bash curl http://localhost:8080/health ``` -------------------------------- ### get_system_health Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Checks the current health status of the Malaysia Transit middleware service. ```APIDOC ## get_system_health ### Description Check the health status of the Malaysia Transit middleware service. ### Parameters None ``` -------------------------------- ### places_autocomplete Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md A server-side proxy for Google Places autocomplete, specifically tailored for Malaysian place names. It returns ranked suggestions and can provide transit-aware overrides, such as snapping airports to canonical bus stops. ```APIDOC ## places_autocomplete ### Description Server-side Google Places autocomplete proxy for Malaysian place names. Returns ranked suggestions including transit-aware overrides (airports snap to canonical bus stops). ### Parameters #### Path Parameters None #### Query Parameters - `input` (string, 2-120 chars) - Search input - `sessiontoken` (string, optional) - Reuse the same token across autocomplete + details calls for Google Places billing - `language` (string, optional) - Filter by language (`en`, `ms`, `th`) #### Request Body None ### Request Example None provided in source. ### Response #### Success Response (200) None provided in source. #### Response Example None provided in source. ### Errors None provided in source. ### Use case When the user gives an ambiguous place name and you want them to disambiguate before calling `plan_journey`. ``` -------------------------------- ### get_stop_routes Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Lists all routes serving a specific stop, including their next departures. ```APIDOC ## get_stop_routes ### Description Get all routes serving a specific stop with their next departures. ### Parameters #### Query Parameters - **area** (string): Required. Service area ID - **stopId** (string): Required. Stop ID from search_stops - **count** (number): Optional. Number of departures per route (default: 3) ``` -------------------------------- ### Test MCP Endpoint via Nginx Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Test the MCP health and main endpoints through the Nginx reverse proxy. ```bash # Test health endpoint through nginx curl https://mcp.techmavie.digital/malaysiatransit/health # Test MCP endpoint curl -X POST https://mcp.techmavie.digital/malaysiatransit/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' ``` -------------------------------- ### plan_journey Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Plans a multi-modal public transport journey across Malaysia. It can compose various transport modes like bus, rail, and ferry, and computes per-leg fares locally. This is a BETA feature and has some caveats regarding ETAs and fare accuracy. ```APIDOC ## plan_journey ⭐ ### Description Plan a multi-modal public transport journey across Malaysia. Composes bus, rail, ferry, and walking legs via Google Directions in transit mode, then computes per-leg fares locally. ### Parameters #### Path Parameters None #### Query Parameters - `originText` (string, optional) - Place name (e.g., "Komtar", "Penang Airport", "KL Sentral") - `originLat` / `originLng` (number, optional) - Coordinates (use either text OR lat+lng) - `destinationText` / `destinationLat` / `destinationLng` (string/number, optional) - Same shape as origin - `modeBus` (boolean, optional) - Filter transport modes - `modeRail` (boolean, optional) - Filter transport modes - `modeFerry` (boolean, optional) - Filter transport modes - `language` (string, optional) - Filter by language (`en`, `ms`, `th`) #### Request Body None ### Request Example ```typescript const plan = await tools.plan_journey({ originText: "Penang Airport", destinationText: "Komtar", }); ``` ### Response #### Success Response (200) Array of journey alternatives, each with `summary` (duration, walking distance, transfer count, fare estimate with `hasMissingFare` flag), `legs[]` (mode, route, from/to stops, times, per-leg fare), and `walkOnly` flag. #### Response Example None provided in source. ### Errors - `invalid-origin` (400) - `invalid-destination` (400) - `invalid-modes` (400) - `unsupported-inter-area` (400) - `area-out-of-coverage` (400) - `engine-unavailable` (503) - `routing-failed` (503) ``` -------------------------------- ### find_nearby_stops_with_routes Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Find nearby stops and list all routes that serve them in one consolidated call. Location can be specified by name or coordinates. ```APIDOC ## find_nearby_stops_with_routes ### Description Find nearby stops and get all routes serving those stops in one call. ### Parameters #### Path Parameters - `area` (string): Service area ID - `location` (string, optional): Place name to geocode - `lat` (number, optional): Latitude coordinate (required if `location` not provided) - `lon` (number, optional): Longitude coordinate (required if `location` not provided) - `radius` (number, optional): Search radius in meters (default: 500) ``` -------------------------------- ### find_nearby_stops_with_arrivals Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Find nearby stops and retrieve their real-time arrival predictions in a single API call. Supports filtering by route. ```APIDOC ## find_nearby_stops_with_arrivals ### Description Find nearby stops and get real-time arrivals in one call. ### Parameters #### Path Parameters - `area` (string): Service area ID - `location` (string, optional): Place name to geocode - `lat` (number, optional): Latitude coordinate (required if `location` not provided) - `lon` (number, optional): Longitude coordinate (required if `location` not provided) - `radius` (number, optional): Search radius in meters (default: 500) - `routeFilter` (string, optional): Filter arrivals by route number (e.g., "302", "101") ``` -------------------------------- ### list_routes Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieve a list of all available routes within a specified service area. ```APIDOC ## list_routes ### Description List all routes in an area. ### Parameters #### Path Parameters - `area` (string): Service area ID ``` -------------------------------- ### get_route_schedule Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves the complete daily schedule for a specified route. ```APIDOC ## get_route_schedule ### Description Get the complete daily schedule for a route. ### Parameters #### Query Parameters - **area** (string): Required. Service area ID - **routeId** (string): Required. Route ID from list_routes ``` -------------------------------- ### Test SSL Certificate Renewal Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/deploy/DEPLOYMENT.md Perform a dry run to test if SSL certificates can be renewed successfully. ```bash sudo certbot renew --dry-run ``` -------------------------------- ### get_next_departure Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetches the single next departure for a given route and direction. ```APIDOC ## get_next_departure ### Description Get the single next departure for a route in a specific direction. ### Parameters #### Query Parameters - **area** (string): Required. Service area ID - **routeId** (string): Required. Route ID from list_routes - **direction** (enum): Optional. 'outbound', 'inbound', or 'loop' ``` -------------------------------- ### get_route_details Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetch detailed information about a specific route, identified by its ID and service area. ```APIDOC ## get_route_details ### Description Get detailed route information. ### Parameters #### Path Parameters - `area` (string): Service area ID - `routeId` (string): Route ID from list_routes ``` -------------------------------- ### place_details Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Resolves a `placeId` obtained from `places_autocomplete` into its coordinates and a formatted address. ```APIDOC ## place_details ### Description Resolve a `placeId` from `places_autocomplete` into coordinates and a formatted address. ### Parameters #### Path Parameters None #### Query Parameters - `placeId` (string) - From `places_autocomplete` (Google place_id or `override:*` synthetic ID) - `sessiontoken` (string, optional) - Same session token used in autocomplete - `language` (string, optional) - Filter by language (`en`, `ms`, `th`) #### Request Body None ### Request Example None provided in source. ### Response #### Success Response (200) None provided in source. #### Response Example None provided in source. ### Errors None provided in source. ``` -------------------------------- ### get_penang_ferry_schedule Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves the complete schedule for the Penang Ferry service, detailing operating hours and frequency. ```APIDOC ## get_penang_ferry_schedule ### Description Get the full Penang Ferry schedule with operating hours and frequency. ### Parameters None ``` -------------------------------- ### Discover Transit Routes Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md List all available routes within a given area, or fetch detailed information for a specific route using its ID. ```typescript // List all routes in Klang Valley const routes = await tools.list_routes({ area: "klang-valley" }); // Get detailed route information const routeDetails = await tools.get_route_details({ area: "klang-valley", routeId: "LRT-KJ" }); ``` -------------------------------- ### Track Live Buses by Area and Type Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieve a list of all live vehicles within a specified area, or filter the results to include only buses. ```typescript // Get all live vehicles in Penang const vehicles = await tools.get_live_vehicles({ area: "penang" }); // Filter by bus only const buses = await tools.get_live_vehicles({ area: "klang-valley", type: "bus" }); ``` -------------------------------- ### Handle Provider Unavailable Errors Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Implement error handling for cases where the transit provider might be unavailable. Check the provider status before informing the user. ```typescript try { const arrivals = await tools.get_stop_arrivals({ ... }); } catch (error) { // Check provider status const status = await tools.get_provider_status({ area: "penang" }); if (status.providers[0].status !== "active") { "The transit provider is currently unavailable. Please try again later or check the official transit app." } } ``` -------------------------------- ### get_penang_ferry_next_departure Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetches the next upcoming departure times for the Penang Ferry from both terminals. ```APIDOC ## get_penang_ferry_next_departure ### Description Get the next upcoming Penang Ferry departures from both terminals. ### Parameters None ``` -------------------------------- ### get_route_stops_for_fare Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetches all stops on a route, including their distances, for fare calculation purposes. ```APIDOC ## get_route_stops_for_fare ### Description Get all stops on a route with their distances for fare calculation. ### Parameters #### Query Parameters - **area** (string): Required. Service area ID - **routeId** (string): Required. Route ID from get_fare_routes ``` -------------------------------- ### get_stop_details Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieve detailed information for a specific transit stop using its ID and service area. ```APIDOC ## get_stop_details ### Description Get detailed information about a stop. ### Parameters #### Path Parameters - `area` (string): Service area ID - `stopId` (string): Stop ID from search results ``` -------------------------------- ### Test Middleware API Endpoint Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Use curl to directly test if your middleware URL is accessible and returning data for the /api/areas endpoint. This helps diagnose connection issues. ```bash curl https://your-middleware-url/api/areas ``` -------------------------------- ### get_penang_ferry_terminals Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Provides information about Penang Ferry terminals, including their locations and available facilities. ```APIDOC ## get_penang_ferry_terminals ### Description Get Penang Ferry terminal information including locations and facilities. ### Parameters None ``` -------------------------------- ### get_journey_areas Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Lists the service areas supported by the journey planner, including engine names and walking/transit configurations. ```APIDOC ## get_journey_areas ### Description List service areas supported by the journey planner, plus engine name and walking/transit config. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None provided in source. ### Response #### Success Response (200) None provided in source. #### Response Example None provided in source. ### Errors None provided in source. ``` -------------------------------- ### get_api_analytics Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetches API usage analytics and statistics from the middleware, with options to filter by type. ```APIDOC ## get_api_analytics ### Description Get API usage analytics and statistics from the middleware. ### Parameters #### Path Parameters - `type` (enum, optional): Type of analytics to retrieve: - `summary` (default): Overview with requests/hour, error rate, uptime - `endpoints`: Per-endpoint statistics - `areas`: Per-service-area statistics - `cumulative`: All-time totals - `clients`: App/website usage breakdown ### Request Example ```json { "type": "summary" } ``` ### Request Example ```json { "type": "clients" } ``` ``` -------------------------------- ### search_stops Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Search for transit stops by name within a specified service area. It's recommended to use `detect_location_area` first if the area is unknown. ```APIDOC ## search_stops ### Description Search for stops by name. ### Parameters #### Path Parameters - `area` (string): Service area ID - `query` (string): Search query (e.g., "Komtar", "KLCC") ### Request Example ```typescript const stops = await tools.search_stops({ area: "penang", query: "Komtar" }); ``` ``` -------------------------------- ### Search for Stops by Name Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Use this function to find transit stops by their name within a specified service area. Ensure you have the correct service area ID. ```typescript const stops = await tools.search_stops({ area: "penang", query: "Komtar" }); ``` -------------------------------- ### list_service_areas Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Lists all available transit service areas in Malaysia, providing their IDs, names, and capabilities. ```APIDOC ## list_service_areas ### Description List all available transit areas in Malaysia. ### Parameters None ### Returns List of service areas with their IDs, names, and capabilities. ### Example ```typescript const areas = await tools.list_service_areas(); ``` ``` -------------------------------- ### Detect Location Area Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Use this tool when a user mentions a location without specifying the area. It helps in determining the correct area for subsequent API calls. ```typescript // User: "When is the next bus at KTM Alor Setar?" const areaResult = await tools.detect_location_area({ location: "KTM Alor Setar" }); // Returns: { area: "alor-setar", confidence: "high" } ``` -------------------------------- ### get_penang_ferry_fare Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves information on Penang Ferry fares and accepted payment methods. ```APIDOC ## get_penang_ferry_fare ### Description Get Penang Ferry fare information and payment methods. ### Parameters None ### Returns Fare information including adult and child prices, and currency. ``` -------------------------------- ### get_ktm_schedules Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetches the complete KTM schedule data for a specified schedule type (Komuter Utara or Intercity). ```APIDOC ## get_ktm_schedules ### Description Get full KTM schedule data for a specific schedule type. ### Parameters #### Path Parameters - `type` (enum): `ktm-komuter-utara` or `ktm-intercity` ``` -------------------------------- ### List Service Areas Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Call this function to retrieve a list of all available transit service areas in Malaysia. No parameters are required. ```typescript const areas = await tools.list_service_areas(); ``` -------------------------------- ### get_route_departures Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves the next N departures for a specific route, considering both directions. ```APIDOC ## get_route_departures ### Description Get the next N departures for a specific route (both directions). ### Parameters #### Query Parameters - **area** (string): Required. Service area ID (e.g., "ipoh", "seremban", "penang") - **routeId** (string): Required. Route ID from list_routes - **count** (number): Optional. Number of departures to return (default: 5) ### Request Example ```typescript const departures = await tools.get_route_departures({ area: "ipoh", routeId: "A32", count: 5 }); ``` ``` -------------------------------- ### get_ktm_komuter_fare_matrix Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves the complete fare matrix for the KTM Komuter Utara service, detailing fares between all station pairs. ```APIDOC ## get_ktm_komuter_fare_matrix ### Description Get the full KTM Komuter Utara fare matrix showing fares between all station pairs. ### Parameters None ``` -------------------------------- ### calculate_fare Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Calculates the bus fare between two specified stops on a given route. ```APIDOC ## calculate_fare ### Description Calculate the bus fare between two stops on a route. ### Parameters #### Query Parameters - **area** (string): Required. Service area ID - **routeId** (string): Required. Route ID from get_fare_routes - **fromStop** (string): Required. Origin stop ID - **toStop** (string): Required. Destination stop ID ### Returns Adult, concession, and child fares in MYR with disclaimer. ### Example ```typescript const fare = await tools.calculate_fare({ area: "ipoh", routeId: "A32", fromStop: "stop_001", toStop: "stop_015" }); // Returns: { adult: "1.50", concession: "0.75", child: "FREE" } ``` ``` -------------------------------- ### calculate_journey_fare Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Calculates the total fare for a multi-leg journey involving bus transfers. ```APIDOC ## calculate_journey_fare ### Description Calculate the total fare for a multi-leg journey with bus transfers. ### Parameters #### Query Parameters - **area** (string): Required. Base service area ID - **legs** (array): Required. Array of journey legs (max 5), each with: - **routeId** (string): Required. Route ID for this leg - **fromStop** (string): Required. Origin stop ID - **toStop** (string): Required. Destination stop ID - **areaId** (string): Optional. Area ID for this leg (for inter-area journeys) ### Notes Each bus change requires a separate fare payment (BAS.MY does not have integrated transfers). ``` -------------------------------- ### get_fare_routes Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves all routes available for fare calculation within a specific service area. ```APIDOC ## get_fare_routes ### Description Get all routes available for fare calculation in a specific area. ### Parameters #### Query Parameters - **area** (string): Required. Service area ID (e.g., "ipoh", "seremban", "penang", "kangar") ### Notes Supported Areas: BAS.MY areas (Ipoh, Seremban, Kangar, Alor Setar, Kota Bharu, Kuala Terengganu, Melaka, Johor, Kuching) and Rapid Penang. ``` -------------------------------- ### Calculate KTM Komuter Utara Fare Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Calculates the fare between two specified KTM Komuter Utara stations. Requires origin and destination station codes. ```typescript const fare = await tools.calculate_ktm_komuter_fare({ from: "BU", to: "IP" }); // Returns: { adult: "12.00", child: "6.00", currency: "MYR" } ``` -------------------------------- ### detect_location_area Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Automatically detects the transit service area for a given location using geocoding, returning the area ID and confidence level. ```APIDOC ## detect_location_area ### Description Automatically detect which transit service area a location belongs to using geocoding. ### Parameters #### Path Parameters - **location** (string) - Required - Location name or place (e.g., "KTM Alor Setar", "Komtar", "KLCC") ### Returns Detected area ID, confidence level, and location details. ### Example ```typescript const result = await tools.detect_location_area({ location: "KTM Alor Setar" }); // Returns: { area: "alor-setar", confidence: "high" } ``` ``` -------------------------------- ### calculate_ktm_komuter_fare Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Calculates the fare for the KTM Komuter Utara service between two specified stations. ```APIDOC ## calculate_ktm_komuter_fare ### Description Calculate KTM Komuter Utara fare between two stations. ### Parameters #### Path Parameters - `from` (string): Origin station code (e.g., "BU" for Butterworth) - `to` (string): Destination station code (e.g., "IP" for Ipoh) ### Request Example ```json { "from": "BU", "to": "IP" } ``` ### Returns Station codes, names, and coordinates. ``` -------------------------------- ### find_nearby_stops Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Find transit stops near a specified location, optionally filtering by radius. Location can be a place name or coordinates. ```APIDOC ## find_nearby_stops ### Description Find nearby stops and the routes that serve them. ### Parameters #### Path Parameters - `area` (string): Service area ID - `location` (string, optional): Place name to geocode (e.g., "KLCC", "Komtar") - `lat` (number, optional): Latitude coordinate (required if `location` not provided) - `lon` (number, optional): Longitude coordinate (required if `location` not provided) - `radius` (number, optional): Search radius in meters (default: 500) ``` -------------------------------- ### get_area_info Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves detailed information about a specific transit service area using its ID. ```APIDOC ## get_area_info ### Description Get detailed information about a specific area. ### Parameters #### Path Parameters - **areaId** (string) - Required - Service area ID (e.g., "penang", "klang-valley") ### Example ```typescript const info = await tools.get_area_info({ areaId: "penang" }); ``` ``` -------------------------------- ### get_provider_status Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Check the operational status of the transit data provider for a given service area. ```APIDOC ## get_provider_status ### Description Check provider operational status. ### Parameters #### Path Parameters - `area` (string): Service area ID ``` -------------------------------- ### get_route_status Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Checks if a route is currently operating based on its schedule. ```APIDOC ## get_route_status ### Description Check if a route is currently operating based on its schedule. ### Parameters #### Query Parameters - **area** (string): Required. Service area ID - **routeId** (string): Required. Route ID from list_routes ``` -------------------------------- ### get_ktm_komuter_stations Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves all 23 KTM Komuter Utara stations, including their codes, names, and coordinates. ```APIDOC ## get_ktm_komuter_stations ### Description Get all 23 KTM Komuter Utara stations (Padang Besar - Butterworth - Ipoh line). ### Parameters None ### Returns Station codes, names, and coordinates. ``` -------------------------------- ### get_area_analytics Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves detailed API usage analytics for a specific service area within the Malaysia Transit system. ```APIDOC ## get_area_analytics ### Description Get detailed API usage analytics for a specific service area. ### Parameters #### Path Parameters - `area` (string): Service area ID (e.g., "penang", "klang-valley") ### Request Example ```json { "area": "penang" } ``` ``` -------------------------------- ### Calculate Fare Between Stops Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Calculates the bus fare between two specified stops on a given route. This function returns adult, concession, and child fares in MYR. Ensure the correct service area, route ID, origin stop ID, and destination stop ID are provided. ```typescript const fare = await tools.calculate_fare({ area: "ipoh", routeId: "A32", fromStop: "stop_001", toStop: "stop_015" }); // Returns: { adult: "1.50", concession: "0.75", child: "FREE" } ``` -------------------------------- ### get_route_origin Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetches the origin stop name for a route in a specified direction. ```APIDOC ## get_route_origin ### Description Get the origin stop name for a route in a specific direction. ### Parameters #### Query Parameters - **area** (string): Required. Service area ID - **routeId** (string): Required. Route ID from list_routes - **direction** (enum): Optional. 'outbound' or 'inbound' ``` -------------------------------- ### get_ktm_station_departures Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Fetches departure times for a specific KTM station, supporting both Komuter Utara and Intercity services. ```APIDOC ## get_ktm_station_departures ### Description Get departure times for a specific KTM station. ### Parameters #### Path Parameters - `stationName` (string): Station name (e.g., "Butterworth", "Ipoh") - `type` (enum): Schedule type - `ktm-komuter-utara` or `ktm-intercity` ### Request Example ```json { "stationName": "Butterworth", "type": "ktm-komuter-utara" } ``` ``` -------------------------------- ### get_route_directions_for_fare Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves the available directions for a route when calculating fares. ```APIDOC ## get_route_directions_for_fare ### Description Get available directions for a route when calculating fares. ### Parameters #### Query Parameters - **area** (string): Required. Service area ID - **routeId** (string): Required. Route ID from get_fare_routes ``` -------------------------------- ### get_ktm_intercity_fare Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Looks up the fare for KTM Intercity routes (SH and ERT). Currently, this endpoint returns an HTTP 501 status code as the fare data is not yet integrated. The response provides information on related endpoints and a link to the official KTMB website. ```APIDOC ## get_ktm_intercity_fare ### Description Look up KTM Intercity (SH and ERT routes) fare. NOTE: Currently returns HTTP 501 because Intercity fare data is not yet integrated. The response includes pointers to related endpoints and a link to the official KTMB website. Call this tool to surface the gap honestly to the user rather than guessing a fare. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None provided in source. ### Response #### Success Response (501) Includes pointers to related endpoints and a link to the official KTMB website. #### Response Example None provided in source. ### Errors - HTTP 501 (Not Implemented) ``` -------------------------------- ### get_ktm_stations Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieves a list of all KTM stations for a specified schedule type (Komuter Utara or Intercity). ```APIDOC ## get_ktm_stations ### Description Get all KTM stations for a specific schedule type. ### Parameters #### Path Parameters - `type` (enum): `ktm-komuter-utara` or `ktm-intercity` ``` -------------------------------- ### Detect Location Area Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Automatically detect the transit service area for a given location string. This function uses geocoding and returns the detected area ID and confidence level. It may fall back to Nominatim if a Google Maps API key is not configured. ```typescript const result = await tools.detect_location_area({ location: "KTM Alor Setar" }); // Returns: { area: "alor-setar", confidence: "high" } ``` -------------------------------- ### find_nearby_ktm_stations Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Finds KTM stations near a given geographical location, with an optional search radius. ```APIDOC ## find_nearby_ktm_stations ### Description Find KTM stations near a specific location. ### Parameters #### Path Parameters - `lat` (number): Latitude coordinate - `lon` (number): Longitude coordinate - `radius` (number, optional): Search radius in kilometers (default: 10) - `type` (enum): `ktm-komuter-utara` or `ktm-intercity` ``` -------------------------------- ### get_route_geometry Source: https://github.com/hithereiamaliff/mcp-malaysiatransit/blob/main/README.md Retrieve the geographical path of a route, suitable for map visualizations. Requires route ID and service area. ```APIDOC ## get_route_geometry ### Description Get route path for map visualization. ### Parameters #### Path Parameters - `area` (string): Service area ID - `routeId` (string): Route ID from list_routes ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.