get_torrent_details
Retrieve detailed information about a specific torrent, including optional magnet link, using the YggTorrent MCP Server for secure, programmatic access.
Instructions
Get details about a specific torrent.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| torrent_id | Yes | ||
| with_magnet_link | No |
Implementation Reference
- ygg_torrent/mcp_server.py:59-67 (handler)MCP tool handler and registration for 'get_torrent_details'. This function handles the tool call, logs the request, fetches details using the YggTorrentApi, and returns the torrent details as a string or 'Torrent not found'.@mcp.tool() def get_torrent_details(torrent_id: int) -> str | None: """Get details from YggTorrent about a specific torrent by id.""" logger.info(f"Getting details for torrent: {torrent_id}") torrent: Torrent | None = ygg_api.get_torrent_details( torrent_id, with_magnet_link=True ) return str(torrent) if torrent else "Torrent not found"
- Core helper function in YggTorrentApi class that implements the API call to retrieve torrent details from YggTorrent, optionally including magnet link, and formats the response into a Torrent object.def get_torrent_details( self, torrent_id: int, with_magnet_link: bool = False ) -> Torrent | None: """ Get details about a specific torrent. Corresponds to GET /torrent/{torrent_id} Args: torrent_id: The ID of the torrent. Returns: Detailed torrent result. """ if torrent_id < 1: print("torrent_id must be >= 1") return None resp = self._request("GET", f"torrent/{torrent_id}") if not resp: print("Failed to get torrent details") return None torrent = format_torrent(resp, torrent_id) if with_magnet_link: torrent.magnet_link = self.get_magnet_link(torrent_id) return torrent