此仓库提供了一个用于 YggTorrent 网站的 Python 封装以及一个 MCP(模型上下文协议)服务器,以编程方式与之交互。这允许轻松地将 YggTorrent 功能集成到其他应用程序或服务中。
<a href="https://glama.ai/mcp/servers/@philogicae/ygg-torrent-mcp"> <img width="380" height="200" src="https://gips1.baidu.com/it/u=3184828045,168793594&fm=3081&app=3181&f=PNG?w=760&h=400" alt="YggTorrent Server MCP 服务器" /> </a>uv(用于本地开发)此应用需要您的 YggTorrent 密钥来与 API 交互。
我的账户 -> PASSKEY 字段。YGG_PASSKEY 环境变量读取密钥。推荐的方式是在项目根目录创建一个 .env 文件。应用会自动加载它。选择以下安装方法之一。
此方法最适合将包作为库使用或不修改代码运行服务器。
pip install ygg-torrent-mcp
.env 文件,并添加您的密钥:YGG_PASSKEY=your_passkey_here
python -m ygg_torrent
此方法适用于希望修改源代码的贡献者。
使用 uv:
git clone https://github.com/philogicae/ygg-torrent-mcp.git
cd ygg-torrent-mcp
uv 安装依赖项:uv sync --locked
cp .env.example .env
uv run -m ygg_torrent
此方法使用 Docker 在容器中运行服务器。
compose.yaml 配置为绕过 DNS 问题(使用 quad9 DNS)。
git clone https://github.com/philogicae/ygg-torrent-mcp.git
cd ygg-torrent-mcp
cp .env.example .env
docker compose up --build -d
docker logs ygg-torrent-mcp -f
from ygg_torrent import ygg_api
results = ygg_api.search_torrents('...')
for torrent in results:
print(f"{torrent.filename} | {torrent.size} | {torrent.seeders} SE | {torrent.leechers} LE | {torrent.downloads} DL | {torrent.date}")
from ygg_torrent import ygg_mcp
ygg_mcp.run(transport="sse")
此项目还包括一个 FastAPI 服务器,作为一种通过标准 HTTP API 与 YggTorrent 功能交互的替代方式。这对于直接 API 调用、与其他 Web 服务集成或测试非常有用。
运行 FastAPI 服务器:
# 使用 Python
python -m ygg_torrent --mode fastapi
# 使用 uv
uv run -m ygg_torrent --mode fastapi
--host <host>:默认值:0.0.0.0。--port <port>:默认值:8000。--reload:当代码更改时启用自动重新加载(对开发有用)。--workers <workers>:默认值:1。FastAPI 服务器将在 http://<host>:<port> 可用。
可用端点: FastAPI 服务器提供了类似于 MCP 服务器的功能。关键端点包括:
/:简单的健康检查端点。返回 {"status": "ok"}。/docs:交互式 API 文档(Swagger UI)。/redoc:替代 API 文档(ReDoc)。环境变量(如 YGG_PASSKEY)的配置方式与 MCP 服务器相同(通过项目根目录中的 .env 文件)。
可用于任何兼容 MCP 的客户端。可用工具:
search_torrents:搜索种子。get_torrent_details:获取特定种子的详细信息。get_magnet_link:获取种子的磁力链接。download_torrent_file:下载种子的 .torrent 文件。配置:
{
"mcpServers": {
...
# 使用标准 I/O(仅需安装 uv)
"ygg-torrent-mcp": {
"command": "uvx",
"args": ["ygg-torrent-mcp"],
"env": { "YGG_PASSKEY": "your_passkey_here" }
}
# 使用服务器发送事件传输(需安装)
"ygg-torrent-mcp": {
"serverUrl": "http://127.0.0.1:8000/sse"
}
# 使用可流式传输的 HTTP 传输(需安装)
"ygg-torrent-mcp": {
"serverUrl": "http://127.0.0.1:8000/mcp" # 并非所有客户端都支持
}
...
}
}
查看 CHANGELOG.md 了解此项目的变更历史。
欢迎贡献!请打开一个问题或提交一个拉取请求。
本项目根据 MIT 许可证发布 - 查看 LICENSE 文件了解详情。