种子搜索
STDIO种子搜索MCP服务器支持多平台
种子搜索MCP服务器支持多平台
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.
How to use it with MCP Clients Run it with Docker to bypass common DNS issues
uv (for local development)This application requires a passkey if you want to interact with YggTorrent.
Mon compte -> PASSKEY field..env file in your project's root directory. The application will load it automatically. See .env.example for all available options.Choose one of the following installation methods.
This method is best for using the package as a library or running the server without modifying the code.
pip install torrent-search-mcp crawl4ai-setup # For crawl4ai/playwright playwright install --with-deps chromium # If previous command fails
.env file in the directory where you'll run the application and add your passkey (optional):YGG_PASSKEY=your_passkey_here
python -m torrent_search
This method is for contributors who want to modify the source code.
Using uv:
git clone https://github.com/philogicae/torrent-search-mcp.git cd torrent-search-mcp
uv:uv sync --locked uvx playwright install --with-deps chromium
cp .env.example .env
uv run -m torrent_search
This method uses Docker to run the server in a container.
compose.yaml is configured to bypass DNS issues (using quad9 DNS).
git clone https://github.com/philogicae/torrent-search-mcp.git cd torrent-search-mcp
cp .env.example .env
docker compose up --build -d
docker logs torrent-search-mcp -f
from torrent_search import torrent_search_api results = torrent_search_api.search_torrents('...') for torrent in results: print(f"{torrent.filename} | {torrent.size} | {torrent.seeders} SE | {torrent.leechers} LE | {torrent.date} | {torrent.source}")
from torrent_search import torrent_search_mcp torrent_search_mcp.run(transport="sse")
This project also includes a FastAPI server as an alternative way to interact with the library 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:
# With Python python -m torrent_search --mode fastapi # With uv uv run -m torrent_search --mode fastapi
--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).
Usable with any MCP-compatible client. Available tools:
search_torrents: Search for torrents.get_torrent_info: Get info for a specific torrent by id.get_magnet_link_or_torrent_file: Get the magnet link or torrent file for a specific torrent by id.Configuration:
{ "mcpServers": { ... # with stdio (only requires uv) "torrent-search-mcp": { "command": "uvx", "args": [ "torrent-search-mcp" ], "env": { "YGG_PASSKEY": "your_passkey_here" } # optional }, # with docker (only requires docker) "torrent-search-mcp": { "command": "docker", "args": [ "run", "-i", "-p", "8000:8000", "-e", "YGG_PASSKEY=your_passkey_here", "philogicae/torrent-search-mcp:latest", "torrent-search-mcp" ] }, # with sse transport (requires installation) "torrent-search-mcp": { "serverUrl": "http://127.0.0.1:8000/sse" }, # with streamable-http transport (requires installation) "torrent-search-mcp": { "serverUrl": "http://127.0.0.1:8000/mcp" # not yet supported by every client }, ... } }
See CHANGELOG.md for a history of changes to this project.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.