Skip to main content
Glama

get_train_positions

Read-onlyIdempotent

Retrieve live GPS positions for Swedish trains by train number or within a radius, including coordinates, speed, direction, and report age; filter results to recent positions only.

Instructions

Get live GPS positions of Swedish trains: coordinates, speed (km/h), direction of travel (degrees) and when the position was reported. Locate one train by its train number, list trains within a radius of a point (latitude, longitude, radiusKm), or both. Only positions reported within the last maxAgeMinutes are returned. Use get_train_announcements for timetable and delay data at a station. fetchedAt is when this server got the response from Trafikverket; the result does not refresh afterwards, so call the tool again if fetchedAt is old. ageMinutes is each position's age at fetchedAt. Returns an error result (isError: true) if TRAFIKVERKET_API_KEY is missing/invalid or the Trafikverket API is unreachable. Coverage: Sweden only (Trafikverket data).

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "get_train_positions"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum number of trains to return (1-100)
latitudeNoLatitude of the centre of a radius search (requires longitude)
radiusKmNoSearch radius in kilometres (0.5-100, default 10)
longitudeNoLongitude of the centre of a radius search (requires latitude)
trainNumberNoTrain number to locate, e.g. "421" (matched against both the advertised and the operational train number)
maxAgeMinutesNoIgnore positions reported longer ago than this many minutes (1-60, default 10)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.1

TDQS

A4.7/5.0
Behavior4/5

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

Annotations cover the safety profile (readOnly, idempotent, non-destructive, open-world), and the description still adds real behavioral context: results are a snapshot where fetchedAt never refreshes and the caller must re-invoke, ageMinutes is measured relative to fetchedAt, and failures surface as isError:true when TRAFIKVERKET_API_KEY is missing/invalid or the upstream API is unreachable. Geographic coverage (Sweden only) is also disclosed. It stops short of stating rate limits or result-cap behaviour, which keeps it off a 5.

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?

Front-loads the purpose and the returned fields, then usage modes, then liveness caveat, then error conditions, then coverage. Every sentence carries a distinct fact; nothing is padding despite the length.

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

Completeness5/5

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

There is no output schema, so the description carries the return-value burden and does it: it names the position fields, the fetchedAt snapshot semantics, the per-position ageMinutes, and the isError failure mode. Combined with a fully documented 6-parameter schema, an agent has everything needed to call this and interpret the result.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3; the description earns above baseline by explaining how the optional parameters compose into modes (trainNumber alone, lat/long/radiusKm as a radius search, or both) and by tying maxAgeMinutes to a concrete filter rather than restating the range. It repeats some schema text (train number matching, the radius triple) rather than adding new meaning, so it is not a 5.

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

Purpose5/5

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

Opens with a specific verb and resource ('Get live GPS positions of Swedish trains') and enumerates exactly what is returned (coordinates, speed km/h, direction degrees, report time). It also carves out its own two access modes and names the sibling tool it is not (get_train_announcements), so an agent can distinguish it without opening a schema.

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

Usage Guidelines5/5

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

States the three invocation patterns explicitly ('locate one train by its train number, list trains within a radius of a point ... or both') and gives a clear exclusion with an alternative: use get_train_announcements for timetable and delay data at a station. The maxAgeMinutes sentence adds a second usage constraint on what data is actionable.

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