playlist_list
Retrieve all saved playlists from mpv player or view the contents of a specific playlist by providing its name.
Instructions
List all saved playlists or show contents of a specific playlist.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Playlist name to inspect (omit to list all playlists) |
Implementation Reference
- index.js:687-696 (handler)Handler for playlist_list: if args.name is provided, reads and lists contents of that playlist; otherwise lists all saved playlist names from the PLAYLIST_DIR directory.
case "playlist_list": { if (args.name) { const files = readPlaylist(args.name); const lines = files.map((f, i) => ` ${i}. ${f}`); return info(`📋 Playlist "${args.name}" (${files.length} items):\n${lines.join("\n")}`); } const playlists = listPlaylists(); if (playlists.length === 0) return info("No playlists found. Use playlist_create to make one."); return info(`📁 Saved playlists (${PLAYLIST_DIR}):\n${playlists.map((p) => ` • ${p}`).join("\n")}`); } - index.js:474-486 (schema)Schema definition for playlist_list tool: optional 'name' string parameter, returns list of playlists or contents of a specific playlist.
{ name: "playlist_list", description: "List all saved playlists or show contents of a specific playlist.", inputSchema: { type: "object", properties: { name: { type: "string", description: "Playlist name to inspect (omit to list all playlists)", }, }, }, }, - index.js:724-729 (registration)Tool registration: TOOLS array is defined at line 321, registered via ListToolsRequestSchema on line 724, and dispatched via handleTool in CallToolRequestSchema on line 726-729.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS })); server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; return handleTool(name, args || {}); }); - index.js:273-278 (helper)Helper function listPlaylists() reads the PLAYLIST_DIR and returns all .m3u file names without extension.
function listPlaylists() { return fs .readdirSync(PLAYLIST_DIR) .filter((f) => f.endsWith(".m3u")) .map((f) => f.replace(".m3u", "")); } - index.js:284-292 (helper)Helper function readPlaylist(name) reads a playlist file by name and returns non-empty, non-comment lines.
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("#")); }