sbb-mcp 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +57 -57
- package/README.md +258 -314
- package/dist/cache.d.ts +2 -0
- package/dist/cache.js +4 -0
- package/dist/cache.js.map +1 -1
- package/dist/formatters.d.ts +13 -0
- package/dist/formatters.js +94 -19
- package/dist/formatters.js.map +1 -1
- package/dist/http.js +59 -3
- package/dist/http.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/look2book.d.ts +98 -0
- package/dist/look2book.js +212 -0
- package/dist/look2book.js.map +1 -0
- package/dist/profile.js +15 -8
- package/dist/profile.js.map +1 -1
- package/dist/shortlink.d.ts +60 -0
- package/dist/shortlink.js +122 -0
- package/dist/shortlink.js.map +1 -0
- package/dist/structured.d.ts +7 -1
- package/dist/structured.js +2 -1
- package/dist/structured.js.map +1 -1
- package/dist/swisstrip.js +21 -5
- package/dist/swisstrip.js.map +1 -1
- package/dist/tools.d.ts +38 -0
- package/dist/tools.js +122 -77
- package/dist/tools.js.map +1 -1
- package/dist/transport/index.d.ts +1 -0
- package/dist/transport/index.js +4 -0
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/setup.d.ts +1 -0
- package/dist/transport/setup.js +59 -0
- package/dist/transport/setup.js.map +1 -0
- package/dist/transport/smapi-auth.d.ts +14 -2
- package/dist/transport/smapi-auth.js +67 -17
- package/dist/transport/smapi-auth.js.map +1 -1
- package/dist/transport/smapi-client.d.ts +25 -1
- package/dist/transport/smapi-client.js +112 -9
- package/dist/transport/smapi-client.js.map +1 -1
- package/dist/transport/smapi-journey.d.ts +11 -5
- package/dist/transport/smapi-journey.js +16 -7
- package/dist/transport/smapi-journey.js.map +1 -1
- package/dist/transport/smapi-mock.js.map +1 -1
- package/dist/transport/smapi-prices.d.ts +43 -9
- package/dist/transport/smapi-prices.js +112 -41
- package/dist/transport/smapi-prices.js.map +1 -1
- package/dist/transport/smapi-types.d.ts +28 -0
- package/dist/widgets.d.ts +30 -3
- package/dist/widgets.js +78 -14
- package/dist/widgets.js.map +1 -1
- package/package.json +79 -73
- package/web/dist/widgets.css +1 -1
- package/web/dist/widgets.js +1 -1
package/README.md
CHANGED
|
@@ -1,314 +1,258 @@
|
|
|
1
|
-
# sbb-mcp
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/sbb-mcp)
|
|
4
|
-
[](https://fsl.software/)
|
|
5
|
-
[![smithery
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Add
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
```jsonc
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
-
|
|
202
|
-
-
|
|
203
|
-
-
|
|
204
|
-
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
##
|
|
231
|
-
|
|
232
|
-
###
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
- **Cloud-synced profiles** -- your travel profile (name, DOB, reduction card) syncs from SwissTrip instead of local `~/.sbb-mcp/profile.json`
|
|
261
|
-
- **Multi-traveler pricing** -- add your partner, kids, or travel companions on SwissTrip and get per-person pricing with correct reduction cards
|
|
262
|
-
- **Family tickets** -- pass `traveler_names` to `get_prices` and `get_ticket_link` for group pricing
|
|
263
|
-
|
|
264
|
-
```json
|
|
265
|
-
{
|
|
266
|
-
"mcpServers": {
|
|
267
|
-
"sbb": {
|
|
268
|
-
"command": "npx",
|
|
269
|
-
"args": ["-y", "sbb-mcp"],
|
|
270
|
-
"env": {
|
|
271
|
-
"SMAPI_CLIENT_ID": "your-client-id",
|
|
272
|
-
"SMAPI_CLIENT_SECRET": "your-secret",
|
|
273
|
-
"SMAPI_SCOPE": "your-scope",
|
|
274
|
-
"SWISSTRIP_TOKEN": "your-swisstrip-auth-token"
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
Without `SWISSTRIP_TOKEN`, sbb-mcp uses local file-based profiles as before -- no SwissTrip account required.
|
|
282
|
-
|
|
283
|
-
## Available on
|
|
284
|
-
|
|
285
|
-
- [npm](https://www.npmjs.com/package/sbb-mcp)
|
|
286
|
-
- [Official MCP Registry](https://registry.modelcontextprotocol.io)
|
|
287
|
-
- [Smithery](https://smithery.ai/servers/fabsforward2-zhoi/sbb-mcp)
|
|
288
|
-
|
|
289
|
-
Also available as: [sbb-mcp-official](https://www.npmjs.com/package/sbb-mcp-official) | [swiss-rail-mcp](https://www.npmjs.com/package/swiss-rail-mcp) | [sbb-cff-ffs-mcp](https://www.npmjs.com/package/sbb-cff-ffs-mcp) | [swiss-train-mcp](https://www.npmjs.com/package/swiss-train-mcp) | [swiss-railways-mcp](https://www.npmjs.com/package/swiss-railways-mcp)
|
|
290
|
-
|
|
291
|
-
## About
|
|
292
|
-
|
|
293
|
-
Built on the official SBB Swiss Mobility API (SMAPI) with OSDM-compliant journey planning and pricing. Covers the entire Swiss public transport network including SBB, BLS, SOB, and regional operators. Weather data powered by [swiss-weather-mcp](https://www.npmjs.com/package/swiss-weather-mcp) (MeteoSwiss + Open-Meteo).
|
|
294
|
-
|
|
295
|
-
**SBB** (Schweizerische Bundesbahnen) / **CFF** (Chemins de fer federaux suisses) / **FFS** (Ferrovie federali svizzere) -- Swiss Federal Railways operates one of the densest rail networks in the world with over 10,000 daily connections.
|
|
296
|
-
|
|
297
|
-
## Changelog
|
|
298
|
-
|
|
299
|
-
### v0.4.0 — Multilingual
|
|
300
|
-
|
|
301
|
-
- Every tool now accepts an optional `language` parameter (`de | fr | it | en | es | pt | ru | ar | zh`).
|
|
302
|
-
- Labels, date/time formatting, and the SBB ticket-buy button text are translated.
|
|
303
|
-
- `Accept-Language` is passed to SBB SMAPI so station names come back in the requested language where supported (de/fr/it/en).
|
|
304
|
-
- `save_profile` stores a preferred language; later tool calls default to it when `language` is omitted.
|
|
305
|
-
- **Breaking:** default output locale with no profile and no tool arg is now `en` (was implicitly `de-CH`). Set a profile or pass `language: 'de'` to restore the old behavior.
|
|
306
|
-
- Translations shared with the WhatsApp/Telegram bots via the new [`sbb-i18n`](https://www.npmjs.com/package/sbb-i18n) package.
|
|
307
|
-
|
|
308
|
-
### v0.3.0 — Destination weather
|
|
309
|
-
|
|
310
|
-
- Automatic weather forecast appended to `search_connections` results via [`swiss-weather-mcp`](https://www.npmjs.com/package/swiss-weather-mcp).
|
|
311
|
-
|
|
312
|
-
## License
|
|
313
|
-
|
|
314
|
-
[FSL-1.1-MIT](https://fsl.software/) -- Functional Source License. Free to use for any non-competing purpose. Converts to MIT after 2 years. See [LICENSE](LICENSE) for details.
|
|
1
|
+
# sbb-mcp
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/sbb-mcp)
|
|
4
|
+
[](https://fsl.software/)
|
|
5
|
+
[](https://smithery.ai/servers/fabsforward2-zhoi/sbb-mcp)
|
|
6
|
+
|
|
7
|
+
> **Swiss trains in any AI assistant.** Real-time schedules, ticket prices with Half-Fare/GA discounts, and direct purchase links for Claude Desktop, ChatGPT, Cursor, and any MCP-compatible client.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
You: trains from Bern to Zermatt tomorrow at 9am, with Halbtax
|
|
11
|
+
AI: IC 8 14:32 → 17:24 (2h52, 1 transfer in Visp, Pl. 8) — CHF 42.50
|
|
12
|
+
IC 8 15:02 → 17:54 (2h52, 1 transfer in Visp, Pl. 8) — CHF 42.50
|
|
13
|
+
[Buy on SBB.ch ↗]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Ask any AI assistant to find Swiss trains. It returns connections, prices with your reduction card applied, and a direct ticket-purchase link to sbb.ch — all through natural language.
|
|
17
|
+
|
|
18
|
+
> **Not affiliated with SBB.** Independent, community-maintained MCP server built on SBB's public Swiss Mobility API (SMAPI). Not affiliated with or endorsed by SBB (Schweizerische Bundesbahnen).
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Quick install
|
|
23
|
+
|
|
24
|
+
### ChatGPT (no install — hosted)
|
|
25
|
+
|
|
26
|
+
ChatGPT Plus / Pro / Business / Enterprise with Developer Mode enabled:
|
|
27
|
+
|
|
28
|
+
1. **Settings → Connectors** → enable **Developer Mode**
|
|
29
|
+
2. Click **Add custom connector**
|
|
30
|
+
3. **MCP Server URL:** `https://mcp.swisstrip.app/mcp`
|
|
31
|
+
4. **Authentication:** None
|
|
32
|
+
5. Save, then enable via the **+** button in the composer
|
|
33
|
+
|
|
34
|
+
Tool responses render as native ChatGPT widgets (connection cards, trip timelines, price tables) via the OpenAI Apps SDK.
|
|
35
|
+
|
|
36
|
+
### Claude Code
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
claude mcp add sbb -- npx -y sbb-mcp
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Done — try `/mcp` in Claude to confirm it's loaded, then ask about Swiss trains.
|
|
43
|
+
|
|
44
|
+
### Claude Desktop
|
|
45
|
+
|
|
46
|
+
Add to `claude_desktop_config.json`:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"sbb": {
|
|
52
|
+
"command": "npx",
|
|
53
|
+
"args": ["-y", "sbb-mcp"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Restart Claude Desktop. That's it — works in **mock mode** out of the box with realistic Swiss station data. Add credentials later for live SBB data (see below).
|
|
60
|
+
|
|
61
|
+
### Cursor / Windsurf / VS Code Copilot
|
|
62
|
+
|
|
63
|
+
Same `mcpServers` block as Claude Desktop, in the respective config file:
|
|
64
|
+
|
|
65
|
+
| Client | Config path |
|
|
66
|
+
|---|---|
|
|
67
|
+
| Cursor | `.cursor/mcp.json` |
|
|
68
|
+
| Windsurf | `~/.codeium/windsurf/mcp_config.json` |
|
|
69
|
+
| VS Code Copilot | `.vscode/mcp.json` (use top-level `servers` instead of `mcpServers`) |
|
|
70
|
+
|
|
71
|
+
### Try it without installing
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx sbb-mcp
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Runs in mock mode with realistic Swiss station data — no setup, no credentials. Useful for testing the protocol or building demos.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Live SBB data (optional)
|
|
82
|
+
|
|
83
|
+
Mock mode works out of the box. For real-time schedules and prices, get credentials from the [SBB Developer Portal](https://developer.sbb.ch) (free signup, OAuth 2.0 + business contract).
|
|
84
|
+
|
|
85
|
+
Add to your config's `env` block:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"mcpServers": {
|
|
90
|
+
"sbb": {
|
|
91
|
+
"command": "npx",
|
|
92
|
+
"args": ["-y", "sbb-mcp"],
|
|
93
|
+
"env": {
|
|
94
|
+
"SMAPI_JOURNEY_CLIENT_ID": "...",
|
|
95
|
+
"SMAPI_JOURNEY_CLIENT_SECRET": "...",
|
|
96
|
+
"SMAPI_JOURNEY_SCOPE": "api://.../.default",
|
|
97
|
+
"SMAPI_TICKETING_CLIENT_ID": "...",
|
|
98
|
+
"SMAPI_TICKETING_CLIENT_SECRET": "...",
|
|
99
|
+
"SMAPI_TICKETING_SCOPE": "api://.../.default",
|
|
100
|
+
"SMAPI_CONTRACT_ID": "..."
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
SBB issues separate AAD apps per API. The Journey API is for schedules/stations; the Ticketing API for prices/booking links. Set whichever you have approved — the server falls back to mock data per family if a credential set is missing.
|
|
108
|
+
|
|
109
|
+
For backwards compatibility, single-app setups can use the generic `SMAPI_CLIENT_ID` / `SMAPI_CLIENT_SECRET` / `SMAPI_SCOPE` for both APIs.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## What it does
|
|
114
|
+
|
|
115
|
+
- **Search stations** — find any Swiss train station by name, get UIC IDs
|
|
116
|
+
- **Train connections** — schedules with departure/arrival times, platforms, transfer info, occupancy forecasts
|
|
117
|
+
- **Ticket prices** — 1st/2nd class with Half-Fare (Halbtax) and GA travelcard support
|
|
118
|
+
- **Purchase links** — direct deep links to buy on SBB.ch (opens the SBB app on mobile with discounts applied)
|
|
119
|
+
- **Pagination** — browse earlier/later connections without losing context
|
|
120
|
+
- **Trip details** — intermediate stops, platforms, real-time status
|
|
121
|
+
- **Destination weather** — auto-included in connection results via [`swiss-weather-mcp`](https://www.npmjs.com/package/swiss-weather-mcp)
|
|
122
|
+
- **Multilingual** — output in 9 languages (`de fr it en es pt ru ar zh`)
|
|
123
|
+
- **ChatGPT widgets** — connection cards, price tables, ticket cards rendered as native UI via OpenAI Apps SDK
|
|
124
|
+
- **Mock mode** — full demo data without credentials
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Tools
|
|
129
|
+
|
|
130
|
+
9 MCP tools, all support an optional `language` argument.
|
|
131
|
+
|
|
132
|
+
| Tool | What it does |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `search_stations` | Find stations by name → UIC IDs |
|
|
135
|
+
| `search_connections` | Schedules between two stations (returns trip IDs) |
|
|
136
|
+
| `get_trip_details` | Stop-by-stop info, platforms, occupancy |
|
|
137
|
+
| `get_more_connections` | Earlier/later trains via pagination |
|
|
138
|
+
| `get_prices` | Ticket prices with reduction card applied |
|
|
139
|
+
| `get_ticket_link` | Direct purchase link to SBB.ch (mobile-app deep link) |
|
|
140
|
+
| `save_profile` | Save user's reduction card + DOB locally for auto-apply |
|
|
141
|
+
| `get_profile` | Read saved profile |
|
|
142
|
+
| `list_travelers` | Multi-traveler family pricing (requires SwissTrip account) |
|
|
143
|
+
|
|
144
|
+
Plus a `plan_journey` prompt for end-to-end trip planning.
|
|
145
|
+
|
|
146
|
+
### Multilingual
|
|
147
|
+
|
|
148
|
+
Every tool accepts `language: "de" | "fr" | "it" | "en" | "es" | "pt" | "ru" | "ar" | "zh"`. Sets `Accept-Language` on SBB API calls so station names come back in the requested language; localizes the buy-button text on deep links.
|
|
149
|
+
|
|
150
|
+
```jsonc
|
|
151
|
+
// French output
|
|
152
|
+
{ "from": "Zürich HB", "to": "Genève", "language": "fr" }
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Save a default once via `save_profile` — subsequent calls use it automatically.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Hosted MCP endpoint
|
|
160
|
+
|
|
161
|
+
A public HTTPS endpoint is live at `https://mcp.swisstrip.app/mcp` for clients that prefer remote MCP over local stdio (ChatGPT, Claude Pro remote MCPs, etc.). Same tools, plus rich widgets for ChatGPT.
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Test from your terminal
|
|
165
|
+
curl -X POST https://mcp.swisstrip.app/mcp \
|
|
166
|
+
-H 'Content-Type: application/json' \
|
|
167
|
+
-H 'Accept: application/json, text/event-stream' \
|
|
168
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Environment variables
|
|
174
|
+
|
|
175
|
+
| Variable | Required | Description |
|
|
176
|
+
|---|---|---|
|
|
177
|
+
| `SMAPI_JOURNEY_CLIENT_ID` / `_CLIENT_SECRET` / `_SCOPE` | For schedules + stations | OAuth credentials for SBB Journey API |
|
|
178
|
+
| `SMAPI_TICKETING_CLIENT_ID` / `_CLIENT_SECRET` / `_SCOPE` | For prices + booking links | OAuth credentials for SBB Ticketing API (b2p) |
|
|
179
|
+
| `SMAPI_CLIENT_ID` / `_CLIENT_SECRET` / `_SCOPE` | Fallback | Single-app credentials, used for any family without specific vars |
|
|
180
|
+
| `SMAPI_CONTRACT_ID` | With any creds | SBB partner contract identifier |
|
|
181
|
+
| `SMAPI_ENV` | No | `int` (default) \| `prod` \| `mock` |
|
|
182
|
+
| `SMAPI_TENANT_ID` | No | Azure AD tenant override (defaults to SBB's) |
|
|
183
|
+
| `SWISSTRIP_TOKEN` | No | SwissTrip account token for cloud-synced multi-traveler profiles |
|
|
184
|
+
|
|
185
|
+
Without any SMAPI credentials → mock mode (realistic demo data).
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## SwissTrip integration (optional)
|
|
190
|
+
|
|
191
|
+
Connect your [SwissTrip](https://swisstrip.app) account via `SWISSTRIP_TOKEN` to enable:
|
|
192
|
+
|
|
193
|
+
- Cloud-synced travel profile (name, DOB, reduction card) instead of local file
|
|
194
|
+
- Multi-traveler family pricing (partner, kids, each with their own card)
|
|
195
|
+
- Mint a token at https://swisstrip.app/settings/developer
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Available everywhere
|
|
200
|
+
|
|
201
|
+
- [npm](https://www.npmjs.com/package/sbb-mcp)
|
|
202
|
+
- [Official MCP Registry](https://registry.modelcontextprotocol.io)
|
|
203
|
+
- [Smithery](https://smithery.ai/servers/fabsforward2-zhoi/sbb-mcp)
|
|
204
|
+
- [PulseMCP](https://www.pulsemcp.com/servers/fabsbags-sbb)
|
|
205
|
+
- [LobeHub](https://lobehub.com/mcp)
|
|
206
|
+
- ChatGPT custom connector at `https://mcp.swisstrip.app/mcp`
|
|
207
|
+
|
|
208
|
+
Also published under alias names that all forward to `sbb-mcp`: [swiss-rail-mcp](https://www.npmjs.com/package/swiss-rail-mcp), [sbb-cff-ffs-mcp](https://www.npmjs.com/package/sbb-cff-ffs-mcp), [swiss-train-mcp](https://www.npmjs.com/package/swiss-train-mcp), [swiss-railways-mcp](https://www.npmjs.com/package/swiss-railways-mcp).
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## About
|
|
213
|
+
|
|
214
|
+
Built on SBB's commercial Swiss Mobility API (SMAPI) with OSDM-compliant journey planning and Azure AD OAuth. Covers SBB plus regional operators (BLS, SOB, MOB, RhB, etc.) — the entire Swiss public transport network with 10,000+ daily connections.
|
|
215
|
+
|
|
216
|
+
Weather data via [`swiss-weather-mcp`](https://www.npmjs.com/package/swiss-weather-mcp) (MeteoSwiss + Open-Meteo).
|
|
217
|
+
|
|
218
|
+
Repository: [Fabsbags/swisstrip-web](https://github.com/Fabsbags/swisstrip-web/tree/main/packages/sbb-mcp). Issues: [tracker](https://github.com/Fabsbags/swisstrip-web/issues).
|
|
219
|
+
|
|
220
|
+
**SBB** (Schweizerische Bundesbahnen) / **CFF** (Chemins de fer fédéraux suisses) / **FFS** (Ferrovie federali svizzere) — Swiss Federal Railways.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
[FSL-1.1-MIT](https://fsl.software/) — Functional Source License. Free for any non-competing purpose. Converts to MIT after 2 years. See [LICENSE](LICENSE).
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Changelog
|
|
231
|
+
|
|
232
|
+
### v0.4.3 — README polish
|
|
233
|
+
|
|
234
|
+
Launch-focused README rewrite: install-first structure, ChatGPT custom connector promoted to top, mock-mode-by-default messaging, 9-tool reference table, per-family SBB credential env vars documented. No runtime changes — `sbb-mcp@0.4.2` behavior is identical to `0.4.3`.
|
|
235
|
+
|
|
236
|
+
### v0.4.2 — Repository metadata
|
|
237
|
+
|
|
238
|
+
Point `repository`, `homepage`, and `bugs` at the monorepo source of truth. No runtime changes.
|
|
239
|
+
|
|
240
|
+
### v0.4.1 — Apps SDK widgets
|
|
241
|
+
|
|
242
|
+
- Five Preact widgets registered as `ui://widget/*.html` resources: stations list, connection list, trip details, prices table, ticket card
|
|
243
|
+
- Tool responses include `structuredContent` + `_meta["openai/outputTemplate"]` so ChatGPT renders rich UI
|
|
244
|
+
- Hosted endpoint live at `https://mcp.swisstrip.app/mcp` for use as a ChatGPT custom connector
|
|
245
|
+
- Widget bundle ~25KB (single IIFE, inlined CSS) built via Vite under `web/`
|
|
246
|
+
- Server rendering unchanged for stdio clients
|
|
247
|
+
|
|
248
|
+
### v0.4.0 — Multilingual
|
|
249
|
+
|
|
250
|
+
- Optional `language` argument on every tool (9 languages)
|
|
251
|
+
- `Accept-Language` passed to SBB SMAPI for localized station names
|
|
252
|
+
- `save_profile` stores preferred language as default
|
|
253
|
+
- **Breaking:** default output locale with no profile is now `en` (was `de-CH`). Set a profile or pass `language: 'de'` to restore previous behavior.
|
|
254
|
+
- Translations shared with WhatsApp/Telegram bots via [`sbb-i18n`](https://www.npmjs.com/package/sbb-i18n)
|
|
255
|
+
|
|
256
|
+
### v0.3.0 — Destination weather
|
|
257
|
+
|
|
258
|
+
Auto-include weather forecast in `search_connections` results via [`swiss-weather-mcp`](https://www.npmjs.com/package/swiss-weather-mcp).
|
package/dist/cache.d.ts
CHANGED
package/dist/cache.js
CHANGED
|
@@ -55,4 +55,8 @@ export const TTL = {
|
|
|
55
55
|
PRICES: 2 * 60 * 1000, // 2 minutes
|
|
56
56
|
TRIP_DETAILS: 5 * 60 * 1000, // 5 minutes
|
|
57
57
|
};
|
|
58
|
+
/** Test-only: clear all entries. No effect in production. */
|
|
59
|
+
export function __clearCacheForTesting() {
|
|
60
|
+
store.clear();
|
|
61
|
+
}
|
|
58
62
|
//# sourceMappingURL=cache.js.map
|
package/dist/cache.js.map
CHANGED
|
@@ -1 +1 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A;QAC5C,CAAC;IACH,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;AACzD,CAAC;AAED,OAAO;AACP,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAK,WAAW;IAC7C,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAS,YAAY;IAC/C,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAc,YAAY;IAC/C,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAQ,YAAY;CACvC,CAAA;AAEV,6DAA6D;AAC7D,MAAM,UAAU,sBAAsB;IACpC,KAAK,CAAC,KAAK,EAAE,CAAA;AACf,CAAC"}
|
package/dist/formatters.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { SmapiPlace, SmapiTrip, SmapiTripsCollection, SmapiPriceResult } from './transport/smapi-types.js';
|
|
2
2
|
import type { Lang } from './i18n.js';
|
|
3
|
+
/**
|
|
4
|
+
* Terse one-line summary used when the client renders the Apps SDK widget
|
|
5
|
+
* (see `isWidgetRenderingClient`). Widget clients already show a full card
|
|
6
|
+
* list — returning the long markdown table here just causes the LLM to
|
|
7
|
+
* paraphrase it into a redundant narration right next to the iframe. The
|
|
8
|
+
* structured content still carries all the data the model needs to answer
|
|
9
|
+
* follow-up questions; this string is purely for the chat bubble above the
|
|
10
|
+
* widget.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatStationsTerse(stations: SmapiPlace[], _lang?: Lang): string;
|
|
13
|
+
export declare function formatConnectionsTerse(collection: SmapiTripsCollection, lang?: Lang): string;
|
|
14
|
+
export declare function formatTripDetailsTerse(trip: SmapiTrip, lang?: Lang): string;
|
|
15
|
+
export declare function formatPricesTerse(results: SmapiPriceResult[], lang?: Lang): string;
|
|
3
16
|
export declare function formatStations(stations: SmapiPlace[], lang?: Lang): string;
|
|
4
17
|
export declare function formatConnections(collection: SmapiTripsCollection, lang?: Lang): string;
|
|
5
18
|
export declare function formatTripDetails(trip: SmapiTrip, lang?: Lang): string;
|