tos_video_info
Retrieve video metadata and details from TOS object storage by specifying bucket name and object key for media processing workflows.
Instructions
获取视频信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket_name | Yes | 存储桶名称 | |
| object_key | Yes | 视频对象键名 |
Implementation Reference
- src/tos_mcp_server/handlers.py:345-377 (handler)The core handler function implementing tos_video_info tool logic. Uses TOS SDK to fetch video information via process='video/info', parses JSON response, handles errors, and returns formatted metadata.async def video_info(args: Dict[str, Any]) -> List[TextContent]: """获取视频信息""" bucket_name = args["bucket_name"] object_key = args["object_key"] try: # 使用 get_object 方法通过 style 参数获取视频信息 # 设置处理参数为 video/info resp = tos_client.get_object(bucket_name, object_key, process="video/info") video_info_data = resp.read().decode('utf-8') # 尝试解析JSON响应 try: video_info_json = json.loads(video_info_data) result = { "bucket": bucket_name, "key": object_key, "video_info": video_info_json, "status": "success" } except json.JSONDecodeError: # 如果不是JSON格式,直接返回原始数据 result = { "bucket": bucket_name, "key": object_key, "video_info": video_info_data, "status": "success", "note": "返回原始格式数据" } return [TextContent(type="text", text=json.dumps(result, indent=2, ensure_ascii=False))] except Exception as e: return [TextContent(type="text", text=f"获取视频信息失败: {str(e)}")]
- src/tos_mcp_server/server.py:316-329 (schema)Input schema validation for tos_video_info tool, defining properties and requirements for bucket_name and object_key parameters.inputSchema={ "type": "object", "properties": { "bucket_name": { "type": "string", "description": "存储桶名称" }, "object_key": { "type": "string", "description": "视频对象键名" } }, "required": ["bucket_name", "object_key"] }
- src/tos_mcp_server/server.py:313-330 (registration)Registers the tos_video_info tool in the MCP server's list_tools() by defining its Tool object with name, description, and schema.Tool( name="tos_video_info", description="获取视频信息", inputSchema={ "type": "object", "properties": { "bucket_name": { "type": "string", "description": "存储桶名称" }, "object_key": { "type": "string", "description": "视频对象键名" } }, "required": ["bucket_name", "object_key"] } )
- src/tos_mcp_server/server.py:361-362 (registration)Tool dispatching logic in call_tool() that routes tos_video_info calls to the video_info handler function.elif name == "tos_video_info": return await video_info(arguments)