Skip to main content
Glama
mirodn

mcp-server-public-transport

no_trip

Plan door-to-door public transport trips between two European locations using NSR IDs. Get route options with departure times and results customization.

Instructions

Door-to-door trip planning between two StopPlaces (NSR IDs).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_idYes
to_idYes
date_timeNo
resultsNo

Implementation Reference

  • The main asynchronous handler function for the 'no_trip' tool. It validates inputs, constructs a GraphQL query for Entur's Journey Planner, and fetches trip patterns between from_id and to_id stop places.
    async def no_trip(from_id: str, to_id: str, date_time: str | None = None, results: int | None = 5) -> dict[str, object]:
        """
        Args:
            from_id: NSR ID for origin (e.g., 'NSR:StopPlace:58368').
            to_id: NSR ID for destination.
            date_time: ISO 8601 datetime (e.g., '2025-08-23T12:00:00+02:00'). Optional.
            results: Number of trip patterns. Default: 5.
        Returns:
            GraphQL `data` with trip -> tripPatterns -> legs.
        """
        if not from_id or not to_id:
            raise ValueError("'from_id' and 'to_id' are required.")
    
        query = """
        query PlanTrip($from: String!, $to: String!, $results: Int!, $dateTime: DateTime) {
          trip(
            from: { place: $from }
            to:   { place: $to }
            numTripPatterns: $results
            dateTime: $dateTime
          ) {
            tripPatterns {
              duration
              walkDistance
              legs {
                mode
                distance
                aimedStartTime
                expectedStartTime
                aimedEndTime
                expectedEndTime
                fromPlace { name }
                toPlace { name }
                line { id name publicCode transportMode }
              }
            }
          }
        }
        """
        variables = {
            "from": from_id.strip(),
            "to": to_id.strip(),
            "results": int(results or 5),
            "dateTime": date_time,  # may be None
        }
        logger.info(
            "🇳🇴 Entur trip: %s -> %s (results=%s, dateTime=%s)",
            variables["from"], variables["to"], variables["results"], variables["dateTime"]
        )
        return await _post_graphql(query, variables)
  • tools/no.py:215-218 (registration)
    MCP tool registration decorator specifically for 'no_trip', including name and description.
    @mcp.tool(
        name="no_trip",
        description="Door-to-door trip planning between two StopPlaces (NSR IDs)."
    )
  • Docstring within the handler defining input parameters (from_id, to_id, date_time, results) and output (GraphQL data with tripPatterns).
    """
    Args:
        from_id: NSR ID for origin (e.g., 'NSR:StopPlace:58368').
        to_id: NSR ID for destination.
        date_time: ISO 8601 datetime (e.g., '2025-08-23T12:00:00+02:00'). Optional.
        results: Number of trip patterns. Default: 5.
    Returns:
        GraphQL `data` with trip -> tripPatterns -> legs.
    """
  • Module docstring listing the function signature and defaults for no_trip.
    - no_trip(from_id, to_id, date_time=None, results=5)
  • tools/no.py:316-316 (registration)
    Includes 'no_trip' in the list of registered tool names returned by register_no_tools.
    return ["no_search_places", "no_stop_departures", "no_trip", "no_nearest_stops"]

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/mirodn/mcp-server-public-transport'

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