Skip to main content
Glama

channels_getChannel

Retrieve detailed information about a YouTube channel by providing its channel ID to access metadata and statistics.

Instructions

Get information about a YouTube channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYesThe YouTube channel ID

Implementation Reference

  • Core handler function in ChannelService that fetches YouTube channel details using the YouTube Data API v3, calling channels.list with snippet, statistics, and contentDetails parts.
    async getChannel({ 
      channelId 
    }: ChannelParams): Promise<unknown> {
      try {
        this.initialize();
        
        const response = await this.youtube.channels.list({
          part: ['snippet', 'statistics', 'contentDetails'],
          id: [channelId]
        });
    
        return response.data.items?.[0] || null;
      } catch (error) {
        throw new Error(`Failed to get channel: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • MCP tool registration for 'channels_getChannel', defining input schema, description, and handler that delegates to ChannelService.getChannel.
    server.registerTool(
        'channels_getChannel',
        {
            title: 'Get Channel Information',
            description: 'Get information about a YouTube channel',
            annotations: { readOnlyHint: true, idempotentHint: true },
            inputSchema: {
                channelId: z.string().describe('The YouTube channel ID'),
            },
        },
        async ({ channelId }) => {
            const result = await channelService.getChannel({ channelId });
            return {
                content: [{
                    type: 'text',
                    text: JSON.stringify(result, null, 2)
                }]
            };
        }
    );
  • TypeScript interface defining the input parameters for channel operations, used by the ChannelService.getChannel method.
    export interface ChannelParams {
      channelId: string;
    }

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/sfiorini/youtube-mcp'

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