本仓库提供了一个适用于 rqbit 种子客户端的Python API包装器和一个MCP(模型上下文协议)服务器,方便将其集成到其他应用程序或服务中。
本项目为你提供了便捷的方式来使用 rqbit 种子客户端,下面将详细介绍项目的特性、安装步骤和使用方法。
rqbit 种子客户端提供API包装器。list_torrents:列出所有种子及其详细信息。download_torrent:从磁力链接或文件下载种子。get_torrent_details:获取特定种子的详细信息。get_torrent_stats:获取特定种子的统计信息/状态。pause_torrent:暂停种子下载。start_torrent:开始种子下载。forget_torrent:遗忘种子,但保留文件。delete_torrent:删除种子及其文件。本应用程序需要 rqbit 实例的URL。
设置环境变量:将项目根目录下的 .env.example 复制为 .env,并根据你的设置进行编辑。应用程序将自动从 .env 加载变量:
RQBIT_URL:rqbit实例的URL(默认:http://localhost:3030)。RQBIT_HTTP_BASIC_AUTH_USERPASS:如果rqbit实例中设置了基本认证。RQBIT_HTTP_BASIC_AUTH_USERPASS:基本认证的用户名和密码,格式为 username:password。RQBIT_HTTP_API_LISTEN_ADDR:HTTP API的监听地址(例如:0.0.0.0:3030)。RQBIT_UPNP_SERVER_ENABLE:启用或禁用UPnP服务器(例如:true 或 false)。RQBIT_UPNP_SERVER_FRIENDLY_NAME:UPnP服务器的友好名称(例如:rqbit-media)。RQBIT_EXPERIMENTAL_UTP_LISTEN_ENABLE:启用或禁用uTP监听器(默认:false)。你可以选择以下其中一种安装方法:
这种方法适合将该包作为库使用或在不修改代码的情况下运行服务器。
pip install rqbit-mcp
.env 文件,并添加你的 rqbit URL:RQBIT_URL=http://localhost:3030
python -m rqbit_client
这种方法适用于想要修改源代码的贡献者,需要使用 uv:
git clone https://github.com/philogicae/rqbit-mcp.git
cd rqbit-mcp
uv 安装依赖:uv sync --locked
cp .env.example .env
uv run -m rqbit_client
这种方法使用Docker在容器中运行服务器,compose.yaml 包含 rqbit 种子客户端。
git clone https://github.com/philogicae/rqbit-mcp.git
cd rqbit-mcp
cp .env.example .env
docker compose up --build -d
docker logs rqbit-mcp -f
import asyncio
from rqbit_client.wrapper import RqbitClient
async def main():
# 从.env文件中读取RQBIT_URL,若未找到则使用默认值 (http://localhost:3030)
async with RqbitClient() as client:
# 下载种子
magnet_link = "magnet:?xt=urn:btih:..."
torrent = await client.download_torrent(magnet_link)
print(torrent)
# 检查状态
status = await client.get_torrent_stats(torrent["id"])
print(status)
# 列出种子
torrents = await client.list_torrents()
print(torrents)
if __name__ == "__main__":
asyncio.run(main())
from rqbit_client import RqbitMCP
RqbitMCP.run(transport="sse") # 可选择 'stdio', 'sse', 或 'streamable-http'
可与任何兼容MCP的客户端一起使用,可用工具如下:
list_torrents:列出所有种子。download_torrent:通过磁力链接或文件路径下载种子。get_torrent_details:获取特定种子的详细信息。get_torrent_stats:获取特定种子的统计信息/状态。pause_torrent:暂停种子下载。start_torrent:开始种子下载。forget_torrent:遗忘种子,但保留文件。delete_torrent:删除种子及其文件。配置如下:
{
"mcpServers": {
...
# 使用标准输入输出(仅需uv)
"rqbit-mcp": {
"command": "uvx",
"args": [ "rqbit-mcp" ],
"env": {
"RQBIT_URL": "http://localhost:3030", # (可选)默认rqbit实例URL
"RQBIT_HTTP_BASIC_AUTH_USERPASS": "username:password" # (可选)仅在rqbit实例中设置时使用
}
},
# 使用sse传输(需要安装)
"rqbit-mcp": {
"serverUrl": "http://127.0.0.1:8000/sse"
},
# 使用可流式传输的HTTP传输(需要安装)
"rqbit-mcp": {
"serverUrl": "http://127.0.0.1:8000/mcp"
},
...
}
}
有关本项目的变更历史,请查看 CHANGELOG.md。
欢迎贡献代码!请提交问题或拉取请求。
本项目采用MIT许可证,请查看 LICENSE 文件以获取详细信息。