get_channel_details
Retrieve comprehensive YouTube channel data including statistics, metadata, and content details to analyze performance and gather insights.
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 function that executes the get_channel_details tool logic by calling the YouTubeService helper, formatting the API response, and handling errors.@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)Supporting utility method in YouTubeService class that performs the actual YouTube Data API v3 call to fetch channel details using channels.list endpoint.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:1012-1014 (registration)The @mcp.tool decorator that registers the get_channel_details tool with name and description.@mcp.tool( name="get_channel_details", description="Get detailed information about a YouTube channel",