# sbb-mcp

Swiss Federal Railways (SBB/CFF/FFS) MCP server — real-time train schedules, ticket prices with Half-Fare/GA support, and direct purchase links. Built on official SBB SMAPI.

## Quick Start

```bash
# Connect this server (installs CLI if needed)
npx -y @smithery/cli@latest mcp add fabsforward2-zhoi/sbb-mcp

# Browse available tools
npx -y @smithery/cli@latest tool list fabsforward2-zhoi/sbb-mcp

# Get full schema for a tool
npx -y @smithery/cli@latest tool get fabsforward2-zhoi/sbb-mcp search_stations

# Call a tool
npx -y @smithery/cli@latest tool call fabsforward2-zhoi/sbb-mcp search_stations '{}'
```

## Direct MCP Connection

Endpoint: `https://sbb-mcp--fabsforward2-zhoi.run.tools`

**Optional config:**
- `SMAPI_CLIENT_ID` (query) — OAuth 2.0 client ID from SBB Developer Portal (optional - runs in mock mode without)
- `SMAPI_CLIENT_SECRET` (query) — OAuth 2.0 client secret
- `SMAPI_SCOPE` (query) — OAuth scope from SBB Developer Portal
- `SMAPI_CONTRACT_ID` (query) — Business contract identifier

## Tools (6)

- `search_stations` — Search for Swiss train stations, addresses, or points of interest by name. Returns station IDs needed for other tools.
- `search_connections` — Find train connections between two Swiss stations. Returns schedules with departure/arrival times, duration, transfers,…
- `get_trip_details` — Get detailed information about a specific train connection including all intermediate stops, platforms, and occupancy. …
- `get_more_connections` — Load earlier or later train connections for a previous search. Use the collection ID from search_connections results.
- `get_prices` — Get ticket prices for one or more train connections. Supports Half-Fare card (Halbtax) and GA travelcard discounts.
- `get_ticket_link` — Get a direct purchase link to buy a train ticket on SBB.ch. Only call this when the user wants to buy a specific ticket.

```bash
# Get full input/output schema for a tool
npx -y @smithery/cli@latest tool get fabsforward2-zhoi/sbb-mcp <tool-name>
```

## Prompts (1)

- `plan_journey` (from, to, date) — Plan a train journey in Switzerland — finds connections, compares prices, and provides ticket links
