list_my_videos
List your own YouTube videos with details like titles, view counts, and privacy status. Results are sorted newest first, with pagination support.
Instructions
List videos on the authenticated channel (newest first via the uploads playlist). Returns video IDs, titles, view counts, and privacy status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_results | No | ||
| page_token | No |
Implementation Reference
- src/tools/videos.ts:38-56 (handler)The tool registration and handler for 'list_my_videos'. Calls client.listMyUploads() and formats results as text with video IDs, titles, views, and privacy status.
server.tool( "list_my_videos", "List videos on the authenticated channel (newest first via the uploads playlist). Returns video IDs, titles, view counts, and privacy status.", listMyVideosSchema, async (args) => { const res = await client.listMyUploads(args.max_results, args.page_token); const lines = [ `Found ${res.items.length} video(s):`, ...res.items.map((v) => { const title = v.snippet?.title ?? "(untitled)"; const views = v.statistics?.viewCount ?? "0"; const privacy = v.status?.privacyStatus ?? "?"; return ` ${v.id} — ${title} [${views} views, ${privacy}]`; }), res.nextPageToken ? `next page_token: ${res.nextPageToken}` : "(end of results)", ]; return { content: [{ type: "text" as const, text: lines.join("\n") }] }; }, ); - src/tools/videos.ts:5-8 (schema)Input schema for 'list_my_videos': max_results (1-50, default 25) and optional page_token.
const listMyVideosSchema = { max_results: z.number().int().min(1).max(50).default(25), page_token: z.string().optional(), }; - src/server.ts:13-47 (registration)Import and registration of registerVideoTools on the MCP server with the YouTubeClient instance.
import { registerVideoTools } from "./tools/videos.js"; import { registerPlaylistTools } from "./tools/playlists.js"; import { registerCommentTools } from "./tools/comments.js"; import { registerAnalyticsTool } from "./tools/analytics.js"; import { registerCaptionTools } from "./tools/captions.js"; import { registerShortsTools } from "./tools/shorts.js"; import { registerBridgeTools } from "./tools/bridge.js"; export interface ServerConfig { host: string; port: number; clientId: string; clientSecret: string; tokenFile: string; comfyUIUrl?: string; comfyUIDefaultCkpt: string; } interface Session { server: McpServer; transport: StreamableHTTPServerTransport; } function buildContext(config: ServerConfig) { const youtube = new YouTubeClient({ clientId: config.clientId, clientSecret: config.clientSecret, tokenFile: config.tokenFile, }); const comfyui = config.comfyUIUrl ? new ComfyUIClient({ baseUrl: config.comfyUIUrl }) : null; const buildServer = () => { const s = new McpServer({ name: "youtube-mcp", version: "0.1.0" }); registerVideoTools(s, youtube); - src/youtube/client.ts:125-127 (helper)listMyUploads() method that delegates to listMyVideoIdsViaUploadsPlaylist for fetching the authenticated user's uploaded videos.
listMyUploads(maxResults = 25, pageToken?: string): Promise<VideoListResponse> { return this.listMyVideoIdsViaUploadsPlaylist(maxResults, pageToken); } - src/youtube/client.ts:129-158 (helper)listMyVideoIdsViaUploadsPlaylist() fetches the uploads playlist from the channel, retrieves video IDs, then fetches full video details (snippet, status, statistics, contentDetails).
private async listMyVideoIdsViaUploadsPlaylist( maxResults: number, pageToken?: string, ): Promise<VideoListResponse> { const channels = await this.dataGet<{ items: Channel[] }>("/channels", { part: "contentDetails", mine: "true", }); const uploadsPlaylist = channels.items[0]?.contentDetails?.relatedPlaylists?.uploads; if (!uploadsPlaylist) { return { items: [] }; } const playlistItems = await this.dataGet<{ items: Array<{ contentDetails: { videoId: string } }>; nextPageToken?: string; }>("/playlistItems", { part: "contentDetails", playlistId: uploadsPlaylist, maxResults: String(maxResults), pageToken, }); const ids = playlistItems.items.map((i) => i.contentDetails.videoId); if (ids.length === 0) return { items: [], nextPageToken: playlistItems.nextPageToken }; const videos = await this.dataGet<{ items: Video[] }>("/videos", { part: "snippet,status,statistics,contentDetails", id: ids.join(","), }); return { items: videos.items, nextPageToken: playlistItems.nextPageToken }; }