Skip to main content
Glama

playlist_add

Append multiple files to a specified existing playlist in mpv media player. Provide playlist name and list of file paths to extend the playlist.

Instructions

Add files to an existing playlist.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesPlaylist name
filesYesFiles to append

Implementation Reference

  • Tool definition and input schema for 'playlist_add'. Declares required parameters: name (string) and files (array of strings).
    {
      name: "playlist_add",
      description: "Add files to an existing playlist.",
      inputSchema: {
        type: "object",
        properties: {
          name: { type: "string", description: "Playlist name" },
          files: {
            type: "array",
            items: { type: "string" },
            description: "Files to append",
          },
        },
        required: ["name", "files"],
      },
    },
  • Handler for 'playlist_add' tool. Reads the existing playlist, appends new files, and writes back. Returns a success message with the total count.
    case "playlist_add": {
      const existing = readPlaylist(args.name);
      writePlaylist(args.name, [...existing, ...args.files]);
      return ok(
        `Added ${args.files.length} item(s) to "${args.name}" (total: ${existing.length + args.files.length})`
      );
    }
  • writePlaylist helper - writes an M3U playlist file (with #EXTM3U header) to the playlist directory.
    function writePlaylist(name, files) {
      const content = "#EXTM3U\n" + files.join("\n") + "\n";
      fs.writeFileSync(playlistPath(name), content, "utf8");
    }
  • readPlaylist helper - reads an existing M3U playlist file, strips M3U headers and comments, returns array of file paths.
    function readPlaylist(name) {
      const p = playlistPath(name);
      if (!fs.existsSync(p)) throw new Error(`Playlist "${name}" not found`);
      return fs
        .readFileSync(p, "utf8")
        .split("\n")
        .map((l) => l.trim())
        .filter((l) => l && !l.startsWith("#"));
    }
  • index.js:724-729 (registration)
    Tool registration via MCP SDK - the TOOLS array (containing all tool schemas) is registered via ListToolsRequestSchema handler, and CallToolRequestSchema dispatches to handleTool().
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
    
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
      return handleTool(name, args || {});
    });
Behavior2/5

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

No annotations are provided, so the description must disclose behavior. It indicates a mutation (add) but does not mention whether duplicates are allowed, if files are appended, or what happens if the playlist doesn't exist. This is insufficient for a mutation tool without annotations.

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, concise sentence with no superfluous information. It is front-loaded and efficient.

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?

Given no output schema and no annotations, the description is minimal. It covers the basic purpose but lacks details on error handling, idempotency, or behavior for missing playlists. For a simple mutation, it is just adequate.

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

Parameters3/5

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

Schema coverage is 100%, so the baseline is 3. The description clarifies that files are added to an existing playlist, which adds context beyond the schema but does not elaborate on the parameters themselves.

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 'Add files to an existing playlist' clearly states the action (add) and the resource (files to an existing playlist). It effectively distinguishes from sibling tools like playlist_create (creates new) and playlist_remove (removes files).

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 the playlist must already exist but does not explicitly state this prerequisite or compare with alternatives. It provides minimal guidance on when to use versus playlist_create or playlist_remove.

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/guodaxia9527/mcp-mpv-player'

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