get_youtube_channel
Retrieve YouTube channel data by handle or @username to access profiles, videos, and engagement metrics for analysis.
Instructions
Get YouTube channel data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| handle | Yes | YouTube channel handle or @username |
Implementation Reference
- src/index.ts:487-497 (handler)The core handler logic for the 'get_youtube_channel' tool. It extracts the 'handle' argument, makes an API request to the Sociavault YouTube channel endpoint, processes the response using the extractYouTubeChannel helper, and returns the structured data as JSON text.if (name === "get_youtube_channel") { const { handle } = args as { handle: string }; const response = await axios.get(`${BASE_URL}/youtube/channel`, { headers: { "X-API-Key": API_KEY }, params: { handle }, }); const extracted = extractYouTubeChannel(response.data); return { content: [{ type: "text", text: JSON.stringify(extracted, null, 2) }], }; }
- src/index.ts:303-312 (schema)Input schema definition for the 'get_youtube_channel' tool, specifying an object with a required 'handle' string parameter.inputSchema: { type: "object", properties: { handle: { type: "string", description: "YouTube channel handle or @username", }, }, required: ["handle"], },
- src/index.ts:300-313 (registration)Registration of the 'get_youtube_channel' tool in the MCP tools array, including name, description, and input schema.{ name: "get_youtube_channel", description: "Get YouTube channel data", inputSchema: { type: "object", properties: { handle: { type: "string", description: "YouTube channel handle or @username", }, }, required: ["handle"], }, },
- src/index.ts:153-170 (helper)Helper function that extracts and structures YouTube channel information from the raw API response data.function extractYouTubeChannel(data: any) { const channel = data?.data?.channel || data?.channel || data?.data || {}; const snippet = channel.snippet || {}; const statistics = channel.statistics || {}; return { title: snippet.title || channel.title, description: snippet.description || channel.description || "", subscribers: parseInt(statistics.subscriberCount || statistics.subscribers || "0") || 0, videos: parseInt(statistics.videoCount || "0") || 0, views: parseInt(statistics.viewCount || "0") || 0, custom_url: channel.customUrl || snippet.customUrl, thumbnail: snippet.thumbnails?.high?.url || snippet.thumbnails?.default?.url, published_at: snippet.publishedAt || channel.publishedAt, }; }