Python wrapper & MCP server for the Transmission API
Project description
Python API Wrapper & MCP Server for Transmission
This repository provides a Python API wrapper and an MCP (Model Context Protocol) server for the Transmission torrent client using the transmission-rpc library. It allows for easy integration into other applications or services.
Table of Contents
Features
- API wrapper for the
Transmissiontorrent client using the officialtransmission-rpclibrary. - MCP server interface for standardized communication (stdio, sse, streamable-http).
- Tools:
get_session: Get Transmission session configuration and version info.get_session_stats: Get session statistics (speeds, torrent counts, cumulative stats).free_space: Get free disk space in bytes at the specified path.list_torrents: List all torrents and their details.get_torrent_details: Get detailed information about a specific torrent.get_torrent_stats: Get stats/status of a specific torrent.get_recently_active: Get recently active torrents and IDs of recently removed ones.add_torrent: Download a torrent from magnet link, HTTP URL, or local file.download_torrent: Download a torrent from a magnet link, HTTP URL, or local file.start_torrent: Start (resume) a torrent.stop_torrent: Stop (pause) a torrent.pause_torrent: Pause a torrent.verify_torrent: Verify torrent data integrity.reannounce_torrent: Reannounce torrent to trackers.move_torrent: Move torrent data to a new location.set_torrent_labels: Set labels for a torrent.remove_torrent: Remove a torrent (optionally delete data).delete_torrent: Delete a torrent and its files.forget_torrent: Forget a torrent, keeping the files.
Setup
Prerequisites
- An running instance of Transmission. (Included in docker compose)
- Python 3.10+ (required for PyPI install).
uv(for local development)
Configuration
This application requires the URL of your Transmission instance.
Set Environment Variable: Copy .env.example to .env in your project's root directory and edit it with your settings. The application will automatically load variables from .env:
- MCP Server:
TRANSMISSION_URL: The URL of the Transmission instance (Default:http://localhost:9091).TRANSMISSION_USER: The username for Transmission authentication (optional).TRANSMISSION_PASS: The password for Transmission authentication (optional).
- Transmission Instance (for docker-compose setup):
TRANSMISSION_DOWNLOAD_DIR: The download directory for torrents (e.g.,/downloads).TRANSMISSION_WATCH_DIR: The watch directory for torrent files (e.g.,/watch).TRANSMISSION_RPC_URL: The RPC URL for the Transmission API (e.g.,http://localhost:9091/transmission/rpc).TRANSMISSION_PEER_PORT: The peer port for BitTorrent connections (e.g.,51413).TRANSMISSION_SPEED_LIMIT_DOWN: Download speed limit in KB/s (e.g.,100).TRANSMISSION_SPEED_LIMIT_UP: Upload speed limit in KB/s (e.g.,100).- Check Transmission for other variables and more information.
Installation
Choose one of the following installation methods.
Install from PyPI (Recommended)
This method is best for using the package as a library or running the server without modifying the code.
- Install the package from PyPI:
pip install transmission-mcp
- Create a
.envfile in the directory where you'll run the application and add yourTransmissionURL:
TRANSMISSION_URL=http://localhost:9091
- Run the MCP server (default: stdio):
python -m transmission_client
For Local Development
This method is for contributors who want to modify the source code.
Using uv:
- Clone the repository:
git clone https://github.com/philogicae/transmission-mcp.git
cd transmission-mcp
- Install dependencies using
uv:
uv sync --locked
- Create your configuration file by copying the example and add your settings:
cp .env.example .env
- Run the MCP server (default: stdio):
uv run -m transmission_client
For Docker
This method uses Docker to run the server in a container. compose.yaml includes Transmission torrent client.
- Clone the repository (if you haven't already):
git clone https://github.com/philogicae/transmission-mcp.git
cd transmission-mcp
- Create your configuration file by copying the example and add your settings:
cp .env.example .env
- Build and run the container using Docker Compose (default port: 8000):
docker compose up --build -d
- Access container logs:
docker logs transmission-mcp -f
Usage
As Python API Wrapper
import asyncio
from transmission_client import TransmissionClient
async def main():
# Initialize client (reads TRANSMISSION_URL, TRANSMISSION_USER, and TRANSMISSION_PASS from env)
client = TransmissionClient()
# Use as context manager for automatic cleanup
async with TransmissionClient() as client:
# Get session info
session = await client.get_session()
print(f"Transmission version: {session['version']}")
# Get session statistics
stats = await client.get_session_stats()
print(f"Download speed: {stats['downloadSpeed']} bytes/s")
# Check free space
free_space = await client.free_space("/downloads")
print(f"Free space: {free_space} bytes")
# List all torrents
torrents = await client.list_torrents()
# Add a torrent
await client.add_torrent("magnet:?xt=urn:btih:...")
# Get torrent details
details = await client.get_torrent("1") # Use ID or hash
# Control torrents
await client.stop_torrent("1") # Pause
await client.start_torrent("1") # Resume
# Verify torrent data
await client.verify_torrent("1")
# Move torrent data
await client.move_torrent("1", "/new/location", move=True)
# Set torrent labels
await client.set_torrent_labels("1", ["movies", "4k"])
# Remove torrent (keep files)
await client.remove_torrent("1", delete_data=False)
# Delete torrent and files
await client.remove_torrent("1", delete_data=True)
if __name__ == "__main__":
asyncio.run(main())
As MCP Server
from transmission_client import TransmissionMCP
TransmissionMCP.run(transport="sse") # 'stdio', 'sse', or 'streamable-http'
Via MCP Clients
Usable with any MCP-compatible client. Available tools:
get_session: Get Transmission session configuration and version info.get_session_stats: Get session statistics (speeds, torrent counts, cumulative stats).free_space: Get free disk space in bytes at the specified path.list_torrents: List all torrents and their details.get_torrent_details: Get details of a specific torrent by ID or hash.get_torrent_stats: Get stats/status of a specific torrent by ID or hash.get_recently_active: Get recently active torrents and IDs of recently removed ones.add_torrent: Add a torrent from magnet link, HTTP URL, or local file path.download_torrent: Download a torrent via magnet link, HTTP URL, or local file.start_torrent: Start (resume) a torrent by ID or hash.stop_torrent: Stop (pause) a torrent by ID or hash.pause_torrent: Pause a torrent by ID or hash.verify_torrent: Verify torrent data integrity by ID or hash.reannounce_torrent: Reannounce torrent to trackers by ID or hash.move_torrent: Move torrent data to a new location by ID or hash.set_torrent_labels: Set labels for a torrent by ID or hash.remove_torrent: Remove a torrent (optionally delete data) by ID or hash.delete_torrent: Delete a torrent and its files by ID or hash.forget_torrent: Forget a torrent, keeping the files, by ID or hash.
Example with Windsurf
Configuration:
{
"mcpServers": {
...
# with stdio (only requires uv)
"transmission-mcp": {
"command": "uvx",
"args": [ "transmission-mcp" ],
"env": {
"TRANSMISSION_URL": "http://localhost:9091", # (Optional) Default Transmission instance URL
"TRANSMISSION_USER": "username", # (Optional) Transmission username
"TRANSMISSION_PASS": "password" # (Optional) Transmission password
}
},
# with docker (only requires docker)
"transmission-mcp": {
"command": "docker",
"args": [ "run", "-i", "-p", "8000:8000", "-e", "TRANSMISSION_URL=http://localhost:9091", "-e", "TRANSMISSION_USER=username", "-e", "TRANSMISSION_PASS=password", "philogicae/transmission-mcp:latest", "transmission-mcp" ]
},
# with sse transport (requires installation)
"transmission-mcp": {
"serverUrl": "http://127.0.0.1:8000/sse"
},
# with streamable-http transport (requires installation)
"transmission-mcp": {
"serverUrl": "http://127.0.0.1:8000/mcp"
},
...
}
}
Changelog
See CHANGELOG.md for a history of changes to this project.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transmission_mcp-1.0.1.tar.gz.
File metadata
- Download URL: transmission_mcp-1.0.1.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38fbe450746bb72261136196c0479b08637b5f3425b8638dbd88cea5a4bce236
|
|
| MD5 |
1cbcc58a57e9373b5745c18bf0ac6ae8
|
|
| BLAKE2b-256 |
86f92c668b14b003fd091f86ca5489a855bb747ae1c7abd6f556d0926d6db313
|
Provenance
The following attestation bundles were made for transmission_mcp-1.0.1.tar.gz:
Publisher:
python-package-ci.yml on philogicae/transmission-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transmission_mcp-1.0.1.tar.gz -
Subject digest:
38fbe450746bb72261136196c0479b08637b5f3425b8638dbd88cea5a4bce236 - Sigstore transparency entry: 828976489
- Sigstore integration time:
-
Permalink:
philogicae/transmission-mcp@f92b018ca0a355ded686e84603b621b64640bfac -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/philogicae
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package-ci.yml@f92b018ca0a355ded686e84603b621b64640bfac -
Trigger Event:
push
-
Statement type:
File details
Details for the file transmission_mcp-1.0.1-py3-none-any.whl.
File metadata
- Download URL: transmission_mcp-1.0.1-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5329bef988d2a032ac3461567eac311a7382320ae8fde32d4e333a9044e0ab2
|
|
| MD5 |
436593fe89b856f2038dea03a624a61a
|
|
| BLAKE2b-256 |
6b9cdc73804f0f62208d59794080d009fb86b7ac6e9d4b5ad452791355dcfb51
|
Provenance
The following attestation bundles were made for transmission_mcp-1.0.1-py3-none-any.whl:
Publisher:
python-package-ci.yml on philogicae/transmission-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transmission_mcp-1.0.1-py3-none-any.whl -
Subject digest:
d5329bef988d2a032ac3461567eac311a7382320ae8fde32d4e333a9044e0ab2 - Sigstore transparency entry: 828976517
- Sigstore integration time:
-
Permalink:
philogicae/transmission-mcp@f92b018ca0a355ded686e84603b621b64640bfac -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/philogicae
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package-ci.yml@f92b018ca0a355ded686e84603b621b64640bfac -
Trigger Event:
push
-
Statement type: