discover-music.ts•1.8 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
export function registerDiscoverMusicPrompt(server: McpServer) {
server.registerPrompt(
"discover_music",
{
title: "Discover New Music",
description: "Get personalized music recommendations based on your preferences and current listening",
argsSchema: {
mood: z.string().optional().describe("Desired mood (e.g., energetic, chill, happy, sad)"),
genre: z.string().optional().describe("Preferred genre")
}
},
async ({ mood, genre }) => {
let promptText = "Help me discover new music";
if (mood || genre) {
promptText += " that is";
if (mood) promptText += ` ${mood}`;
if (mood && genre) promptText += " and";
if (genre) promptText += ` in the ${genre} genre`;
}
promptText += ". Please:\n";
promptText += "1. Use get_recently_played to see what I've been listening to recently\n";
promptText += "2. Use get_recommendations with use_recent_listening=true to get recommendations based on my recent listening";
if (mood) {
promptText += ` and adjust target_energy, target_danceability, and target_valence for a ${mood} mood`;
}
if (genre) {
promptText += ` and include seed_genres=['${genre}']`;
}
promptText += "\n3. Show me the top recommendations with artist and album details";
promptText += "\n\nNote: Recommendations use Spotify's search API with smart filters based on your listening history.";
return {
messages: [
{
role: "user",
content: {
type: "text",
text: promptText,
},
},
],
};
}
);
}