Skip to main content
Glama

summarize_video_story

Extract story summaries and key content from YouTube Shorts videos by analyzing titles, descriptions, themes, and narrative techniques.

Instructions

提炼 YouTube Shorts 视频的故事梗概和核心内容。基于视频标题和描述,分析视频的主题、情节和创作手法。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
video_urlYesYouTube Shorts 视频链接

Implementation Reference

  • Main handler function for summarize_video_story tool. Extracts video ID, fetches video details via YouTubeClient, and formats the video information (title, channel, stats, description) into a structured text response for Claude to analyze and summarize.
    async def summarize_video_story(video_url: str) -> list[TextContent]:
        """
        工具 4 的实现:提炼视频故事梗概
        
        这个工具的巧妙之处:
        1. 我们只负责获取视频的标题和描述
        2. 将这些信息返回给 Claude
        3. Claude 会自动分析并提炼故事梗概
        4. 用户看到的是 Claude 基于视频信息生成的分析
        """
        
        try:
            # 提取视频 ID
            video_id = extract_video_id(video_url)
            
            if not video_id:
                return [TextContent(
                    type="text",
                    text=f"❌ 无效的 YouTube 链接: {video_url}"
                )]
            
            # 获取视频详情
            client = YouTubeClient()
            videos = client.get_video_details([video_id])
            
            if not videos:
                return [TextContent(
                    type="text",
                    text=f"❌ 未找到视频: {video_id}"
                )]
            
            video = videos[0]
            
            # 构建视频信息文本,供 Claude 分析
            info = f"""# 视频信息
    
    **标题**: {video.title}
    
    **频道**: {video.channel_name}
    
    **发布时间**: {video.published_at.strftime('%Y-%m-%d %H:%M UTC')}
    
    **播放量**: {video.views:,}
    
    **点赞数**: {video.likes:,}
    
    **评论数**: {video.comments:,}
    
    **视频链接**: {video.url}
    
    ---
    
    ## 视频描述
    
    {video.description if video.description else '(该视频没有描述)'}
    
    ---
    
    **请基于以上信息,分析这个视频的:**
    1. 主题和核心内容
    2. 可能的故事情节或创作手法
    3. 为什么这个视频可能受欢迎
    4. 适合什么样的观众群体
    """
            
            return [TextContent(type="text", text=info)]
        
        except Exception as e:
            return [TextContent(
                type="text",
                text=f"❌ 获取视频信息失败: {str(e)}"
            )]
  • src/server.py:235-251 (registration)
    Tool registration in list_tools() function. Defines the tool name 'summarize_video_story', description for Claude, and the inputSchema requiring a 'video_url' parameter.
    Tool(
        name="summarize_video_story",
        description=(
            "提炼 YouTube Shorts 视频的故事梗概和核心内容。"
            "基于视频标题和描述,分析视频的主题、情节和创作手法。"
        ),
        inputSchema={
            "type": "object",
            "properties": {
                "video_url": {
                    "type": "string",
                    "description": "YouTube Shorts 视频链接"
                }
            },
            "required": ["video_url"]
        }
    ),
  • src/server.py:344-347 (registration)
    Call routing in call_tool() function. Routes tool calls with name='summarize_video_story' to the summarize_video_story handler function, passing the video_url argument.
    elif name == "summarize_video_story":
        return await summarize_video_story(
            video_url=arguments["video_url"]
        )
  • Helper function extract_video_id() used by summarize_video_story to parse YouTube URLs and extract the video ID using regex patterns for different YouTube URL formats.
    def extract_video_id(url: str) -> Optional[str]:
        """从 YouTube URL 中提取视频 ID"""
        patterns = [
            r'youtube\.com/shorts/([a-zA-Z0-9_-]+)',
            r'youtube\.com/watch\?v=([a-zA-Z0-9_-]+)',
            r'youtu\.be/([a-zA-Z0-9_-]+)',
        ]
        
        for pattern in patterns:
            match = re.search(pattern, url)
            if match:
                return match.group(1)
        
        return None

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/Xeron2000/viral-shorts'

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