Skip to main content
Glama

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

Implementation Reference

  • 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)}`);
      }
    }
  • 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'],
        },
    },
  • 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)
            }]
        };
    }
Install Server

Other Tools

Related Tools

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/ZubeidHendricks/youtube-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server