rmv
# rmv
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/udondan/rmv/main/docs/banner-dark.webp">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/udondan/rmv/main/docs/banner-light.webp">
<img alt="rmv – Rhein-Main transit, in your terminal. CLI + MCP." src="https://raw.githubusercontent.com/udondan/rmv/main/docs/banner-light.webp">
</picture>
[](https://github.com/udondan/rmv/releases/latest)
[](https://crates.io/crates/rmv)
[](https://hub.docker.com/r/udondan/rmv)
[](https://glama.ai/mcp/servers/udondan/rmv)
[](https://github.com/udondan/rmv/actions/workflows/test.yml)
[](https://codecov.io/gh/udondan/rmv)
[](https://qlty.sh/gh/udondan/projects/rmv)
[](https://github.com/udondan/rmv/blob/main/LICENSE)
CLI and MCP server for public transport departures and connections in the
Rhein-Main-Verkehrsverbund (RMV), on the
[RMV OpenData API](https://www.rmv.de/s/de/rmv-open-data) (HAFAS ReST).
It is built for callers that check fixed daily trips, like a script or an
agent asking in the morning whether the usual train still runs. For each
connection it reports scheduled and actual times, delays, cancellations and
RMV's disruption messages, and sums them up in one status:
| Status | Meaning |
| --- | --- |
| `ok` | As planned, as far as the realtime data tells |
| `delayed` | The arrival is late, or the departure is off its schedule |
| `cancelled` | A ride, or boarding or alighting at a stop of it, is cancelled |
| `unreachable` | A transfer can no longer be made, or the first ride has left |
| `no_realtime` | No realtime data: the times are the timetable |
A cancelled connection stays in the result, marked as cancelled, instead of
silently dropping out. `reasons` says why, like
`{"kind": "transfer_missed", "leg": 2, "margin_minutes": -3}`.
[docs/status.md](https://github.com/udondan/rmv/blob/main/docs/status.md)
explains the rules.
## Contents
- [Installation](#installation)
- [Access key](#access-key)
- [Usage](#usage)
- [MCP server](#mcp-server)
- [Configuration](#configuration)
- [Requests and quota](#requests-and-quota)
- [Merging with other sources](#merging-with-other-sources)
- [Crates](#crates)
- [Data and terms](#data-and-terms)
## Installation
```sh
brew install udondan/software/rmv # macOS and Linux
cargo install rmv # from source
docker pull udondan/rmv # see Docker below
```
The [releases](https://github.com/udondan/rmv/releases) also have binaries
for Linux (x86_64, aarch64, static), macOS and Windows, each with the shell
completion scripts. `SHA256SUMS.txt` lists their checksums and is signed with
the GPG key `F111A9BDD62F384A`:
```sh
gpg --verify SHA256SUMS.txt.asc SHA256SUMS.txt
sha256sum --check --ignore-missing SHA256SUMS.txt
```
The Docker image is signed with cosign by the release workflow:
```sh
cosign verify udondan/rmv \
--certificate-identity-regexp '^https://github.com/udondan/rmv/' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
```
## Access key
Every request to the RMV API needs an access key of your own. No key comes
with `rmv`, its image or its releases: the
[terms of use](https://www.rmv.de/s/de/rmv-open-data/nutzungsbedingung)
make it personal and confidential, and forbid passing it on.
1. Request one on the [RMV OpenData page](https://www.rmv.de/s/de/rmv-open-data).
2. Set it once. `-` reads it from standard input, so it stays out of the
shell history:
```sh
rmv config set access_id -
```
`RMV_ACCESS_ID` sets it for a single run instead.
Without a key, `rmv` sends no request at all and answers
`access_id_missing`. A key the API rejects gives `access_denied`. RMV deletes
keys that have not been used for more than 180 days.
The key is a query parameter of every request, so every URL contains it.
`rmv` never prints it: not in output, errors or logs, even with `-vv`.
Shell completion, loaded when the shell starts (bash shown; `zsh`, `fish`,
`elvish` and `powershell` work the same way):
```sh
source <(rmv completion bash)
```
## Usage
```console
$ rmv stops Hauptwache
Frankfurt (Main) Hauptwache
3000001
Daten: Rhein-Main-Verkehrsverbund (RMV), https://www.rmv.de/s/de/rmv-open-data
$ rmv departures 3000010 --count 3
Departures at Frankfurt (Main) Hauptbahnhof tief
08:40 +15 S2 → Dietzenbach Bahnhof track 102
! S1, S2: Halt entfällt und Teilausfälle bis 13.12.
08:44 12 → Frankfurt (Main) Rheinlandstraße
08:44 +2 S8 → Offenbach (Main)-Offenbach Ost Ostbahnhof track 102
Daten: Rhein-Main-Verkehrsverbund (RMV), https://www.rmv.de/s/de/rmv-open-data
$ rmv trip 3000010 3000001 --count 2
Frankfurt (Main) Hauptbahnhof tief → Frankfurt (Main) Hauptwache
1. 08:44 +2 → 08:47 +1 2 min, 0 transfers delayed
S8 → Offenbach (Main)-Offenbach Ost Ostbahnhof
08:44 +2 Frankfurt (Main) Hauptbahnhof tief track 102
08:47 +1 Frankfurt (Main) Hauptwache track 2
2. 08:47 → 08:50 3 min, 0 transfers ok
S6 → Darmstadt Hauptbahnhof
08:47 Frankfurt (Main) Hauptbahnhof tief track 101
08:50 Frankfurt (Main) Hauptwache track 2
Daten: Rhein-Main-Verkehrsverbund (RMV), https://www.rmv.de/s/de/rmv-open-data
```
| Command | Does |
| --- | --- |
| `stops <name> [--near LAT,LON] [--count N]` | Finds stops by name, with their IDs (up to 20) |
| `departures <stop> [--time T] [--count N] [--arrivals] [--modes M]` | The next departures or arrivals at a stop (up to 100) |
| `trip <from> <to> [--arrive T \| --depart T] [--count N] [--modes M] [--max-transfers N] [--realtime-routing]` | Connections, each with its status (up to 6) |
| `journey <trip-id>` | A trip with all its stops, by its ID from `departures` or `trip` |
| `recheck <token>` | A connection again, with current data, by its `recheck_token` from `trip` |
| `config show\|path\|get\|set\|unset` | The configuration file |
| `mcp [--http [ADDR]]` | The MCP server |
| `completion <shell>` | The completion script |
- **Stops** are given by ID, like `3000010` or `A=1@L=3000010@`, or by a
name that fits exactly one stop. A name that fits several gives
`ambiguous_stop` with the candidates and their IDs, never a guess. `trip`
also takes coordinates `LAT,LON`.
- **Times** are `HH:MM` (always today, in Europe/Berlin, never rolled over
to tomorrow), a local time like `2026-11-27T07:50`, or RFC 3339.
- **`trip --arrive 07:50`** returns the connections arriving last before
07:50, together with earlier ones to switch to.
- **`recheck`** asks RMV for exactly the connection you picked, with the
current delays and cancellations. That is the cheapest way to poll a fixed
trip: one request, no stop lookups.
- **Pages**: results have a `page_cursor` with `earlier` and `later` (for
departures only `later`); pass one with `--page-cursor`.
### Modes
`--modes` takes a comma-separated list of these names, in any case. They
stand for product classes of RMV:
| Mode | RMV products | Class |
| --- | --- | --- |
| `HIGHSPEED_RAIL` | ICE | 1 |
| `LONG_DISTANCE` | IC, ECE, NJ | 2 |
| `REGIONAL_RAIL` | RE, RB | 4 |
| `SUBURBAN` | S-Bahn | 8 |
| `SUBWAY` | U-Bahn | 16 |
| `TRAM` | Tram | 32 |
| `BUS` | Regional and city buses | 64, 128 |
| `ODM` | On-demand services (AST, ALT) | 512 |
| `RAIL` | All trains: the first four | 1, 2, 4, 8 |
Results name the mode of each ride the same way, and `OTHER` for a class not
listed.
### Output
`-o text|json|yaml` chooses the format. JSON is the default when stdout is
not a terminal, so scripts get JSON without asking. Errors are printed in the
same format on stderr, with a stable `status`, and the exit code is 1 (2 for
invalid arguments):
| `status` | Meaning |
| --- | --- |
| `access_id_missing` | No access key configured; nothing was sent |
| `access_denied` | RMV rejected the access key |
| `config_error` | The configuration file or a setting is invalid |
| `invalid_input` | (MCP) A time, mode or place could not be read; the CLI reports these as usage errors |
| `ambiguous_stop` | The name fits several stops; see `candidates` |
| `stop_not_found` | No stop has that name |
| `not_found` | RMV does not know the stop or trip ID |
| `rate_limited` | The quota of the key is used up, or too many requests came at once; see `retry_after_seconds` |
| `timeout`, `unavailable`, `bad_request`, `upstream_error` | RMV did not answer, or refused |
Text output always ends with the attribution of the data, which must be
kept. JSON has it as `attribution`.
Besides the fields of each result, stops and stop events have `dhid`, the
German stop ID like `de:06412:10`, and results have `realtime_as_of`, when
RMV last updated its realtime data.
## MCP server
`rmv mcp` serves five read-only tools to an MCP client on stdin and stdout.
Each has an output schema and returns a one-line summary followed by the
same JSON as the CLI.
| Tool | Returns |
| --- | --- |
| `rmv_find_stop` | Stops by name, with their IDs |
| `rmv_departures` | The next departures or arrivals at a stop |
| `rmv_trip` | Connections between two places, each with its status and reasons |
| `rmv_journey` | A trip with all its stops |
| `rmv_recheck` | A connection from `rmv_trip` again, with current data |
For example, in Claude Code:
```sh
claude mcp add rmv -e RMV_ACCESS_ID=<your key> -- rmv mcp
```
Or in the configuration of another client:
```json
{
"mcpServers": {
"rmv": {
"command": "rmv",
"args": ["mcp"],
"env": { "RMV_ACCESS_ID": "<your key>" }
}
}
}
```
With the key in the configuration file (`rmv config set access_id -`), the
`env` entry is not needed.
The server tells the model that stop names and disruption texts from the API
are data, not instructions, and that every call costs requests of the quota.
Agents that use the CLI instead can load the skill in
[skills/rmv/SKILL.md](https://github.com/udondan/rmv/blob/main/skills/rmv/SKILL.md).
### HTTP
`rmv mcp --http` serves streamable HTTP at `http://127.0.0.1:8080/mcp`;
`--http 0.0.0.0:9000` takes another address. It needs a bearer token of at
least 16 characters in `RMV_MCP_TOKEN`, which every request must send as
`Authorization: Bearer <token>`:
```sh
export RMV_MCP_TOKEN=$(openssl rand -hex 32)
rmv mcp --http
claude mcp add --transport http rmv http://127.0.0.1:8080/mcp \
--header "Authorization: Bearer $RMV_MCP_TOKEN"
```
The server shuts down cleanly on SIGINT and SIGTERM. It serves plain HTTP;
put a TLS proxy in front of it to reach it over a network. It is for your own
clients only: the terms of use forbid giving others access through your key.
### Docker
The image runs `rmv`; without a command it starts the MCP server on stdio.
It holds no key and no state, so it needs no volume:
```sh
docker run --rm -i -e RMV_ACCESS_ID udondan/rmv
docker run --rm -e RMV_ACCESS_ID udondan/rmv departures 3000010
```
`mise run docker-build` builds the image from source. For the Docker MCP
Toolkit, `mise run docker` builds it and adds
[docker-mcp.yml](https://github.com/udondan/rmv/blob/main/docker-mcp.yml) to
a profile. Set the secret `rmv.access_id` with `docker mcp secret set`.
The server is also in the
[MCP Registry](https://registry.modelcontextprotocol.io) as
`io.github.udondan/rmv`.
## Configuration
`rmv config path` shows the file, by default `~/.config/rmv/config.toml`
(`%APPDATA%` on Windows). `rmv config show` shows the settings in effect,
with the key masked.
| Setting | Default | Meaning |
| --- | --- | --- |
| `access_id` | – | Your access key |
| `base_url` | `https://www.rmv.de/hapi/` | Another HAFAS ReST server |
| `timeout_seconds` | 20 | How long a command may take, retries and waits included |
| `retries` | 2 | Retries after a transient error, at most 5; `0` turns them off |
| `delay_threshold_minutes` | 2 | From how many minutes late an arrival counts as `delayed` |
| Variable | Does |
| --- | --- |
| `RMV_ACCESS_ID` | Overrides `access_id` |
| `RMV_BASE_URL` | Overrides `base_url` |
| `RMV_CONFIG` | Another configuration file |
| `RMV_OUTPUT` | The output format, like `-o` |
| `RMV_LOG`, `RMV_LOG_FILE` | Log level, like `debug` or `hafas=debug`, and a log file |
| `RMV_MCP_TOKEN` | The bearer token of `mcp --http` |
| `RMV_NOW` | Evaluate the status as if it were another time, as RFC 3339 like `2026-11-27T07:50:00+01:00`; `HH:MM` times then count from that day |
`https://www.rmv.de/hapi/latest/` runs the next version of the API (2.52),
which RMV offers for testing. `rmv` works with both versions, but use
`latest/` only to try it out.
## Requests and quota
An access key may make **600 requests per hour and 5000 per day**, shared by
everything that uses it. `rmv` has no cache and no counter: it cannot see
what else uses your key, so keeping within the quota is up to you. When RMV
reports the quota as used up, the answer is `rate_limited`.
What a command costs:
- one request for the search itself;
- one more for every stop given by name instead of ID (`trip` with two names
makes three). IDs and `LAT,LON` cost nothing extra;
- `trip --arrive`: one more for an earlier page when the first has too few
connections;
- after a connection error, a timeout or a 500, 502, 503 or 504, up to
`retries` more (2 by default), with waits of about 0.5 and 1 second, all
within `timeout_seconds`. Errors that RMV reports with a code, like an
invalid key, the used up quota or wrong parameters, are never retried.
Set `retries = 0` to make every command cost exactly what is listed above.
Polling one connection every 5 minutes for an hour with `recheck` costs 12
requests. Never run `rmv` in a loop without a pause: the terms of use forbid
crawling and bulk downloads.
## Merging with other sources
RMV knows cancellations and disruption messages in its area that wider
sources often lack, while other sources cover more area. The output uses
plain, documented field names so that it can be merged with data from other
journey planners;
[docs/merging.md](https://github.com/udondan/rmv/blob/main/docs/merging.md)
lists the join keys. How RMV reports realtime data is described in
[docs/realtime-findings.md](https://github.com/udondan/rmv/blob/main/docs/realtime-findings.md).
## Crates
| Crate | crates.io | docs.rs | Purpose |
| --- | --- | --- | --- |
| [`hafas`](https://github.com/udondan/rmv/tree/main/crates/hafas) | [![hafas on crates.io][hafas-crate-badge]][hafas-crate] | [![hafas on docs.rs][hafas-docs-badge]][hafas-docs] | Neutral client for the HAFAS ReST API, versions 2.39 and 2.52 |
| [`rmv-core`](https://github.com/udondan/rmv/tree/main/crates/rmv-core) | [![rmv-core on crates.io][rmv-core-crate-badge]][rmv-core-crate] | [![rmv-core on docs.rs][rmv-core-docs-badge]][rmv-core-docs] | Configuration, access key, retries, stop resolution, status and the output model |
| [`hafas-sim`](https://github.com/udondan/rmv/tree/main/crates/hafas-sim) | [![hafas-sim on crates.io][hafas-sim-crate-badge]][hafas-sim-crate] | [![hafas-sim on docs.rs][hafas-sim-docs-badge]][hafas-sim-docs] | Fake HAFAS server for tests |
| [`rmv`](https://github.com/udondan/rmv/tree/main/crates/rmv) | [![rmv on crates.io][rmv-crate-badge]][rmv-crate] | – | The binary: CLI and `rmv mcp` |
[hafas-crate-badge]: https://img.shields.io/crates/v/hafas?label=
[hafas-crate]: https://crates.io/crates/hafas
[hafas-docs-badge]: https://img.shields.io/docsrs/hafas?label=
[hafas-docs]: https://docs.rs/hafas
[hafas-sim-crate-badge]: https://img.shields.io/crates/v/hafas-sim?label=
[hafas-sim-crate]: https://crates.io/crates/hafas-sim
[hafas-sim-docs-badge]: https://img.shields.io/docsrs/hafas-sim?label=
[hafas-sim-docs]: https://docs.rs/hafas-sim
[rmv-core-crate-badge]: https://img.shields.io/crates/v/rmv-core?label=
[rmv-core-crate]: https://crates.io/crates/rmv-core
[rmv-core-docs-badge]: https://img.shields.io/docsrs/rmv-core?label=
[rmv-core-docs]: https://docs.rs/rmv-core
[rmv-crate-badge]: https://img.shields.io/crates/v/rmv?label=
[rmv-crate]: https://crates.io/crates/rmv
## Data and terms
Daten: Rhein-Main-Verkehrsverbund (RMV), from the
[RMV OpenData API](https://www.rmv.de/s/de/rmv-open-data), under the
[RMV terms of use](https://www.rmv.de/s/de/rmv-open-data/nutzungsbedingung).
They allow the results for passenger information, for the user who asked,
and forbid storing or publishing a substantial part of them. RMV can change
or end the API at any time.
This project is not affiliated with RMV.
## Security and contributing
See [SECURITY.md](https://github.com/udondan/rmv/blob/main/SECURITY.md) and
[CONTRIBUTING.md](https://github.com/udondan/rmv/blob/main/CONTRIBUTING.md).
## License
[Apache-2.0](https://github.com/udondan/rmv/blob/main/LICENSE). The license
covers the code, not the data.
TDQS
Scored across 5 tools
Each tool targets a distinct question: departures at one stop, stop lookup, a single ride's route, A-to-B connection search, and rechecking an existing connection. The descriptions explicitly cross-reference each other (e.g. 'to get from A to B use rmv_trip, for all stops of one ride rmv_journey'), making boundaries unambiguous.
All tools share the rmv_ prefix and snake_case, which is predictable. The only minor deviation is mixing noun-style names (rmv_departures, rmv_journey, rmv_trip) with verb-style ones (rmv_find_stop, rmv_recheck), but this remains readable and intuitive.
Five tools is a tight, well-scoped set for a transit API, with each tool earning its place and no redundant entries. Nothing feels thin or bloated.
The surface covers the core lifecycle: find stop, plan trip, inspect ride, watch departures, and recheck a connection. Minor gaps exist (no dedicated alerts/disruption or operator/line lookup tool), but agents can work around these via the alert data embedded in other responses.