Skip to main content
Glama
philogicae

rqbit Torrent Client MCP

download_torrent

Download torrent files using magnet links, HTTP URLs, or local files through the rqbit Torrent Client MCP server.

Instructions

Download a torrent from a magnet link, HTTP URL, or local file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
magnet_link_or_url_or_pathYes

Implementation Reference

  • MCP tool handler for 'download_torrent'. Decorated with @mcp.tool() for registration. Handles input validation via type hints and docstring, logs the action, delegates to RqbitClient.add_torrent, and serializes the result to JSON or returns error.
    @mcp.tool()
    async def download_torrent(magnet_link_or_url_or_path: str) -> str:
        """Download a torrent from a magnet link, HTTP URL, or local file."""
        logger.info(
            f"Downloading torrent from magnet link/HTTP URL/local file: {magnet_link_or_url_or_path}"
        )
        result = await rqbit_client.add_torrent(magnet_link_or_url_or_path)
        if isinstance(result, str):
            error = f"Error downloading torrent {magnet_link_or_url_or_path}: {result}"
            logger.error(error)
            return error
        return dumps(result)
  • Core helper method implementing torrent addition logic. Handles magnet links, HTTP URLs, and local files by posting to rqbit API endpoint /torrents with appropriate parameters and content handling.
    async def add_torrent(
        self, url_or_path: str, content: bytes | None = None
    ) -> dict[str, Any] | str:
        """Add a torrent from a magnet, HTTP URL, or local file."""
        url = "/torrents?&overwrite=true"
        if url_or_path.startswith("http"):
            url += "&is_url=true"
        if content:
            return await self._safe_request("POST", url, content=content)  # type: ignore
        if os.path.exists(url_or_path):
            try:
                with open(url_or_path, "rb") as f:
                    return await self._safe_request("POST", url, content=f.read())  # type: ignore
            except FileNotFoundError:
                return f"Error: File not found at {url_or_path}"
            except IOError as e:
                return f"Error reading file {url_or_path}: {e}"
        return await self._safe_request("POST", url, content=url_or_path)  # type: ignore

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/philogicae/rqbit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server