Metadata-Version: 2.4
Name: mcp-deutsche-bahn
Version: 0.1.1
Summary: MCP server exposing live Deutsche Bahn data: journeys, delays, disruptions, strikes, and alternative routes.
Project-URL: Homepage, https://github.com/heykay/mcp-deutsche-bahn
Project-URL: Issues, https://github.com/heykay/mcp-deutsche-bahn/issues
Author-email: Heykay <akhinoz@gmail.com>
License: MIT
License-File: LICENSE
Keywords: anthropic,claude,db,deutsche-bahn,hafas,mcp,trains
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: anthropic>=0.104.0
Requires-Dist: feedparser>=6.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: mcp>=1.0.0
Requires-Dist: pydantic>=2.0
Requires-Dist: python-dateutil>=2.9
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Description-Content-Type: text/markdown

# mcp-deutsche-bahn

An MCP server that gives any MCP-compatible AI assistant (Claude Desktop, Claude Code, Cursor, etc.) live access to Deutsche Bahn data: journey planning, real-time delays, disruptions, construction works, strikes, and alternative routes.

## What it does

Six tools, available to your LLM:

| Tool                  | Answers                                                        |
|-----------------------|----------------------------------------------------------------|
| `search_journeys`     | "How do I get from Berlin Hbf to München Hbf tomorrow at 9am?" |
| `station_departures`  | "What's leaving Hamburg Hbf in the next hour?"                 |
| `journey_status`      | "Has my booked journey been delayed?"                          |
| `get_disruptions`     | "Any construction on the Köln–Frankfurt corridor?"             |
| `detect_strike`       | "Is there a strike going on right now?"                        |
| `find_alternatives`   | "Route me around Hannover Hbf if it's blocked."                |

---

## Quickstart (1 minute, no clone)

You need **`uv`** ([one-line install](https://docs.astral.sh/uv/getting-started/installation/)):

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

That's the only prereq. The MCP server itself installs on demand — pick your client:

### Claude Desktop

Open `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows). Add:

```json
{
  "mcpServers": {
    "deutsche-bahn": {
      "command": "uvx",
      "args": ["mcp-deutsche-bahn"]
    }
  }
}
```

Restart Claude Desktop (⌘Q + reopen — closing the window isn't enough). A plug icon appears in the input bar → click it → confirm `deutsche-bahn` lists 6 tools.

### Claude Code

```bash
claude mcp add deutsche-bahn -- uvx mcp-deutsche-bahn
```

### Cursor / other MCP clients

Same shape — `command: uvx`, `args: ["mcp-deutsche-bahn"]`.

---

## Try it

Ask your assistant:

> What are my options getting from Berlin Hbf to Munich tomorrow at 8am, and is there any construction on that route?

It will call `search_journeys` and `get_disruptions` and stitch a human answer.

---

## Optional: standalone CLI agent

If you want a plain-English REPL without Claude Desktop, the package ships an `anthropic`-powered front-end that drives the MCP server directly:

```bash
export ANTHROPIC_API_KEY=sk-ant-...
uvx --from mcp-deutsche-bahn mcp-deutsche-bahn-agent                              # interactive
uvx --from mcp-deutsche-bahn mcp-deutsche-bahn-agent "next trains out of Hamburg" # one-shot
```

---

## Local development

```bash
git clone https://github.com/heykay/mcp-deutsche-bahn.git
cd mcp-deutsche-bahn
uv sync --extra dev
uv run pytest -m live   # smoke tests, hit the real API
uv run ruff check .
```

Run the server in inspector mode to poke individual tools without an MCP client:

```bash
npx @modelcontextprotocol/inspector uv run mcp-deutsche-bahn
```

To point Claude Desktop at your local checkout (instead of the published package), use `uv --directory /path/to/clone run mcp-deutsche-bahn` as the command.

---

## Roadmap

- v0.2: hosted/remote MCP variant (HTTP + SSE) for non-CLI users
- v0.2: richer strike signal — wire to a real news API
- v0.3: ticket-price comparison via DB API Marketplace

## Contributing

PRs welcome. File issues with the query that broke and the JSON the tool returned.

## License

MIT — see [LICENSE](LICENSE).
