Skip to main content
Glama

add_to_playlist

Add a video to an existing YouTube playlist by providing the playlist ID and video ID (both YouTube IDs, not URLs).

Instructions

Add a video to an existing playlist. Both playlist_id and video_id are YouTube IDs (not URLs).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlist_idYesYouTube playlist ID
video_idYesYouTube video ID to add

Implementation Reference

  • The tool handler for 'add_to_playlist' registered with the MCP server. Calls client.addToPlaylist() and returns a success message with the video and playlist IDs.
    server.tool(
      "add_to_playlist",
      "Add a video to an existing playlist. Both playlist_id and video_id are YouTube IDs (not URLs).",
      addToPlaylistSchema,
      async (args) => {
        await client.addToPlaylist({
          playlistId: args.playlist_id,
          videoId: args.video_id,
        });
        return {
          content: [
            {
              type: "text" as const,
              text: `Added video ${args.video_id} to playlist ${args.playlist_id}`,
            },
          ],
        };
      },
  • Zod schema defining the input parameters for the 'add_to_playlist' tool: playlist_id (YouTube playlist ID) and video_id (YouTube video ID), both strings.
    const addToPlaylistSchema = {
      playlist_id: z.string().describe("YouTube playlist ID"),
      video_id: z.string().describe("YouTube video ID to add"),
    };
  • The registerPlaylistTools function registers both 'create_playlist' and 'add_to_playlist' tools on the MCP server, and is called from src/server.ts line 48.
    export function registerPlaylistTools(server: McpServer, client: YouTubeClient): void {
      server.tool(
        "create_playlist",
        "Create a new playlist on the authenticated channel. Default privacy is 'private'.",
        createPlaylistSchema,
        async (args) => {
          const playlist = await client.createPlaylist({
            title: args.title,
            description: args.description,
            privacyStatus: args.privacy_status,
          });
          return {
            content: [
              {
                type: "text" as const,
                text: `Created ${args.privacy_status} playlist: ${playlist.snippet?.title ?? args.title} (${playlist.id})`,
              },
            ],
          };
        },
      );
    
      server.tool(
        "add_to_playlist",
        "Add a video to an existing playlist. Both playlist_id and video_id are YouTube IDs (not URLs).",
        addToPlaylistSchema,
        async (args) => {
          await client.addToPlaylist({
            playlistId: args.playlist_id,
            videoId: args.video_id,
          });
          return {
            content: [
              {
                type: "text" as const,
                text: `Added video ${args.video_id} to playlist ${args.playlist_id}`,
              },
            ],
          };
        },
      );
    }
  • The YouTubeClient.addToPlaylist() helper method that makes the actual API call to POST /playlistItems with the playlist ID and video resource ID.
    addToPlaylist(input: { playlistId: string; videoId: string }): Promise<unknown> {
      return this.dataPost(
        "/playlistItems",
        { part: "snippet" },
        {
          snippet: {
            playlistId: input.playlistId,
            resourceId: { kind: "youtube#video", videoId: input.videoId },
          },
        },
      );
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It only discloses that parameters should be IDs not URLs, but omits side effects (e.g., duplicate addition), error conditions, prerequisites, or authentication needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no unnecessary words, efficiently conveying the tool's function and a key usage caveat.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple add-video-to-playlist operation, the description covers the basic purpose. However, it lacks typical details like error behavior (e.g., if playlist does not exist) or prerequisites, which would be helpful for comprehensive understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and descriptions are provided, but the description adds a meaningful clarification that both IDs are YouTube IDs (not URLs), which is not explicit in the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add') and the resource ('video to an existing playlist'), differentiating it from siblings like 'create_playlist' which creates new playlists.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you have a playlist and video ID, but does not provide explicit when-to-use or when-not-to-use guidance or alternative tools. Implicit differentiation from 'create_playlist' exists but is not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/miller-joe/youtube-mcp'

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