playlists_getPlaylistItems
Retrieve video items from a YouTube playlist by specifying the playlist ID. Use this tool to gather playlist content details, supporting structured data retrieval for analysis or integration purposes.
Instructions
Get videos in a YouTube playlist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | Maximum number of results to return | |
| playlistId | Yes | The YouTube playlist ID |
Implementation Reference
- src/services/playlist.ts:57-74 (handler)Core handler function that executes the tool logic by calling the YouTube API playlistItems.list endpoint to retrieve videos in the specified playlist.async getPlaylistItems({ playlistId, maxResults = 50 }: PlaylistItemsParams): Promise<any[]> { 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)TypeScript interface defining the input parameters for the playlists_getPlaylistItems tool.export interface PlaylistItemsParams { playlistId: string; maxResults?: number; }
- src/server.ts:145-162 (registration)Registers the tool in the MCP server's tools list, including name, description, and input schema validation.{ name: 'playlists_getPlaylistItems', description: 'Get videos in a YouTube playlist', inputSchema: { type: 'object', properties: { playlistId: { type: 'string', description: 'The YouTube playlist ID', }, maxResults: { type: 'number', description: 'Maximum number of results to return', }, }, required: ['playlistId'], }, },
- src/server.ts:232-240 (handler)MCP server request handler that dispatches the tool call to the playlistService.getPlaylistItems method and formats the response.case 'playlists_getPlaylistItems': { const result = await playlistService.getPlaylistItems(args as unknown as PlaylistItemsParams); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }