本项目提供了一个Python API和一个MCP(模型上下文协议)服务器,用于在ThePirateBay、Nyaa和YggTorrent上以编程方式搜索种子。它便于集成到其他应用程序或服务中。
如何与MCP客户端一起使用 使用Docker运行以绕过常见的DNS问题
uv(用于本地开发)如果您想与YggTorrent进行交互,此应用程序需要一个通行证密钥。
Mon compte -> PASSKEY字段。.env文件。应用程序将自动加载它。有关所有可用选项,请参阅.env.example。选择以下其中一种安装方法。
此方法最适合将该包作为库使用或在不修改代码的情况下运行服务器。
pip install torrent-search-mcp
crawl4ai-setup # 用于crawl4ai/playwright
playwright install --with-deps chromium # 如果上一个命令失败
.env文件,并添加您的通行证密钥(可选):YGG_PASSKEY=your_passkey_here
python -m torrent_search
此方法适用于想要修改源代码的贡献者。
使用 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
此方法使用Docker在容器中运行服务器。
compose.yaml配置为绕过DNS问题(使用 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")
本项目还包含一个FastAPI服务器,作为通过标准HTTP API与库进行交互的另一种方式。这对于直接API调用、与其他Web服务集成或用于测试目的非常有用。
运行FastAPI服务器:
# 使用Python运行
python -m torrent_search --mode fastapi
# 使用uv运行
uv run -m torrent_search --mode fastapi
--host :默认值:0.0.0.0。--port
:默认值:8000。--reload:启用代码更改时自动重新加载(适用于开发)。--workers :默认值:1。FastAPI服务器将在 http:// 上可用。
可用端点: FastAPI服务器提供与MCP服务器类似的功能。主要端点包括:
/:一个简单的健康检查端点。返回 {"status": "ok"}。/docs:交互式API文档(Swagger UI)。/redoc:替代API文档(ReDoc)。环境变量(如 YGG_PASSKEY)的配置方式与MCP服务器相同(通过项目根目录中的 .env 文件)。
可与任何兼容MCP的客户端一起使用。可用工具:
search_torrents:搜索种子。get_torrent_info:通过ID获取特定种子的信息。get_magnet_link_or_torrent_file:通过ID获取特定种子的磁力链接或种子文件。配置:
{
"mcpServers": {
...
# 使用标准输入输出(仅需要uv)
"torrent-search-mcp": {
"command": "uvx",
"args": [ "torrent-search-mcp" ],
"env": { "YGG_PASSKEY": "your_passkey_here" } # 可选
},
# 使用服务器发送事件传输(需要安装)
"torrent-search-mcp": {
"serverUrl": "http://127.0.0.1:8000/sse"
},
# 使用可流式HTTP传输(并非每个客户端都支持)
"torrent-search-mcp": {
"serverUrl": "http://127.0.0.1:8000/mcp"
},
...
}
}
请参阅 CHANGELOG.md 以了解本项目的更改历史。
欢迎贡献代码!请打开一个问题或提交一个拉取请求。
本项目采用MIT许可证 - 有关详细信息,请参阅 LICENSE 文件。