Skip to main content
Glama

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
NameRequiredDescriptionDefault
playlistIdYesThe YouTube playlist ID
maxResultsNoMaximum number of results to return

Implementation Reference

  • Core handler that fetches playlist items from YouTube API v3
    async 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)}`); } }
  • Type definition for input parameters of getPlaylistItems
    export interface PlaylistItemsParams { playlistId: string; maxResults?: number; }
  • Registers the tool with MCP server, defines input schema using Zod, and provides thin handler delegating to PlaylistService
    server.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) }] }; } );

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