mcp-rtorrent
by Je-Bin
README.md
# mcp-rtorrent
<!-- mcp-name: io.github.je-bin/mcp-rtorrent -->
## Publishing to the MCP Registry
This server is registered as `io.github.je-bin/mcp-rtorrent` in the [MCP Registry](https://registry.modelcontextprotocol.io/).
`server.json` holds the registry metadata, and the `mcp-name` marker above is what the registry
checks to prove ownership of the published package.
To publish a new version:
1. Create the package on [PyPI](https://pypi.org) and configure *Trusted Publishing* for this
repository and the `publish-mcp.yml` workflow.
2. Bump the version in `pyproject.toml` (or `server.json`) and tag the release (`git tag vX.Y.Z`).
3. Push the tag: the workflow publishes to PyPI and then to the MCP Registry.
An [MCP](https://modelcontextprotocol.io) (Model Context Protocol) server that exposes an
[rtbit](https://github.com/amousa/rusttorrent) client — the Rust BitTorrent client used in my
homelab — to AI assistants over stdio.
The server speaks to the rtbit HTTP API (v7) and turns its REST routes into 10 MCP tools:
list torrents, read their progress and peers, pause, resume, and add a magnet link.
**Deleting a torrent is deliberately not exposed.**
## Features
| Tool | What it does |
| --- | --- |
| `rtbit_global_stats` | Global client statistics: download/upload speed, live peers, counters, uptime |
| `rtbit_list_torrents` | List torrents, optionally filtered by name, category or state |
| `rtbit_get_torrent` | Full detail of one torrent (metadata, tags, trackers, output folder) |
| `rtbit_torrent_stats` | Progress of one torrent: bytes downloaded, percentage, state |
| `rtbit_peer_stats` | Peers connected to a torrent: address, client, progress, speed |
| `rtbit_torrent_files` | Files contained in a torrent, with their size |
| `rtbit_limits` | Download limits configured in the client (speed, slots, peers) |
| `rtbit_pause` | Pause a torrent |
| `rtbit_start` | Resume a torrent |
| `rtbit_add_magnet` | Add a torrent from a magnet link or a `.torrent` URL |
Torrents can be addressed either by their numeric id or by their info hash.
## Requirements
- Python 3.10+
- `mcp` 2.3.0 or later (provides `mcp.server.mcpserver.MCPServer`)
- A reachable rtbit instance with its HTTP API enabled, and an API key (`rtb_...`)
## Installation
```bash
git clone https://github.com/Je-Bin/mcp-rtorrent.git
cd mcp-rtorrent
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
```
## Configuration
Everything is configured through environment variables:
| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| `RTBIT_URL` | recommended | `http://192.0.2.10:3030` | Base URL of the rtbit HTTP API. The default is a documentation address — point it at your own instance. |
| `RTBIT_API_KEY` | **yes** | *(empty)* | The rtbit API key (`rtb_...`). If it is missing, every tool returns an explicit configuration error instead of sending an unauthenticated request. |
The key is only ever read from the environment: it is never written to disk, never logged and
never passed on the command line.
### Example MCP client configuration
```json
{
"mcpServers": {
"rtorrent": {
"command": "/path/to/mcp-rtorrent/.venv/bin/python",
"args": ["/path/to/mcp-rtorrent/server.py"],
"env": {
"RTBIT_URL": "http://192.0.2.10:3030",
"RTBIT_API_KEY": "rtb_..."
}
}
}
}
```
### Running it manually
```bash
RTBIT_URL=http://192.0.2.10:3030 RTBIT_API_KEY=rtb_... python server.py
```
The server speaks MCP over stdio, so it stays silent until a client talks to it.
## Tools in action
A typical conversation looks like this:
```text
You: which torrents are still downloading?
Assistant: (calls rtbit_list_torrents with state="downloading")
```
```json
{
"tool": "rtbit_list_torrents",
"arguments": { "state": "downloading", "limit": 20 }
}
```
```json
{
"total_torrents": 128,
"matches": 3,
"returned": 3,
"torrents": [
{
"id": 412,
"name": "example-linux-iso",
"category": "isos",
"tags": ["linux"],
"state": "downloading",
"progress_pct": 63.4,
"total_size": "2.1 GiB",
"finished": false
}
]
}
```
Other examples:
```json
{ "tool": "rtbit_global_stats", "arguments": {} }
```
```json
{ "tool": "rtbit_get_torrent", "arguments": { "torrent_id": "412" } }
```
```json
{ "tool": "rtbit_peer_stats", "arguments": { "torrent_id": "412", "state": "downloading" } }
```
```json
{ "tool": "rtbit_pause", "arguments": { "torrent_id": "412" } }
```
```json
{ "tool": "rtbit_start", "arguments": { "torrent_id": "412" } }
```
```json
{
"tool": "rtbit_add_magnet",
"arguments": {
"magnet_uri": "magnet:?xt=urn:btih:0123456789abcdef0123456789abcdef01234567",
"output_folder": "/downloads/isos",
"paused": true
}
}
```
## Helper script
`scripts/rtbit_bulk_start.py` resumes every paused torrent in one go (finished torrents are
skipped). It is a plain CLI, not an MCP tool:
```bash
RTBIT_URL=http://192.0.2.10:3030 RTBIT_API_KEY=rtb_... \
python scripts/rtbit_bulk_start.py --all --dry-run
```
## Security
- **No deletion tool.** The rtbit API can delete torrents and their data; this server does not
expose that route. An assistant can add, pause and resume, but never erase.
- **Least privilege.** Point `RTBIT_API_KEY` at a key scoped to the operations you allow, and keep
the rtbit API bound to the local network or behind a reverse proxy.
- **Secrets stay in the environment.** The API key is read from `RTBIT_API_KEY` only. It is never
written to disk, echoed in tool output, or included in a command line. If the variable is unset
or empty, the tools return a clear configuration error instead of calling the API.
- **Local transport.** The server communicates over stdio with the MCP client, so no listening
socket is opened on your network.
- **No arbitrary code execution.** The server only talks to the rtbit HTTP API; it never runs
shell commands and never touches the file system.
## License
MIT — see [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues