Skip to main content
Glama

gen_video

Generate educational explanation videos from text questions and answers, with optional image support, to create instructional content for learning purposes.

Instructions

生成教学讲解视频,生成时间大约需要10到20分钟,根据题目难度来定

Args: question: 问题内容(文本形式),question和questionImages中至少输入一个 answer: 参考答案(文本形式):确保生成的讲解内容准确(可选) question_images: 问题内容(图片形式),输入图片的URL或者base64(可选) answer_images: 参考答案(图片形式),输入图片的URL或者base64(可选) quality: 视频质量,可选值:l(低)、m(中)、h(高),默认为配置的默认质量

Returns: 包含任务ID的字典

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
questionNo
answerNo
question_imagesNo
answer_imagesNo
qualityNom

Implementation Reference

  • Primary MCP tool handler for 'gen_video'. This function is registered via @mcp.tool() decorator, validates inputs, retrieves API key from HTTP headers, and proxies the video generation request to the external Scenext API (https://api.scenext.cn/api/gen_video), returning task ID on success.
    @mcp.tool()
    async def gen_video(
        question: str = "",
        answer: str = "",
        question_images: Optional[List[str]] = None,
        answer_images: Optional[List[str]] = None,
        quality: str = DEFAULT_QUALITY
    ) -> Dict[str, Any]:
        """
        生成教学讲解视频,生成时间大约需要10到20分钟,根据题目难度来定
        
        Args:
            question: 问题内容(文本形式),question和questionImages中至少输入一个
            answer: 参考答案(文本形式):确保生成的讲解内容准确(可选)
            question_images: 问题内容(图片形式),输入图片的URL或者base64(可选)
            answer_images: 参考答案(图片形式),输入图片的URL或者base64(可选)
            quality: 视频质量,可选值:l(低)、m(中)、h(高),默认为配置的默认质量
        
        Returns:
            包含任务ID的字典
        """
        
        # 从请求头获取API KEY
        api_key = get_api_key_from_headers()
        
        if not api_key or api_key == "YOUR_API_KEY":
            return {"error": "请在请求头中提供有效的API Key,支持Authorization: Bearer <token>或X-API-Key: <token>"}
        
        # 验证至少有question或questionImages其中一个
        if not question.strip() and not (question_images and len(question_images) > 0):
            return {"error": "question和questionImages中至少输入一个"}
        
        url = f"{API_BASE_URL}/gen_video"
        headers = {
            "Authorization": f"Bearer {api_key}",
            "Content-Type": "application/json"
        }
    
        data = {
            "question": question,
            "answer": answer,
            "questionImages": question_images or [],
            "answerImages": answer_images or [],
            "quality": quality,
        }
    
        try:
            async with aiohttp.ClientSession() as session:
                async with session.post(url, json=data, headers=headers) as response:
                    if response.status == 200:
                        result = await response.json()
                        logger.info(f"视频生成请求成功: {result}")
                        
                        if result.get("status") == "success":
                            return {
                                "status": "success",
                                "task_id": result.get("data", {}).get("task_id"),
                                "message": "视频生成任务创建成功"
                            }
                        else:
                            return {
                                "error": "API返回错误状态",
                                "details": result
                            }
                    else:
                        error_text = await response.text()
                        logger.error(f"API请求失败: {response.status} - {error_text}")
                        return {
                            "error": f"API请求失败: {response.status}",
                            "details": error_text
                        }
        except aiohttp.ClientError as e:
            logger.error(f"网络请求错误: {e}")
            return {"error": f"网络请求错误: {str(e)}"}
        except Exception as e:
            logger.error(f"未知错误: {e}")
            return {"error": f"未知错误: {str(e)}"}
  • Registration of the gen_video tool using FastMCP's @mcp.tool() decorator.
    @mcp.tool()
  • Input schema defined by function parameters with type hints and detailed docstring describing arguments and return value.
    async def gen_video(
        question: str = "",
        answer: str = "",
        question_images: Optional[List[str]] = None,
        answer_images: Optional[List[str]] = None,
        quality: str = DEFAULT_QUALITY
    ) -> Dict[str, Any]:
        """
        生成教学讲解视频,生成时间大约需要10到20分钟,根据题目难度来定
        
        Args:
            question: 问题内容(文本形式),question和questionImages中至少输入一个
            answer: 参考答案(文本形式):确保生成的讲解内容准确(可选)
            question_images: 问题内容(图片形式),输入图片的URL或者base64(可选)
            answer_images: 参考答案(图片形式),输入图片的URL或者base64(可选)
            quality: 视频质量,可选值:l(低)、m(中)、h(高),默认为配置的默认质量
        
        Returns:
            包含任务ID的字典
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/typing233/scenext-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server