Skip to main content
Glama

player_play

Play media files or URLs using mpv, launching the player automatically if needed. Optionally append to the current playlist.

Instructions

Open and play a media file or URL. If mpv is not running, it will be launched automatically.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute file path or URL (http/https/rtmp etc.)
appendNoAppend to current playlist instead of replacing it

Implementation Reference

  • Tool definition and input schema for player_play: accepts path (string, required) and append (boolean, optional).
    {
      name: "player_play",
      description:
        "Open and play a media file or URL. If mpv is not running, it will be launched automatically.",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description: "Absolute file path or URL (http/https/rtmp etc.)",
          },
          append: {
            type: "boolean",
            description: "Append to current playlist instead of replacing it",
            default: false,
          },
        },
        required: ["path"],
      },
    },
  • Handler for player_play: ensures mpv is running, loads the file (replacing or appending to playlist), focuses the window for video files, and ensures playback is not paused.
    case "player_play": {
      await ensureMpv();
      const flag = args.append ? "append-play" : "replace";
      await mpv("loadfile", [args.path, flag]);
    
      // If it's a video file, bring mpv window to foreground
      const VIDEO_EXTS = new Set([
        "mp4","mkv","avi","mov","wmv","flv","webm","m4v",
        "mpg","mpeg","ts","rmvb","3gp","ogv","hevc"
      ]);
      const ext = args.path.split(".").pop().toLowerCase().split("?")[0];
      if (VIDEO_EXTS.has(ext)) {
        // Wait for mpv to open the video window, then restore + focus
        await new Promise((r) => setTimeout(r, 800));
        await mpv("focus").catch(() => null);
        spawn("powershell", ["-NoProfile", "-NonInteractive", "-Command",
          "(New-Object -ComObject Shell.Application).Windows() | ForEach-Object { if ($_.FullName -like '*mpv*') { $_.Visible = $true } };" +
          "$wshell = New-Object -ComObject wscript.shell;" +
          "$wshell.AppActivate('mpv')"
        ], { detached: true, stdio: "ignore" }).unref();
      }
    
      await setProperty("pause", false);
      return ok(`Playing: ${args.path}`);
    }
  • index.js:724-728 (registration)
    MCP server request handlers: ListToolsRequestSchema returns the TOOLS array (which includes player_play), and CallToolRequestSchema dispatches to handleTool which handles the player_play case.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
    
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
      return handleTool(name, args || {});
  • Helper function that sends IPC commands to mpv via named pipe; used by the player_play handler to send 'loadfile' and 'focus' commands.
    async function mpv(command, args = []) {
      return ipcCommand({ command: [command, ...args], request_id: reqId++ });
  • Helper that ensures mpv is running before playback; starts mpv with IPC server if not already running, used by player_play handler.
    async function ensureMpv(filePath = null) {
      const running = await isMpvRunning();
      if (running) return { started: false };
    
      const args = [
        "--input-ipc-server=" + PIPE_PATH,
        "--idle=yes",
        "--keep-open=yes",
        "--no-terminal",
      ];
      if (filePath) args.push(filePath);
    
      const proc = spawn(MPV_BINARY, args, {
        detached: true,
        stdio: "ignore",
        windowsHide: false,
      });
      proc.unref();
    
      // Wait for pipe to be ready
      for (let i = 0; i < 20; i++) {
        await new Promise((r) => setTimeout(r, 250));
        if (await isMpvRunning()) return { started: true };
      }
      throw new Error(
        "mpv failed to start. Make sure mpv is installed and in PATH, or set MPV_PATH environment variable."
      );
Behavior3/5

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

With no annotations, the description carries the full burden. It discloses automatic launch of mpv but omits details on error handling, blocking behavior, or side effects like replacing the current playlist (only vaguely implied by the append parameter).

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 extremely concise (two sentences) with the primary purpose front-loaded. No wasted words.

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

Completeness4/5

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

The description covers the core action and automatic launch behavior. Though it could explicitly mention what happens to current playback or error cases, it is largely complete for a simple playback tool with no output schema.

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 baseline is 3. The description adds no additional meaning beyond what the schema already provides for 'path' and 'append'.

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 tool's function: 'Open and play a media file or URL'. It also adds a distinguishing detail (launching mpv automatically) that sets it apart from sibling tools like player_pause or player_stop.

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 starting playback but does not provide explicit guidance on when to choose this tool over siblings (e.g., player_next, player_seek). It lacks exclusion criteria or alternative descriptions.

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