此仓库提供了一个用于在ThePirateBay、Nyaa和YggTorrent上搜索种子的Python API和MCP(模型上下文协议)服务器。它允许轻松地集成到其他应用程序或服务中。
<a href="https://glama.ai/mcp/servers/@philogicae/torrent-search-mcp"> <img width="380" height="200" src="https://gips3.baidu.com/it/u=3790603102,1341216396&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Torrent Search MCP 服务器" /> </a>uv(用于本地开发)如果要与YggTorrent交互,此应用需要通行证密钥。
我的账户 -> PASSKEY字段。.env文件在项目根目录下。应用会自动加载它。参见.env.example了解所有可用选项。选择以下安装方法之一。
此方法最适合将包作为库使用或不修改代码的情况下运行服务器。
pip install torrent-search-mcp
crawl4ai-setup # 对于crawl4ai/playwright
playwright install --with-deps chromium # 如果前一命令失败
.env文件,并添加您的通行证密钥(可选):YGG_PASSKEY=您的通行证密钥
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
结果 = torrent_search_api.search_torrents('...')
for 种子 in 结果:
print(f"{种子.filename} | {种子.size} | {种子.seeders} SE | {种子.leechers} LE | {种子.date} | {种子.source}")
from torrent_search import torrent_search_mcp
torrent_search_mcp.run(transport="sse")
此项目还包括一个FastAPI服务器,作为通过标准HTTP API与库交互的另一种方式。这可用于直接API调用、与其他网络服务集成或测试目的。
运行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。然后可以在http://<主机>:<端口>访问FastAPI服务器
可用端点: FastAPI服务器提供了类似于MCP服务器的功能。关键端点包括:
/:简单的健康检查端点。返回{"状态": "好"}。/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": {
...
// 使用标准I/O(仅需uv)
"torrent-search-mcp": {
"命令": "uvx",
"参数": ["torrent-search-mcp"],
"环境": {"YGG_PASSKEY": "您的通行证密钥"} // 可选
},
// 使用docker(仅需docker)
"torrent-search-mcp": {
"命令": "docker",
"参数": ["run", "-i", "-p", "8000:8000", "-e", "YGG_PASSKEY=您的通行证密钥", "philogicae/torrent-search-mcp:latest", "torrent-search-mcp"]
},
// 使用SSE传输(需要安装)
"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文件了解详情。