Skip to main content
Glama

playlists_getPlaylistItems

Retrieve videos from a YouTube playlist by providing the playlist ID. This tool helps users access and manage playlist content through the YouTube Data API.

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 implementation in PlaylistService that initializes the YouTube API client and fetches playlist items using the playlistItems.list endpoint.
    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)}`); } }
  • Registers the MCP tool 'playlists_getPlaylistItems' with Zod input schema, annotations, and a thin async handler that delegates to PlaylistService.getPlaylistItems and formats the response.
    '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) }] }; } );
  • TypeScript interface defining the input parameters for getPlaylistItems, used by the PlaylistService.
    export interface PlaylistItemsParams { playlistId: string; maxResults?: number; }

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