create-playlist.ts•1.59 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
export function registerCreatePlaylistPrompt(server: McpServer) {
server.registerPrompt(
"create_themed_playlist",
{
title: "Create Themed Playlist",
description: "Create a new playlist based on a theme, mood, or activity",
argsSchema: {
theme: z.string().describe("Theme or mood for the playlist (e.g., 'Workout', 'Study', 'Road Trip', 'Party')"),
size: z.string().optional().describe("Number of tracks (default: 20)")
}
},
async ({ theme, size }) => {
const trackCount = size || "20";
const promptText = `Create a ${theme} playlist with approximately ${trackCount} songs. Please:
1. Search for popular and fitting tracks for a ${theme} playlist using search_tracks with relevant keywords
2. Use get_recommendations with appropriate genres and mood parameters to find more similar songs
(Note: recommendations now use search-based discovery with genre filters and tags like 'tag:new' for variety)
3. Create a new playlist called "${theme} Mix" using create_playlist
4. Add the found tracks to the playlist using add_tracks_to_playlist
5. Show me the final playlist with all added tracks
Tip: For ${theme}, consider using relevant genre filters and mood-based search terms to get the best matches.`;
return {
messages: [
{
role: "user",
content: {
type: "text",
text: promptText,
},
},
],
};
}
);
}