|
| 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