Skip to main content
Glama
dabidstudio

YouTube Insights MCP Server

by dabidstudio

get_channel_info

Extract YouTube channel details and 10 recent videos from any video URL. Retrieve channel metadata and upload history for content analysis and research.

Instructions

Get channel information and 10 recent videos from a YouTube video URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
video_urlYes

Implementation Reference

  • The main handler function for the 'get_channel_info' tool. It extracts a video ID from a YouTube URL, fetches channel information via YouTube Data API, and retrieves the 10 most recent videos from the channel's RSS feed. Returns channel metadata including title, subscriber count, view count, and recent videos.
    @mcp.tool()
    def get_channel_info(video_url: str) -> dict:
        """Get channel information and 10 recent videos from a YouTube video URL"""
        def extract_video_id(url):
            match = re.search(r"(?:v=|\/)([0-9A-Za-z_-]{11})", url)
            return match.group(1) if match else None
    
        def fetch_recent_videos(channel_id):
            rss_url = f"https://www.youtube.com/feeds/videos.xml?channel_id={channel_id}"
            try:
                response = httpx.get(rss_url)
                if response.status_code != 200:
                    return []
    
                root = ET.fromstring(response.text)
                ns = {'atom': 'http://www.w3.org/2005/Atom'}
                videos = []
    
                for entry in root.findall('.//atom:entry', ns)[:10]:
                    title = entry.find('./atom:title', ns).text
                    link = entry.find('./atom:link', ns).attrib['href']
                    published = entry.find('./atom:published', ns).text
                    videos.append({
                        'title': title,
                        'link': link,
                        'published': published,
                        'updatedDate': datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                    })
    
                return videos
            except Exception:
                return []
    
        video_id = extract_video_id(video_url)
        if not video_id:
            raise ValueError("Invalid YouTube URL")
    
        video_api = f"{YOUTUBE_API_URL}/videos?part=snippet,statistics&id={video_id}&key={YOUTUBE_API_KEY}"
        video_response = httpx.get(video_api)
        video_response.raise_for_status()
        video_data = video_response.json()
        if not video_data.get('items'):
            raise ValueError("No video found")
    
        video_info = video_data['items'][0]
        channel_id = video_info['snippet']['channelId']
    
        channel_api = f"{YOUTUBE_API_URL}/channels?part=snippet,statistics&id={channel_id}&key={YOUTUBE_API_KEY}"
        channel_response = httpx.get(channel_api)
        channel_response.raise_for_status()
        channel_data = channel_response.json()['items'][0]
    
        return {
            'channelTitle': channel_data['snippet']['title'],
            'channelUrl': f"https://www.youtube.com/channel/{channel_id}",
            'subscriberCount': channel_data['statistics'].get('subscriberCount', '0'),
            'viewCount': channel_data['statistics'].get('viewCount', '0'),
            'videoCount': channel_data['statistics'].get('videoCount', '0'),
            'videos': fetch_recent_videos(channel_id)
        }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. Mentions the '10 recent videos' limit (useful behavioral scope), but omits safety flags (read-only status), rate limits, or error handling for invalid URLs. The 'Get' prefix implies read-only but explicit confirmation would help.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, 11 words with zero redundancy. Main verb and resource front-loaded. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With only one parameter and no output schema, the description adequately covers the core function. However, given zero schema descriptions and no annotations, it should explicitly state the derivation logic (channel extracted from video) and mention the return structure beyond just the 10-video inclusion.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 0% description coverage for the video_url parameter. Description adds critical context by specifying this must be a 'YouTube video URL,' which is not evident from the schema title 'Video Url' alone. However, it does not clarify that the channel is derived/extracted from this video URL.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States specific action (Get) and resource (channel information and 10 recent videos) clearly. Distinguishes from sibling tools implicitly by targeting channel data rather than transcripts (get_youtube_transcript) or search results (search_youtube_videos). However, slightly ambiguous about whether input expects a channel URL or derives channel from video URL.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides no guidance on when to select this tool versus siblings. Does not clarify that this should be used when the user has a specific video URL and wants the containing channel's info, as opposed to searching or getting captions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/dabidstudio/youtubeinsights-mcp-server'

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