get_channel_details
Retrieve comprehensive YouTube channel details, including metadata and key insights, by inputting the channel ID. Simplify channel analysis with essential data extraction.
Instructions
Get detailed information about a YouTube channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel_id | Yes |
Implementation Reference
- server.py:1012-1052 (handler)MCP tool handler implementing the get_channel_details tool. It uses the YouTubeService helper to fetch raw API data and formats it into a user-friendly response.@mcp.tool( name="get_channel_details", description="Get detailed information about a YouTube channel", ) async def get_channel_details(channel_id: str) -> Dict[str, Any]: """ Get detailed information about a YouTube channel Args: channel_id (str): YouTube channel ID Returns: Dict[str, Any]: Channel details """ try: channel_data = youtube_service.get_channel_details(channel_id) if not channel_data.get('items'): return {'error': f"Channel with ID {channel_id} not found"} channel = channel_data['items'][0] # Format the response details = { 'id': channel.get('id'), 'title': channel.get('snippet', {}).get('title'), 'description': channel.get('snippet', {}).get('description'), 'publishedAt': channel.get('snippet', {}).get('publishedAt'), 'customUrl': channel.get('snippet', {}).get('customUrl'), 'thumbnails': channel.get('snippet', {}).get('thumbnails'), 'subscriberCount': channel.get('statistics', {}).get('subscriberCount'), 'videoCount': channel.get('statistics', {}).get('videoCount'), 'viewCount': channel.get('statistics', {}).get('viewCount'), 'url': f"https://www.youtube.com/channel/{channel_id}" } return details except Exception as e: logger.exception(f"Error in get_channel_details: {e}") return {'error': str(e)}
- server.py:268-282 (helper)Helper method in YouTubeService class that makes the actual YouTube Data API v3 call to retrieve channel details (snippet and statistics).def get_channel_details(self, channel_id: str) -> Dict[str, Any]: """ Get detailed information about a specific YouTube channel """ channel_id = self.parse_url(channel_id) try: response = self.youtube.channels().list( part='snippet,statistics', id=channel_id ).execute() return response except HttpError as e: logger.error(f"Error getting channel details: {e}") raise e
- server.py:672-691 (registration)MCP resource that lists all available tools, including get_channel_details, which clients use to discover tools.@mcp.resource( uri='youtube://available-youtube-tools', name="available-youtube-tools", description="Returns a list of YouTube tools available on this MCP server." ) async def get_available_youtube_tools() -> List[Dict[str, str]]: """Returns a list of YouTube tools available on this MCP server.""" available_tools = [ {"name": "search_videos", "description": "Search for YouTube videos with advanced filtering options"}, {"name": "get_video_details", "description": "Get detailed information about a YouTube video"}, {"name": "get_channel_details", "description": "Get detailed information about a YouTube channel"}, {"name": "get_video_comments", "description": "Get comments for a YouTube video"}, {"name": "get_video_transcript", "description": "Get transcript/captions for a YouTube video"}, {"name": "get_related_videos", "description": "Get videos related to a specific YouTube video"}, {"name": "get_trending_videos", "description": "Get trending videos on YouTube by region"}, {"name": "get_video_enhanced_transcript", "description": "Advanced transcript extraction tool with filtering, search, and multi-video capabilities. Provides rich transcript data for detailed analysis and processing. Features: 1) Extract transcripts from multiple videos; 2) Filter by time ranges; 3) Search within transcripts; 4) Segment transcripts; 5) Format output in different ways; 6) Include video metadata."} ] logger.info(f"Resource 'get_available_youtube_tools' called. Returning {len(available_tools)} tools.") return available_tools