player_stop
Stop mpv playback and clear the currently loaded media file, allowing a fresh start for the next selection.
Instructions
Stop playback and clear the current file.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "player_stop"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:348-351 (schema)Tool schema definition for player_stop — defines the tool name, description, and empty input schema (no parameters needed).
name: "player_stop", description: "Stop playback and clear the current file.", inputSchema: { type: "object", properties: {} }, }, - index.js:538-542 (handler)Handler implementation for player_stop — ensures mpv is running, sends the 'stop' command via IPC, and returns a success message.
case "player_stop": { await ensureMpv(); await mpv("stop"); return ok("Stopped"); } - index.js:726-728 (registration)MCP server registration — the CallToolRequestSchema handler dispatches tool calls (including 'player_stop') to the handleTool function.
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; return handleTool(name, args || {}); - index.js:222-224 (helper)Helper function that sends IPC commands to mpv via named pipe. Used by the handler to issue the 'stop' command.
async function mpv(command, args = []) { return ipcCommand({ command: [command, ...args], request_id: reqId++ }); } - index.js:243-270 (helper)Helper that ensures the mpv process is running before executing player commands.
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." ); }