Skip to main content
Glama

playlist_remove

Remove a specific file from a saved playlist by providing the playlist name and the 0-based index of the track to delete.

Instructions

Remove a file from a saved playlist by index (0-based).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesPlaylist name
indexYes0-based index to remove

Implementation Reference

  • Schema definition for the playlist_remove tool - requires 'name' (string) and 'index' (number) parameters.
    {
      name: "playlist_remove",
      description: "Remove a file from a saved playlist by index (0-based).",
      inputSchema: {
        type: "object",
        properties: {
          name: { type: "string", description: "Playlist name" },
          index: { type: "number", description: "0-based index to remove" },
        },
        required: ["name", "index"],
      },
  • Handler logic for playlist_remove: reads playlist file, removes the entry at the given 0-based index, writes back the playlist, and also removes the matching entry from the live mpv queue if mpv is running.
    case "playlist_remove": {
      const files = readPlaylist(args.name);
      if (args.index < 0 || args.index >= files.length)
        return fail(`Index ${args.index} out of range (0–${files.length - 1})`);
      const removed = files.splice(args.index, 1);
      writePlaylist(args.name, files);
    
      // Also remove from live mpv queue if running
      if (await isMpvRunning()) {
        const currentPos = await getProperty("playlist-pos").catch(() => null);
        const plCount = await getProperty("playlist-count").catch(() => 0);
        // Find matching entry in mpv's live playlist
        let liveIndex = null;
        for (let i = 0; i < plCount; i++) {
          const entry = await getProperty(`playlist/${i}/filename`).catch(() => null);
          if (entry && (entry === removed[0] || entry.replace(/\\/g, "/") === removed[0].replace(/\\/g, "/"))) {
            liveIndex = i;
            break;
          }
        }
        if (liveIndex !== null) {
          await mpv("playlist-remove", [liveIndex]);
          // If we removed the currently playing track, mpv auto-advances;
          // make sure it's playing (not paused)
          if (liveIndex === currentPos) {
            await setProperty("pause", false);
          }
        }
      }
    
      return ok(`Removed "${removed[0]}" from "${args.name}" (live queue updated)`);
    }
  • index.js:726-729 (registration)
    CallToolRequestSchema handler dispatches all tool calls (including playlist_remove) to the handleTool function via a switch statement.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
      return handleTool(name, args || {});
    });
  • index.js:724-724 (registration)
    ListToolsRequestSchema handler returns the TOOLS array which includes the playlist_remove definition.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
  • Helper functions readPlaylist and writePlaylist used by playlist_remove to read and write .m3u playlist files.
    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("#"));
    }
    
    function writePlaylist(name, files) {
      const content = "#EXTM3U\n" + files.join("\n") + "\n";
      fs.writeFileSync(playlistPath(name), content, "utf8");
    }
Behavior2/5

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

No annotations are provided, so the description must fully convey behavioral traits. It only states removal by index but omits what happens on invalid index, whether the operation is reversible, or any side effects. For a mutation tool, this is insufficient.

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 sentence that efficiently conveys the essential information without any redundancy or waffle.

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 the simplicity of the tool (2 parameters, no output schema), the description is functional but incomplete. It lacks details on return values, error handling, and behavior when inputs are invalid, which would be helpful for an agent.

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 both parameters are well-documented. The description adds the '0-based' detail to the index parameter, which is a minor improvement. However, it does not clarify the name parameter beyond the schema's description.

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 verb 'Remove' and resource 'file from a saved playlist' are clearly stated. The 0-based index specification adds precision. It distinguishes from sibling tools like playlist_delete (deletes entire playlist) and playlist_add.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives such as playlist_delete or player_prev. There is no mention of prerequisites, constraints, or situations where this tool is inappropriate.

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