Skip to main content
Glama

list_stations

Retrieve a complete list of Caltrain stations to ensure accurate station names for train schedules. Use this tool to resolve 'Station not found' errors in next_trains() queries.

Instructions

List all available Caltrain stations.

This tool is useful when you need to find the exact station names, especially if the next_trains() tool returns a "Station not found" error. Station names are case-insensitive and support some common abbreviations like 'SF' and 'SJ'.

Returns a formatted list of all Caltrain stations that can be used as origin or destination in the next_trains() tool.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_stations' tool. It is registered via the @mcp.tool() decorator and implements the logic to list all Caltrain stations using GTFS data.
    @mcp.tool() async def list_stations() -> str: """List all available Caltrain stations. This tool is useful when you need to find the exact station names, especially if the next_trains() tool returns a "Station not found" error. Station names are case-insensitive and support some common abbreviations like 'SF' and 'SJ'. Returns a formatted list of all Caltrain stations that can be used as origin or destination in the next_trains() tool. """ try: stations = gtfs.list_all_stations(gtfs.get_default_data()) stations_list = "\n".join([f"• {station}" for station in stations]) return f"Available Caltrain stations:\n{stations_list}\n\nNote: Station names support common abbreviations like 'SF' for San Francisco and 'SJ' for San Jose." except Exception as e: return f"Error: {str(e)}"
  • Helper function that extracts and returns the sorted list of all station names from the GTFS data.
    def list_all_stations(data: GTFSData) -> list[str]: """Get a list of all available Caltrain stations.""" return data.stations["stop_name"].sort_values().tolist()
  • Cached function to load and provide the default GTFS data used by list_stations.
    @lru_cache(maxsize=1) def get_default_data() -> GTFSData: """Load GTFS data on first use and cache the result.""" return load_gtfs_data()

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/davidyen1124/caltrain-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server