redfox-tools-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redfox_tools_mcp-0.1.0/.gitignore +6 -0
- redfox_tools_mcp-0.1.0/PKG-INFO +128 -0
- redfox_tools_mcp-0.1.0/README.md +116 -0
- redfox_tools_mcp-0.1.0/pyproject.toml +31 -0
- redfox_tools_mcp-0.1.0/src/redfox_tools_mcp/__init__.py +3 -0
- redfox_tools_mcp-0.1.0/src/redfox_tools_mcp/__main__.py +6 -0
- redfox_tools_mcp-0.1.0/src/redfox_tools_mcp/server.py +115 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: redfox-tools-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: RedFoxHub 工具类 MCP server: 多平台视频/作品下载与素材上传
|
|
5
|
+
Project-URL: Homepage, https://github.com/redfox-data/redfox-mcp
|
|
6
|
+
Project-URL: Website, https://redfox.hk/apis/?source=mcp
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: download,mcp,redfox,tools,upload
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Requires-Dist: redfox-mcp-core>=0.1.0
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# redfox-tools-mcp
|
|
14
|
+
|
|
15
|
+
RedFoxHub 工具类 MCP Server — 多平台作品下载与素材上传共 12 个 MCP 工具,适用于 dsh、Claude Code、Cursor 等任意 MCP 客户端。
|
|
16
|
+
|
|
17
|
+
## 工具(12)
|
|
18
|
+
|
|
19
|
+
| 工具 | 分类 | 说明 |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| `tools_download` | 下载 | 通用解析下载(任意平台作品链接) |
|
|
22
|
+
| `tools_download_douyin` | 下载 | 抖音作品下载 |
|
|
23
|
+
| `tools_download_kuaishou` | 下载 | 快手作品下载 |
|
|
24
|
+
| `tools_download_xiaohongshu` | 下载 | 小红书作品下载 |
|
|
25
|
+
| `tools_download_bilibili` | 下载 | B 站作品下载 |
|
|
26
|
+
| `tools_download_wechat_channels` | 下载 | 微信视频号作品下载 |
|
|
27
|
+
| `tools_download_tiktok` | 下载 | TikTok 作品下载 |
|
|
28
|
+
| `tools_download_youtube` | 下载 | YouTube 视频下载 |
|
|
29
|
+
| `tools_download_instagram` | 下载 | Instagram 作品下载 |
|
|
30
|
+
| `tools_download_twitter` | 下载 | X(Twitter) 作品下载 |
|
|
31
|
+
| `tools_upload_image` | 上传 | 上传图片(png/jpeg/webp),返回 URL |
|
|
32
|
+
| `tools_upload_file` | 上传 | 上传文件(视频≤50MB / 音频≤20MB / 图像≤10MB) |
|
|
33
|
+
|
|
34
|
+
上传类工具接收**本地文件路径**,由 server 打开文件后交给 SDK 上传。
|
|
35
|
+
|
|
36
|
+
## 认证
|
|
37
|
+
|
|
38
|
+
1. 前往 <https://redfox.hk/settings/api-keys?source=mcp> 获取 API Key
|
|
39
|
+
2. 设置环境变量:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
export REDFOX_API_KEY="YOUR_API_KEY"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
未配置 key 时,每个工具都会返回结构化的获取引导。
|
|
46
|
+
|
|
47
|
+
## 安装与运行(本地 stdio)
|
|
48
|
+
|
|
49
|
+
需要 Python ≥ 3.10,推荐使用 [uv](https://docs.astral.sh/uv/):
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uvx redfox-tools-mcp
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
或:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install redfox-tools-mcp
|
|
59
|
+
redfox-tools-mcp
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 客户端配置
|
|
63
|
+
|
|
64
|
+
Claude Code:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
claude mcp add redfox-tools --env REDFOX_API_KEY=YOUR_API_KEY -- uvx redfox-tools-mcp
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Cursor / 其他 MCP 客户端:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcpServers": {
|
|
75
|
+
"redfox-tools": {
|
|
76
|
+
"command": "uvx",
|
|
77
|
+
"args": ["redfox-tools-mcp"],
|
|
78
|
+
"env": { "REDFOX_API_KEY": "YOUR_API_KEY" }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 远程 HTTP 模式(多租户)
|
|
85
|
+
|
|
86
|
+
适用于 MCP 市场与托管场景,每个用户携带自己的 API Key:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
redfox-tools-mcp --transport http --host 0.0.0.0 --port 8000
|
|
90
|
+
# 或环境变量:REDFOX_MCP_TRANSPORT=http REDFOX_MCP_HOST=0.0.0.0 REDFOX_MCP_PORT=8000
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- MCP 端点:`http://<host>:8000/mcp`(Streamable HTTP);健康检查:`GET /health`
|
|
94
|
+
- 每个请求通过请求头 `X-API-Key: <key>`(或 `Authorization: Bearer <key>`)携带自己的 key,按 key 建独立客户端缓存,额度互不共享
|
|
95
|
+
- 注意:上传类工具读取的是 **server 所在机器**的本地文件路径,远程模式下请先将文件放到服务端可访问的路径
|
|
96
|
+
|
|
97
|
+
客户端配置(远程 URL + 请求头):
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"mcpServers": {
|
|
102
|
+
"redfox-tools": {
|
|
103
|
+
"url": "http://<host>:8000/mcp",
|
|
104
|
+
"headers": { "X-API-Key": "ak_your_key" }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Docker 部署
|
|
111
|
+
|
|
112
|
+
本包目录自带 Dockerfile,可独立构建部署:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
cd packages/redfox-tools-mcp
|
|
116
|
+
docker build -t redfox-tools-mcp .
|
|
117
|
+
docker run -d -p 8000:8000 redfox-tools-mcp
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
镜像不内置任何 API Key,调用方通过请求头携带自己的 key。
|
|
121
|
+
|
|
122
|
+
## 底层实现
|
|
123
|
+
|
|
124
|
+
基于官方 SDK [redfox-python-sdk](https://github.com/redfox-data/redfox-python-sdk)。API 文档:<https://redfox.hk/?source=mcp>。
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# redfox-tools-mcp
|
|
2
|
+
|
|
3
|
+
RedFoxHub 工具类 MCP Server — 多平台作品下载与素材上传共 12 个 MCP 工具,适用于 dsh、Claude Code、Cursor 等任意 MCP 客户端。
|
|
4
|
+
|
|
5
|
+
## 工具(12)
|
|
6
|
+
|
|
7
|
+
| 工具 | 分类 | 说明 |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `tools_download` | 下载 | 通用解析下载(任意平台作品链接) |
|
|
10
|
+
| `tools_download_douyin` | 下载 | 抖音作品下载 |
|
|
11
|
+
| `tools_download_kuaishou` | 下载 | 快手作品下载 |
|
|
12
|
+
| `tools_download_xiaohongshu` | 下载 | 小红书作品下载 |
|
|
13
|
+
| `tools_download_bilibili` | 下载 | B 站作品下载 |
|
|
14
|
+
| `tools_download_wechat_channels` | 下载 | 微信视频号作品下载 |
|
|
15
|
+
| `tools_download_tiktok` | 下载 | TikTok 作品下载 |
|
|
16
|
+
| `tools_download_youtube` | 下载 | YouTube 视频下载 |
|
|
17
|
+
| `tools_download_instagram` | 下载 | Instagram 作品下载 |
|
|
18
|
+
| `tools_download_twitter` | 下载 | X(Twitter) 作品下载 |
|
|
19
|
+
| `tools_upload_image` | 上传 | 上传图片(png/jpeg/webp),返回 URL |
|
|
20
|
+
| `tools_upload_file` | 上传 | 上传文件(视频≤50MB / 音频≤20MB / 图像≤10MB) |
|
|
21
|
+
|
|
22
|
+
上传类工具接收**本地文件路径**,由 server 打开文件后交给 SDK 上传。
|
|
23
|
+
|
|
24
|
+
## 认证
|
|
25
|
+
|
|
26
|
+
1. 前往 <https://redfox.hk/settings/api-keys?source=mcp> 获取 API Key
|
|
27
|
+
2. 设置环境变量:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
export REDFOX_API_KEY="YOUR_API_KEY"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
未配置 key 时,每个工具都会返回结构化的获取引导。
|
|
34
|
+
|
|
35
|
+
## 安装与运行(本地 stdio)
|
|
36
|
+
|
|
37
|
+
需要 Python ≥ 3.10,推荐使用 [uv](https://docs.astral.sh/uv/):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uvx redfox-tools-mcp
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
或:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install redfox-tools-mcp
|
|
47
|
+
redfox-tools-mcp
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 客户端配置
|
|
51
|
+
|
|
52
|
+
Claude Code:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
claude mcp add redfox-tools --env REDFOX_API_KEY=YOUR_API_KEY -- uvx redfox-tools-mcp
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Cursor / 其他 MCP 客户端:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"redfox-tools": {
|
|
64
|
+
"command": "uvx",
|
|
65
|
+
"args": ["redfox-tools-mcp"],
|
|
66
|
+
"env": { "REDFOX_API_KEY": "YOUR_API_KEY" }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 远程 HTTP 模式(多租户)
|
|
73
|
+
|
|
74
|
+
适用于 MCP 市场与托管场景,每个用户携带自己的 API Key:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
redfox-tools-mcp --transport http --host 0.0.0.0 --port 8000
|
|
78
|
+
# 或环境变量:REDFOX_MCP_TRANSPORT=http REDFOX_MCP_HOST=0.0.0.0 REDFOX_MCP_PORT=8000
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- MCP 端点:`http://<host>:8000/mcp`(Streamable HTTP);健康检查:`GET /health`
|
|
82
|
+
- 每个请求通过请求头 `X-API-Key: <key>`(或 `Authorization: Bearer <key>`)携带自己的 key,按 key 建独立客户端缓存,额度互不共享
|
|
83
|
+
- 注意:上传类工具读取的是 **server 所在机器**的本地文件路径,远程模式下请先将文件放到服务端可访问的路径
|
|
84
|
+
|
|
85
|
+
客户端配置(远程 URL + 请求头):
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"mcpServers": {
|
|
90
|
+
"redfox-tools": {
|
|
91
|
+
"url": "http://<host>:8000/mcp",
|
|
92
|
+
"headers": { "X-API-Key": "ak_your_key" }
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Docker 部署
|
|
99
|
+
|
|
100
|
+
本包目录自带 Dockerfile,可独立构建部署:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
cd packages/redfox-tools-mcp
|
|
104
|
+
docker build -t redfox-tools-mcp .
|
|
105
|
+
docker run -d -p 8000:8000 redfox-tools-mcp
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
镜像不内置任何 API Key,调用方通过请求头携带自己的 key。
|
|
109
|
+
|
|
110
|
+
## 底层实现
|
|
111
|
+
|
|
112
|
+
基于官方 SDK [redfox-python-sdk](https://github.com/redfox-data/redfox-python-sdk)。API 文档:<https://redfox.hk/?source=mcp>。
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "redfox-tools-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "RedFoxHub 工具类 MCP server: 多平台视频/作品下载与素材上传"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
keywords = ["mcp", "redfox", "tools", "download", "upload"]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"redfox-mcp-core>=0.1.0",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://github.com/redfox-data/redfox-mcp"
|
|
19
|
+
Website = "https://redfox.hk/apis/?source=mcp"
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
redfox-tools-mcp = "redfox_tools_mcp.server:main"
|
|
23
|
+
|
|
24
|
+
[tool.uv.sources]
|
|
25
|
+
redfox-mcp-core = { workspace = true }
|
|
26
|
+
|
|
27
|
+
[tool.hatch.build.targets.wheel]
|
|
28
|
+
packages = ["src/redfox_tools_mcp"]
|
|
29
|
+
|
|
30
|
+
[tool.hatch.build.targets.sdist]
|
|
31
|
+
include = ["src/redfox_tools_mcp", "README.md"]
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""RedFox 工具类 MCP Server
|
|
2
|
+
|
|
3
|
+
将 RedFoxHub(红狐数据平台)的多平台作品下载与素材上传能力暴露为 MCP 工具。
|
|
4
|
+
|
|
5
|
+
认证:stdio 模式读环境变量 REDFOX_API_KEY;HTTP 模式从请求头
|
|
6
|
+
X-API-Key(或 Authorization: Bearer <key>)取 key。
|
|
7
|
+
获取地址 https://redfox.hk/settings/api-keys?source=mcp
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import Any, Dict
|
|
11
|
+
|
|
12
|
+
from redfox_mcp_core import call, create_server, get_client, serve
|
|
13
|
+
|
|
14
|
+
from redfox_tools_mcp import __version__
|
|
15
|
+
|
|
16
|
+
mcp = create_server("redfox-tools", __version__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _upload(method: str, file: str, format: str) -> Dict[str, Any]:
|
|
20
|
+
"""打开本地文件并把文件句柄交给 SDK 上传方法,异常统一转结构化结果"""
|
|
21
|
+
try:
|
|
22
|
+
handle = open(file, "rb")
|
|
23
|
+
except OSError as e:
|
|
24
|
+
return {"error": "file_error",
|
|
25
|
+
"message": f"无法读取本地文件 {file}:{e}"}
|
|
26
|
+
with handle:
|
|
27
|
+
return call(lambda: getattr(get_client().tools, method),
|
|
28
|
+
file=handle, format=format)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# ─── 下载 ────────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
@mcp.tool()
|
|
34
|
+
def tools_download(url: str) -> Dict[str, Any]:
|
|
35
|
+
"""通用作品下载:传入任意平台作品链接,自动解析返回下载信息。"""
|
|
36
|
+
return call(lambda: get_client().tools.download, url=url)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@mcp.tool()
|
|
40
|
+
def tools_download_douyin(url: str) -> Dict[str, Any]:
|
|
41
|
+
"""抖音作品下载。url 为抖音作品链接(必填)。"""
|
|
42
|
+
return call(lambda: get_client().tools.download_douyin, url=url)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@mcp.tool()
|
|
46
|
+
def tools_download_kuaishou(url: str) -> Dict[str, Any]:
|
|
47
|
+
"""快手作品下载。url 为快手作品链接(必填)。"""
|
|
48
|
+
return call(lambda: get_client().tools.download_kuaishou, url=url)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@mcp.tool()
|
|
52
|
+
def tools_download_xiaohongshu(url: str) -> Dict[str, Any]:
|
|
53
|
+
"""小红书作品下载。url 为小红书作品链接(必填)。"""
|
|
54
|
+
return call(lambda: get_client().tools.download_xiaohongshu, url=url)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@mcp.tool()
|
|
58
|
+
def tools_download_bilibili(url: str) -> Dict[str, Any]:
|
|
59
|
+
"""B 站作品下载。url 为 B 站作品链接(必填)。"""
|
|
60
|
+
return call(lambda: get_client().tools.download_bilibili, url=url)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@mcp.tool()
|
|
64
|
+
def tools_download_wechat_channels(url: str) -> Dict[str, Any]:
|
|
65
|
+
"""微信视频号作品下载。url 为视频号作品链接(必填)。"""
|
|
66
|
+
return call(lambda: get_client().tools.download_wechat_channels, url=url)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@mcp.tool()
|
|
70
|
+
def tools_download_tiktok(url: str) -> Dict[str, Any]:
|
|
71
|
+
"""TikTok 作品下载。url 为 TikTok 作品链接(必填)。"""
|
|
72
|
+
return call(lambda: get_client().tools.download_tiktok, url=url)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@mcp.tool()
|
|
76
|
+
def tools_download_youtube(url: str) -> Dict[str, Any]:
|
|
77
|
+
"""YouTube 视频下载。url 为 YouTube 视频链接(必填)。"""
|
|
78
|
+
return call(lambda: get_client().tools.download_youtube, url=url)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@mcp.tool()
|
|
82
|
+
def tools_download_instagram(url: str) -> Dict[str, Any]:
|
|
83
|
+
"""Instagram 作品下载。url 为 Instagram 帖子/Reel 链接(必填)。"""
|
|
84
|
+
return call(lambda: get_client().tools.download_instagram, url=url)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@mcp.tool()
|
|
88
|
+
def tools_download_twitter(url: str) -> Dict[str, Any]:
|
|
89
|
+
"""X(Twitter) 作品下载。url 为推文链接(必填)。"""
|
|
90
|
+
return call(lambda: get_client().tools.download_twitter, url=url)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# ─── 上传 ────────────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
@mcp.tool()
|
|
96
|
+
def tools_upload_image(file: str, format: str = "png") -> Dict[str, Any]:
|
|
97
|
+
"""上传图片到红狐素材库。file 为本地图片文件路径(必填);
|
|
98
|
+
format:png/jpeg/webp。返回上传后的 URL。"""
|
|
99
|
+
return _upload("upload_image", file, format)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@mcp.tool()
|
|
103
|
+
def tools_upload_file(file: str, format: str = "mp4") -> Dict[str, Any]:
|
|
104
|
+
"""上传文件到红狐素材库(视频≤50MB / 音频≤20MB / 图像≤10MB)。
|
|
105
|
+
file 为本地文件路径(必填);format 为文件扩展名(如 mp4/mp3/png)。
|
|
106
|
+
返回上传后的 URL。"""
|
|
107
|
+
return _upload("upload_file", file, format)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def main() -> None:
|
|
111
|
+
serve(mcp, prog="redfox-tools-mcp", description="RedFox 工具类 MCP server")
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
main()
|