playlists_getPlaylistItems
Retrieve video items from a specific YouTube playlist by providing the playlist ID. Use this tool to access and list all videos within any YouTube playlist through the YouTube MCP Server.
Instructions
Get videos in a YouTube playlist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playlistId | Yes | The YouTube playlist ID | |
| maxResults | No | Maximum number of results to return |
Implementation Reference
- src/services/playlist.ts:57-74 (handler)Core handler that fetches playlist items from YouTube API v3async getPlaylistItems({ playlistId, maxResults = 50 }: PlaylistItemsParams): Promise<unknown[]> { try { this.initialize(); const response = await this.youtube.playlistItems.list({ part: ['snippet', 'contentDetails'], playlistId, maxResults }); return response.data.items || []; } catch (error) { throw new Error(`Failed to get playlist items: ${error instanceof Error ? error.message : String(error)}`); } }
- src/types.ts:76-79 (schema)Type definition for input parameters of getPlaylistItemsexport interface PlaylistItemsParams { playlistId: string; maxResults?: number; }
- src/server-utils.ts:265-285 (registration)Registers the tool with MCP server, defines input schema using Zod, and provides thin handler delegating to PlaylistServiceserver.registerTool( 'playlists_getPlaylistItems', { title: 'Get Playlist Items', description: 'Get videos in a YouTube playlist', annotations: { readOnlyHint: true, idempotentHint: true }, inputSchema: { playlistId: z.string().describe('The YouTube playlist ID'), maxResults: z.number().optional().describe('Maximum number of results to return'), }, }, async ({ playlistId, maxResults }) => { const result = await playlistService.getPlaylistItems({ playlistId, maxResults }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } );