Skip to content

Commit 4b4c9d9

Browse files
committed
feat: vod mcp tools support
1 parent 384588f commit 4b4c9d9

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

docs/docs/tools/builtin.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ VeADK 集成了以下火山引擎工具:
7070
| `lark` | 集成[飞书开放能力](https://open.larkoffice.com/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/mcp_installation),实现文档处理、会话管理等。 | `from veadk.tools.builtin_tools.lark import lark` |
7171
| `las` | 基于[火山引擎 AI 多模态数据湖服务 LAS](https://www.volcengine.com/mcp-marketplace) 进行数据管理。 | `from veadk.tools.builtin_tools.las import las` |
7272
| `mobile_run` | 手机指令执行 | `from veadk.tools.builtin_tools.mobile_run import create_mobile_use_tool` |
73+
| `vod` | 视频剪辑助手 | `from veadk.tools.builtin_tools.vod import vod_tools` |
7374

7475
### 公域搜索 (Web Search)
7576

@@ -592,7 +593,82 @@ VeADK 集成了以下火山引擎工具:
592593
运行结果:
593594
![img_2.png](../assets/images/tools/mua_3.png)
594595

596+
### 视频云MCP工具(Vod MCP Tool)
595597

598+
`vod_tools`允许Agent通过调用火山引擎的视频云MCP来进行视频剪辑处理,详情请参考[VOD MCP Server](https://github.com/volcengine/mcp-server/blob/main/server/mcp_server_vod/README_zh.md)
599+
600+
!!! warning "使用 `vod_tools` 的附加要求"
601+
1. 需要配置火山引擎 AK、SK
602+
2. (可选)可以配置`TOOL_VOD_GROUPS`选择多样化的视频剪辑能力。可选范围为:
603+
- `edit`:视频剪辑相关tools
604+
- `intelligent_slicing`: 智能切片相关tools
605+
- `intelligent_matting`: 智能抠图相关tools
606+
- `subtitle_processing`: 字幕处理相关tools
607+
- `audio_processing`: 音频处理相关tools
608+
- `video_enhancement`: 视频增强相关tools
609+
- `upload`: 上传相关
610+
- `video_play`: 视频播放相关
611+
3. (可选)工具连接超时时长`TOOL_VOD_TIMEOUT`,默认为10秒
612+
- 注:如果需要多个工具组,请使用逗号进行连接,如果不进行配置,则默认为`edit,video_play`
613+
- 注:视频云工具不支持Space的创建,请在火山视频云控制台提前创建[视频云空间](https://console.volcengine.com/vod/region:vod+cn-north-1/overview/)
614+
615+
616+
=== "代码"
617+
618+
```python
619+
import asyncio
620+
from veadk import Agent, Runner
621+
from veadk.tools.builtin_tools.vod import vod_tools
622+
agent = Agent(tools=[vod_tools])
623+
runner = Runner(agent)
624+
result = asyncio.run(
625+
runner.run(
626+
messages="将这两个视频合并:<your-url1>, <your-url2>, space_name为<your-space-name",
627+
)
628+
)
629+
print(result)
630+
```
631+
632+
=== "环境变量"
633+
634+
必须配置在环境变量的配置项:
635+
636+
- `VOLCENGINE_ACCESS_KEY`: 火山引擎的AccessKey
637+
- `VOLCENGINE_SECRET_KEY`: 火山引擎的SecretKey
638+
639+
可选环境变量
640+
- TOOL_VOD_GROUPS: 配置能力组
641+
- TOOL_VOD_TIMEOUT: 工具连接超时时长, 默认为10.0秒
642+
643+
或在 `config.yaml` 中定义:
644+
645+
```yaml title="config.yaml"
646+
model:
647+
agent:
648+
provider: openai
649+
name: doubao-seed-1-6-250615
650+
api_base: https://ark.cn-beijing.volces.com/api/v3/
651+
api_key: your-api-key-here
652+
volcengine:
653+
access_key: you-access-key-here
654+
secret_key: you-secret-key-here
655+
tool:
656+
vod:
657+
groups: xxxxx
658+
timeout: 10.0
659+
```
660+
661+
输出结果:
662+
```text
663+
已成功将两个视频合并,合并后的视频信息如下:
664+
- **播放地址**:<url>
665+
- **视频时长**:x秒
666+
- **分辨率**:xxxxx
667+
- **文件名称**:xxxxx.mp4
668+
(注:播放地址有效期为60分钟,若过期可重新生成)
669+
```
670+
671+
注:有些视频编辑任务可能时间开销较大,该类任务会直接返回一个task_id,可以继续询问agent,让其查询task是否完成,从而获得任务后续。
596672

597673
## 系统工具
598674

veadk/tools/builtin_tools/vod.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
17+
from google.adk.tools.mcp_tool import StdioConnectionParams
18+
from google.adk.tools.mcp_tool.mcp_toolset import StdioServerParameters, McpToolset
19+
20+
from veadk.config import getenv
21+
from veadk.utils.logger import get_logger
22+
23+
logger = get_logger(__name__)
24+
25+
26+
def _get_vod_envs() -> dict[str, str]:
27+
"""
28+
note, available `TOOL_VOD_GROUPS`:
29+
"edit", # Tools related to video editing
30+
"intelligent_slicing", # Tools related to intelligent slicing
31+
"intelligent_matting", # Tools related to intelligent matting
32+
"subtitle_processing", # Tools related to subtitle processing
33+
"audio_processing", # Tools related to audio processing
34+
"video_enhancement", # Tools related to video enhancement
35+
'upload', # Related to upload
36+
"video_play" # Related to video playback
37+
https://github.com/volcengine/mcp-server/blob/main/server/mcp_server_vod/src/vod/mcp_server.py#L14
38+
"""
39+
40+
ak = getenv("VOLCENGINE_ACCESS_KEY", None)
41+
sk = getenv("VOLCENGINE_SECRET_KEY", None)
42+
43+
if os.getenv("TOOL_VOD_GROUPS", None):
44+
return {
45+
"VOLCENGINE_ACCESS_KEY": ak,
46+
"VOLCENGINE_SECRET_KEY": sk,
47+
"MCP_TOOL_GROUPS": getenv("TOOL_VOD_GROUPS"),
48+
}
49+
else:
50+
return {
51+
"VOLCENGINE_ACCESS_KEY": ak,
52+
"VOLCENGINE_SECRET_KEY": sk,
53+
}
54+
55+
56+
_vod_envs = _get_vod_envs()
57+
58+
vod_tools = McpToolset(
59+
connection_params=StdioConnectionParams(
60+
server_params=StdioServerParameters(
61+
command="uvx",
62+
args=[
63+
"--from",
64+
"git+https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_vod",
65+
"mcp-server-vod",
66+
],
67+
env=_vod_envs,
68+
),
69+
timeout=float(os.getenv("TOOL_VOD_TIMEOUT", 10.0)),
70+
)
71+
)

0 commit comments

Comments
 (0)