The Torrent Search MCP Server allows you to programmatically search and retrieve torrent data from multiple sources:
- Search Torrents: Query ThePirateBay, Nyaa, and YggTorrent with customizable source selection and result limits
- Get YggTorrent Details: Retrieve specific information about a YggTorrent torrent using its ID, with an option to include the magnet link
- Get YggTorrent Magnet Link: Directly fetch the magnet link for a specific YggTorrent torrent
Provides a containerized deployment option with preconfigured DNS settings (using quad9) to bypass common connection issues when accessing torrent sites
Supports configuration through .env files for storing sensitive information like YggTorrent passkeys
Includes a FastAPI server as an alternative interface with interactive API documentation (Swagger UI and ReDoc) for direct HTTP access
Available as a PyPI package for easy installation and integration into other Python applications
Provides a Python API wrapper for programmatic access to torrent search functionality
Uses Shields.io for generating status badges in the README
Offers Swagger UI documentation for the FastAPI interface, enabling easy API exploration and testing
Torrent Search MCP Server & API
This repository provides a Python API and an MCP (Model Context Protocol) server to find torrents programmatically on ThePirateBay, Nyaa and YggTorrent. It allows for easy integration into other applications or services.
Quickstart
Table of Contents
Features
- API wrapper for ThePirateBay, Nyaa and YggTorrent.
- Your Ygg passkey is injected locally into the torrent file/magnet link, ensuring it's not exposed externally
- MCP server interface for standardized communication (stdio, sse, streamable-http)
- FastAPI server interface for alternative HTTP access (e.g., for direct API calls or testing)
- Tools:
- Search for torrents on ThePirateBay, Nyaa and YggTorrent
- Get details for a specific YGG torrent
- Retrieve YGG magnet links
Setup
Prerequisites
- An active YggTorrent account and passkey (Optional).
- Python 3.10+ (required for PyPI install).
uv
(for local development)- Docker and Docker Compose (for Docker setup)
Configuration (Optional)
This application requires your YggTorrent passkey to interact with the API.
- Find your Passkey: On the YggTorrent website, navigate to
Mon compte
->Mes paramètres
. Your passkey is part of the tracker URL, which looks likehttp://tracker.p2p-world.net:8080/{YOUR_PASSKEY}/announce
. - Set Environment Variable: The application reads the passkey from the
YGG_PASSKEY
environment variable. The recommended way to set this is by creating a.env
file in your project's root directory. The application will load it automatically.
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:
- Create a
.env
file in the directory where you'll run the application and add your passkey (optional):
- Run the MCP server (default port: 8000):
For Local Development
This method is for contributors who want to modify the source code.
Using uv
:
- Clone the repository:
- Install dependencies using
uv
:
- Create your configuration file by copying the example and add your passkey (optional):
- Run the MCP server (default port: 8000):
For Docker
This method uses Docker to run the server in a container.
compose.yaml is configured to bypass DNS issues (using quad9 DNS).
- Clone the repository (if you haven't already):
- Create your configuration file by copying the example and add your passkey (optional):
- Build and run the container using Docker Compose (default port: 8765):
Usage
As Python Wrapper
As MCP Server
As FastAPI Server
This project also includes a FastAPI server as an alternative way to interact with the YggTorrent functionalities via a standard HTTP API. This can be useful for direct API calls, integration with other web services, or for testing purposes.
Running the FastAPI Server:
--host <host>
: Default:0.0.0.0
.--port <port>
: Default:8000
.--reload
: Enables auto-reloading when code changes (useful for development).--workers <workers>
: Default:1
.
The FastAPI server will then be accessible at http://<host>:<port>
Available Endpoints: The FastAPI server exposes similar functionalities to the MCP server. Key endpoints include:
/
: A simple health check endpoint. Returns{"status": "ok"}
./docs
: Interactive API documentation (Swagger UI)./redoc
: Alternative API documentation (ReDoc).
Environment variables (like YGG_PASSKEY
) are configured the same way as for the MCP server (via an .env
file in the project root).
Via MCP Clients
Usable with any MCP-compatible client. Available tools:
search_torrents
: Search for torrents.get_torrent_details
: Get details of a specific torrent.get_magnet_link
: Get the magnet link for a torrent.
Example with Windsurf
Configuration:
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.
You must be authenticated.
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A Python MCP server that allows programmatic interaction to find torrents programmatically on ThePirateBay, Nyaa and YggTorrent.
Related MCP Servers
- -securityFlicense-qualityThis is an MCP server that facilitates building tools for interacting with various APIs and workflows, supporting Python-based development with potential for customizable prompts and user configurations.Last updated -Python
- -securityAlicense-qualityA Python-based MCP server that crawls websites to extract and save content as markdown files, with features for mapping website structure and links.Last updated -1PythonMIT License
- -securityFlicense-qualityA Python-based server that helps users easily install and configure other MCP servers across different platforms.Last updated -2Python
- -securityFlicense-qualityA Python-based MCP server that integrates with Plex Media Server API to search for movies and manage playlists in your Plex media library.Last updated -Python