playlist_create
Create a new playlist for mpv media player by specifying a name and an array of absolute file paths or URLs. Organize media files for playback through natural language commands.
Instructions
Create a new playlist with a list of file paths.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Playlist name | |
| files | Yes | Array of absolute file paths or URLs |
Implementation Reference
- index.js:431-445 (schema)Tool schema definition for playlist_create, declaring name, description, and inputSchema with required string 'name' and string array 'files'.
name: "playlist_create", description: "Create a new playlist with a list of file paths.", inputSchema: { type: "object", properties: { name: { type: "string", description: "Playlist name" }, files: { type: "array", items: { type: "string" }, description: "Array of absolute file paths or URLs", }, }, required: ["name", "files"], }, }, - index.js:637-644 (handler)Handler for playlist_create: validates files non-empty, calls writePlaylist helper to write .m3u file, returns success with playlist path.
case "playlist_create": { if (!args.files || args.files.length === 0) return fail("files array cannot be empty"); writePlaylist(args.name, args.files); return ok( `Created playlist "${args.name}" with ${args.files.length} item(s)\nSaved to: ${playlistPath(args.name)}` ); } - index.js:726-729 (registration)MCP registration: the CallToolRequestSchema handler dispatches tool name (including 'playlist_create') to handleTool().
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; return handleTool(name, args || {}); }); - index.js:294-297 (helper)Helper function writePlaylist: writes an M3U playlist file to the playlists directory with #EXTM3U header and each file path on its own line.
function writePlaylist(name, files) { const content = "#EXTM3U\n" + files.join("\n") + "\n"; fs.writeFileSync(playlistPath(name), content, "utf8"); }