Skip to main content
Glama
mirodn

mcp-server-public-transport

no_stop_departures

Get upcoming public transport departures for a specific stop in Europe. Enter a StopPlace ID to view scheduled departures and plan your journey.

Instructions

Upcoming departures for a StopPlace ID (e.g., 'NSR:StopPlace:58368').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stop_place_idYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The async handler function that executes the no_stop_departures tool logic, querying the Entur GraphQL API for upcoming departures from a stop place.
    async def no_stop_departures(stop_place_id: str, limit: int | None = 10) -> dict[str, object]:
        """
        Args:
            stop_place_id: NSR StopPlace ID string.
            limit: Number of departures to fetch. Default: 10.
        Returns:
            GraphQL `data` with stopPlace + estimatedCalls.
        """
        if not stop_place_id or not stop_place_id.strip():
            raise ValueError("Parameter 'stop_place_id' must not be empty.")
    
        query = """
        query StopDepartures($id: String!, $limit: Int!) {
          stopPlace(id: $id) {
            id
            name
            estimatedCalls(numberOfDepartures: $limit) {
              realtime
              aimedDepartureTime
              expectedDepartureTime
              destinationDisplay { frontText }
              quay { id name }
              serviceJourney {
                id
                line { id name publicCode transportMode }
              }
            }
          }
        }
        """
        variables = {"id": stop_place_id.strip(), "limit": int(limit or 10)}
        logger.info("Entur stop departures: %s (limit=%s)", variables["id"], variables["limit"])
        return await _post_graphql(query, variables)
  • tools/no.py:177-180 (registration)
    The @mcp.tool decorator that registers the no_stop_departures tool with the MCP server.
    @mcp.tool(
        name="no_stop_departures",
        description="Upcoming departures for a StopPlace ID (e.g., 'NSR:StopPlace:58368')."
    )
  • Function signature and docstring defining input parameters and output type for the tool.
    async def no_stop_departures(stop_place_id: str, limit: int | None = 10) -> dict[str, object]:
        """
        Args:
            stop_place_id: NSR StopPlace ID string.
            limit: Number of departures to fetch. Default: 10.
        Returns:
            GraphQL `data` with stopPlace + estimatedCalls.
        """
  • Helper function used by no_stop_departures to POST GraphQL queries to Entur API with retries.
    async def _post_graphql(
        query: str,
        variables: dict[str, object] | None = None,
        timeout: int = DEFAULT_TOTAL_TIMEOUT,
        tries: int = 3,
    ) -> dict[str, object]:
        """POST a GraphQL query to Entur Journey Planner v3 and return the `data` field."""
        payload = {"query": query, "variables": variables or {}}
    
        for attempt in range(1, tries + 1):
            try:
                async with aiohttp.ClientSession(headers=COMMON_HEADERS, timeout=_make_timeout(timeout)) as session:
                    async with session.post(NO_JP_BASE_URL, json=payload, timeout=_make_timeout(timeout)) as resp:
                        # Retry on rate limit or server errors
                        if resp.status == 429 or resp.status >= 500:
                            text = await resp.text()
                            if attempt < tries:
                                await asyncio.sleep(0.5 * (2 ** (attempt - 1)))
                                continue
                            raise TransportAPIError(f"Entur GraphQL HTTP {resp.status}: {text}")
    
                        if resp.status >= 400:
                            text = await resp.text()
                            raise TransportAPIError(f"Entur GraphQL HTTP {resp.status}: {text}")
    
                        data = await resp.json()
                        if "errors" in data and data["errors"]:
                            raise TransportAPIError(f"Entur GraphQL errors: {data['errors']}")
                        return data.get("data", {})
            except (asyncio.TimeoutError, aiohttp.ServerTimeoutError) as e:
                if attempt < tries:
                    await asyncio.sleep(0.5 * (2 ** (attempt - 1)))
                    continue
                raise TransportAPIError(f"Entur GraphQL timeout after {tries} attempt(s): {e}") from e
    
        # Should never reach here
        raise TransportAPIError("Entur GraphQL: exhausted retries without response")
  • tools/no.py:316-316 (registration)
    List of registered Norway tools returned by register_no_tools, including no_stop_departures.
    return ["no_search_places", "no_stop_departures", "no_trip", "no_nearest_stops"]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While it implies a read-only operation (retrieving departures), it doesn't mention any constraints like rate limits, authentication requirements, time windows, or what happens when no departures exist. The example ID format is helpful but insufficient for full behavioral understanding.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence that communicates the core purpose efficiently. It's front-loaded with the main functionality and includes a helpful example without unnecessary elaboration. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which reduces the need to describe return values) but no annotations, the description is minimally adequate. It covers the basic purpose and provides an example ID format, but doesn't address the tool's relationship to similar sibling tools or provide behavioral context that would be important for an AI agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description provides minimal parameter information. It mentions the StopPlace ID parameter and provides an example format, which adds some value beyond the bare schema. However, it doesn't explain the 'limit' parameter at all, leaving half the parameters undocumented. The baseline would be lower without the example format.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: retrieving upcoming departures for a specific StopPlace ID. It provides a specific verb ('Upcoming departures') and resource ('StopPlace ID'), but doesn't explicitly differentiate from sibling tools like 'be_get_departures' or 'ch_get_departures' that might serve similar functions in different contexts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With multiple departure-related sibling tools (be_get_departures, ch_get_departures, uk_live_departures), there's no indication of what distinguishes this tool's scope, region, or use case from those alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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