comboios-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| CP_LOG_LEVEL | No | Log level: debug, info (default), warn or error. | |
| CP_MCP_TOKEN | No | Bearer token of at least 16 characters. Required when running the server locally in HTTP mode (e.g. CP_MCP_TOKEN="$(openssl rand -hex 24)" node dist/index.js --http --port 8787). | |
| PAY_TOKEN_KEY | No | 32 random bytes, base64. Encrypts purchase and pre-fill tokens. Required when payments are enabled. | |
| PUBLIC_BASE_URL | No | Public origin, e.g. https://comboios.example.com. Defaults to the Vercel production URL. | |
| PAYMENTS_ENABLED | No | Set to 1 to turn on the purchase page and the comprar_bilhete tool. Off by default. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Unofficial access to Comboios de Portugal (CP) data: stations, journeys with fares, live boards, train status and alerts. Dates are YYYY-MM-DD and times HH:MM in Europe/Lisbon. Station arguments accept names (fuzzy) or CP codes (94-xxxx); if a name is ambiguous the tool returns candidates, so ask the user or call procurar_estacao. Data comes from CP's website back end and may be incomplete. Answer in text by default. Use mostrar_horarios (interactive cards) only when the user wants to see and compare several trains, or to buy; when a sentence or a short list answers the question better, use horarios and reply in text. To buy, give the user the link from link_compra: they choose the train, enter their details and pay on cp.pt. This server never reserves seats or handles personal or payment data.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
| resources | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| procurar_estacaoA | Find CP stations by name (accent-insensitive, fuzzy). Returns a ranked list with CP station codes (94-xxxx) to use in other tools. |
| info_estacaoA | Details for one station: line, address, step-free access and facilities (ticket office, WC, parking, metro, ...). |
| horariosA | Search CP train journeys between two stations on a date, with times, transfers, legs and fares (EUR per passenger). Times are HH:MM local; arrives_next_day marks journeys that cross midnight; duration comes from CP. cp_url opens the same search on cp.pt. Each option has an id to pass to link_compra; copy it exactly. |
| mostrar_horariosA | Same search as horarios, but also shows the options to the user as interactive cards in the chat, each with a buy button. Use it only when the user wants to see and compare trains to pick one, or wants to buy. Do NOT use it for quick factual questions (next train, a price, a single time), for checks you make for yourself, or when you will answer in one sentence; use horarios for those. Do not call both for the same search. |
| precosB | Fares only (EUR per passenger) for each journey option, for 1st and 2nd class. Optionally restrict to one train number or one class. |
| partidas_chegadasA | Live departures or arrivals for a station, with scheduled and expected times, delay in minutes (null = no real-time data yet) and platform. Late-evening requests also include the first trains after midnight; each row carries its own date. |
| estado_comboioA | Live status of a train by number: delay, last station passed, and every stop with scheduled/expected times and platform. The date is the departure date at the train's origin (default today; just after midnight it also checks yesterday's run). |
| perturbacoesA | Current CP service alerts (strikes, works, disruptions). Expired alerts are dropped unless include_expired. Use include_body for the full text (larger response). query filters title, subtitle and body (accent-insensitive). |
| classes_e_regrasB | Travel classes, booking horizon (days ahead), passenger limits and the service codes (AP, IC, ...) CP uses. |
| link_compraA | Returns a cp.pt link that opens the search results for a journey, so the user can pick the train, enter passenger details and pay on cp.pt. Pass option_id from horarios to also say which train to select, or from/to/date. This does not reserve seats, create a sale or take any personal or payment data; the user completes the purchase on cp.pt. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
| horarios-view | Journey options with a buy button |
TDQS
Scored across 10 tools
Most tools target distinct resources or actions (station lookup vs. station details, live departures vs. train status, alerts, rules, purchase link). The main overlap is horarios and mostrar_horarios, which perform the same search with different presentation, and precos partially overlaps with horarios by returning fares. Descriptions explicitly warn not to call both search tools together, which mitigates but does not eliminate the ambiguity.
All names are consistently snake_case and in Portuguese, which keeps them readable. However, the naming convention is mixed: some tools use verb_noun (procurar_estacao, mostrar_horarios), while many are bare nouns or noun phrases (horarios, precos, perturbacoes, estado_comboio). The pattern is not fully predictable across the set.
Ten tools is well within the appropriate range for a focused train-information server. Each tool covers a meaningful capability: station discovery, journey search, fares, live status, disruptions, travel rules, and a purchase handoff. The horarios/mostrar_horarios pair is a presentation variant, but it still serves a distinct user-facing purpose.
The surface covers the full read-only travel lifecycle: find stations, inspect facilities, search journeys, compare fares, check live departures/arrivals and train status, review disruptions and travel rules, and hand off to cp.pt for purchase. No obvious operational gaps remain for the stated purpose, and the purchase handoff is intentionally scoped to avoid payment/reservation responsibilities.