sar-train-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sar-train-mcpCheapest Riyadh to Dammam train next Sunday with fares"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
sar-train-mcp
An MCP server for Saudi passenger rail (SAR) — the Haramain High-Speed Railway (HHR) and the intercity East/North lines. Ask an MCP-capable assistant for train times and fares in plain language.

It uses two backends, matched to how each network exposes its data (the same split the flagship unofficial-API tools use — scrape the open part, use a real browser for the protected part):
Backend | Network | How | Data |
HTTP | Haramain (HHR) | Public HTML timetable ( | Schedules |
Headless browser | Intercity East/North | Renders the public booking results page ( | Schedules + fares |
Why the split: HHR serves an open timetable, so a plain HTTP GET works. The intercity booking API is JWT-authed with an encrypted request/response body — rather than reverse-engineer that anti-scraping layer, we render the public results page in headless Chromium (the browser mints the token and does the crypto natively) and read what any visitor sees, including fares.
Tools
Tool | Purpose |
| Haramain stations + ids |
| Haramain schedules (Makkah⇄Madinah). No fares — HHR gates fares behind a reCAPTCHA. |
| Intercity stations + codes (East + North) |
| Intercity trains with Economy + Business fares (~5–10 s, headless browser). |
date is YYYY-MM-DD. Stations accept names, aliases, or codes/ids
("Makkah", "Jeddah", "Riyadh", "Dammam", "RYD", 5, …).
Related MCP server: YHT Bilet MCP Server
Example prompts
Once registered, ask your assistant things like:
"What Haramain trains run Makkah → Madinah on 2026-06-30, and which are direct?"
"Cheapest Riyadh → Dammam train next Sunday — and the business-class price?"
"List the SAR intercity stations."
Example output

search_intercity("Riyadh", "Dammam", "2026-07-12") — schedules with fares:
{
"from": "Riyadh", "to": "Dammam", "date": "2026-07-12",
"count": 7, "currency": "SAR", "source": "tickets.sar.com.sa",
"trains": [
{ "train": "Train 4", "departure": "05:09", "arrival": "09:19",
"from_code": "RYD", "to_code": "DMM", "duration": "4h10m",
"stops": 2, "economy_sar": 135, "business_sar": 240 },
{ "train": "Train 6", "departure": "07:13", "arrival": "11:22",
"duration": "4h09m", "stops": 2, "economy_sar": 135, "business_sar": 240 }
// … 5 more
]
}Train | Depart | Arrive | Duration | Stops | Economy | Business |
Train 4 | 05:09 | 09:19 | 4h10m | 2 | SAR 135 | SAR 240 |
Train 6 | 07:13 | 11:22 | 4h09m | 2 | SAR 135 | SAR 240 |
search_trains("Makkah", "Madinah", "2026-06-30") — Haramain schedules (no fares):
{
"from": "Makkah", "to": "Madinah", "date": "2026-06-30",
"count": 22, "source": "sar.hhr.sa/timetable",
"trains": [
{ "departure": "2026-06-30T06:00", "arrival": "2026-06-30T08:25",
"duration": "2h25m", "stops": 2,
"intermediate_stops": ["Al-Sulimaniyah (Jeddah)", "KAEC"] },
{ "departure": "2026-06-30T13:20", "arrival": "2026-06-30T15:35",
"duration": "2h15m", "stops": 0, "intermediate_stops": [] } // direct
]
}Coverage
Haramain (HHR): Makkah · Jeddah (Al-Sulimaniyah / Airport) · KAEC · Madinah — schedules ✅, fares ❌ (reCAPTCHA)
East line: Riyadh (RYD) · Abqaiq (ABQ) · Hufuf (HAF) · Dammam (DMM) — schedules ✅, fares ✅
North line: Riyadh · Majmaah · Qassim · Hail · Al-Jouf · Qurayyat — supported, but SAR currently lists no bookable service (returns
[]; populates when service resumes)
Install
Requires Python ≥ 3.10 and uv (or pip).
git clone https://github.com/RazakGhazal/sar-train-mcp.git
cd sar-train-mcp
# install the CLI/MCP entry point (+ Playwright for the intercity backend)
uv tool install . --with playwright
# one-time: download the headless Chromium used for intercity fares (~150 MB)
"$(uv tool dir)/sar-train-mcp/bin/playwright" install chromiumThen register it with your MCP client. For Claude Code:
claude mcp add sar-train -- "$(command -v sar-train-mcp)"For Claude Desktop, add to claude_desktop_config.json:
{
"mcpServers": {
"sar-train": { "command": "sar-train-mcp" }
}
}Notes & limitations
HHR TLS quirk:
sar.hhr.sanegotiates a weak DH group + legacy signature; the HTTP client uses ansslcontext atSECLEVEL=0(certificate validation stays on).Intercity needs Chromium (Playwright) and takes ~5–10 s/query vs. HHR's instant HTTP.
HHR fares are not available — SAR puts a reCAPTCHA on the Haramain fare/booking step, which this project does not attempt to bypass. HHR is schedules-only; use the official site to see HHR prices.
Scrapers are tied to the sites' current structure; if SAR redesigns, the parsers (
server.py/intercity.py) may need updating.
Development
pip install -e ".[test]"
pytest # parser fixtures + resolvers + tool registrationParser tests run against frozen real responses in tests/fixtures/. If SAR
redesigns a page, refresh the fixture and update the expected values — a failing
test is the signal that a scraper needs attention.
Disclaimer
Unofficial and not affiliated with, endorsed by, or connected to Saudi Arabia Railways (SAR), the Haramain High-Speed Railway, or the Saudi Public Transport Authority. It reads publicly available schedule/fare pages for personal, informational use, at low request volumes. It does not bypass CAPTCHAs or other access controls. Always confirm times and prices and complete bookings on the official channels (sar.com.sa, sar.hhr.sa). Provided "as is" without warranty; see LICENSE.
License
MIT © Abdulrazzak Ghazal
Available Tools
4 toolslist_intercity_stationsA
List SAR intercity stations (East + North lines) and their codes.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Simple read operation with no side effects; description covers the output (stations and codes). No annotations to contradict, but no disclosure of potential limitations or authentication needs, though minimal for this tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence, 10 words, front-loaded with verb and core resource. No redundancy or unnecessary detail.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter tool with no output schema, the description fully captures what the tool does: listing intercity stations and their codes. Complete and sufficient.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
No parameters exist, so description adds no param info; schema coverage is 100% trivially. Baseline 4 is appropriate as no additional parameter meaning is needed.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description explicitly states the verb 'list' and the resource 'SAR intercity stations' with specific lines (East + North), clearly distinguishing from sibling tools like 'list_stations'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool versus alternatives (e.g., list_stations for non-intercity stations). The description does not provide explicit usage context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_stationsA
List the Haramain High-Speed Railway (HHR) stations and their ids.
The HHR line runs Makkah <-> Jeddah (two stations) <-> KAEC <-> Madinah.
Use these names or ids with search_trains.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided; description only states it lists stations. No mention of read-only nature, data freshness, or any side effects. Lacks behavioral context beyond the obvious.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Three sentences, each serving a purpose: purpose statement, route context, and usage guidance. No extraneous text.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter list tool without output schema, description is adequate. Explains what is returned and how to use it. Missing output format details, but not critical.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
No parameters, but description adds value by explaining output (station names, ids) and providing route context. Baseline 4 due to zero params.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it lists HHR stations and their ids, and differentiates from sibling tools like list_intercity_stations by specifying the HHR line. The route details add specificity.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly says to use names/ids with search_trains, providing a clear use case. Does not explicitly state when not to use, but sibling tools imply different scopes.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_intercityA
Search SAR intercity trains (East + North lines) WITH fares on a date.
Covers the non-Haramain network: the East line (Riyadh <-> Abqaiq, Hofuf,
Dammam) and the North line (Riyadh <-> Majmaah, Qassim, Hail, Al-Jouf,
Qurayyat). Use this instead of search_trains for any route NOT on the
Makkah-Madinah Haramain line.
Args: from_station: Origin name or code (e.g. "Riyadh", "RYD", "Dammam"). to_station: Destination name or code (e.g. "Dammam", "DMM", "Hofuf"). date: Travel date, ISO format YYYY-MM-DD.
Returns each train with departure/arrival time, duration, stops, and Economy + Business fares in SAR. Rendered from the public booking results page via a headless browser (~5-10s). An empty list means SAR is not selling that route on that date (the North line currently shows no bookable service; the East line runs daily).
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | ||
| to_station | Yes | ||
| from_station | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, but description discloses return contents (times, duration, stops, fares), rendering method (headless browser, ~5-10s latency), and behavior for empty lists. No mention of auth or rate limits, but acceptable for a search tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two well-structured paragraphs. First paragraph states purpose and scope, second lists parameters and return values. No redundant sentences; each sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
No output schema, but description explains return fields (departure/arrival time, duration, stops, Economy + Business fares in SAR) and edge cases like empty list meaning. Complete for a search tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema has 0% description coverage, but the description adds examples and format for each parameter: 'Origin name or code (e.g. "Riyadh", "RYD", "Dammam")' and 'ISO format YYYY-MM-DD'. This compensates well.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Search SAR intercity trains (East + North lines) WITH fares on a date.' It specifies the exact routes covered and distinguishes from the sibling tool 'search_trains' which is for the Haramain line.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly says 'Use this instead of search_trains for any route NOT on the Makkah-Madinah Haramain line.' Also explains when to expect empty results (e.g., North line currently no bookable service).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_trainsA
Search Haramain (HHR) train schedules between two stations on a date.
Args: from_station: Origin station name or id (e.g. "Makkah", "Jeddah", 1). Plain "Jeddah" resolves to Al-Sulimaniyah; use "Jeddah Airport" for KAIA. to_station: Destination station name or id (e.g. "Madinah", 5). date: Travel date in ISO format YYYY-MM-DD (e.g. "2026-06-30").
Returns a list of trains with departure/arrival datetimes, duration, number of stops, and the intermediate stations. Fares are not included (HHR does not expose pricing on the public timetable).
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | ||
| to_station | Yes | ||
| from_station | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It does not explicitly state that the tool is read-only or disclose any side effects, auth needs, or rate limits. It does mention a limitation (no fares), but overall behavioral detail is minimal.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and well-structured: a one-sentence summary followed by a clear Args list. Every sentence adds value, with no redundant or filler content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite no output schema, the description details the return value (list of trains with departure/arrival datetimes, duration, stops, intermediate stations) and notes the absence of fares. This covers the essential information for an agent to use the tool effectively.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description compensates fully by explaining each parameter: from_station (with resolution rules), to_station (with example), and date (with format example). This adds significant meaning beyond the schema's minimal type/title.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Search Haramain (HHR) train schedules between two stations on a date.' It uses a specific verb ('Search') and resource ('HHR train schedules'), and the mention of 'Haramain' distinguishes it from siblings like 'search_intercity' and 'list_stations'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides operational details, such as how station names are resolved (e.g., 'Jeddah' vs 'Jeddah Airport'), and notes that fares are not included. While it does not explicitly state when not to use this tool or name alternatives, the specificity of the domain implies its appropriate context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.2.1- First observed
list_intercity_stations - First observed
list_stations - First observed
search_intercity - First observed
search_trains
TDQS
Scored across 4 tools
Each tool targets a distinct network and operation: two list stations (intercity vs HHR) and two search trains (intercity with fares vs HHR without fares). No overlap or ambiguity.
The naming pattern is mixed: 'list_intercity_stations' vs 'list_stations' and 'search_intercity' vs 'search_trains' use different qualifiers and resource names. While readable, the inconsistency could confuse an agent.
Four tools cover the core needs for two railway networks: station listings and train searches. No excessive or missing tools for the stated purpose.
The tool set covers listing stations and searching schedules for both networks. The only notable gap is HHR fares, but this is a data-source limitation, not an oversight. No dead ends.
Maintenance
Related MCP Connectors
Indian Railways IRCTC helps you to view, track trains schedules, ticket status and more.
TravelMind: 8 MCP tools for travel (12306 trains, flights, hotels, geocode, planning, policy).
The Ferryhopper MCP server is a connector for LLMs and AI Agents in maritime travel that exposes ferry routes, schedules, and booking options. It enables AI assistants to search ports and connections across 33 countries and 190+ ferry operators, provide real-time ferry itineraries with indicative prices, and assist users with planning island-hopping or multi-leg journeys by processing natural language queries about ferry times, passenger counts, and travel durations.
Provide real-time transportation data including bus arrivals, train service alerts, carpark availa…
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables real-time Indian Railways information retrieval, including live train running status, station schedules, and upcoming arrivals/departures.-
- AlicenseNot gradedqualityDmaintenanceEnables searching Turkish high-speed train (YHT) tickets via TCDD API. Supports real-time availability, station name resolution, date formatting, and passenger count.MIT
- FlicenseNot gradedqualityDmaintenanceEnables checking railway seat availability, berth types, and pricing for Indian trains through natural language queries.-
- FlicenseNot gradedqualityDmaintenanceEnables real-time flight and train ticket queries, dynamic trip tracking, and knowledge-based Q&A about rail and aviation policies.-