Skip to main content
Glama

get_recommendations

Generate personalized music recommendations using artist, track, or genre seeds to discover new songs on Spotify.

Instructions

Get Spotify recommendations based on seeds
Args:
    seed_artists: Comma-separated artist IDs
    seed_tracks: Comma-separated track IDs
    seed_genres: Comma-separated genres
    limit: Number of recommendations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
seed_artistsNo
seed_tracksNo
seed_genresNo
limitNo

Implementation Reference

  • main.py:72-87 (handler)
    The main handler function for the 'get_recommendations' MCP tool. Decorated with @mcp.tool() for automatic registration and schema inference. Delegates to SpotifyClient.recommendations.
    @mcp.tool()
    async def get_recommendations(
        seed_artists: str = None,
        seed_tracks: str = None,
        seed_genres: str = None,
        limit: int = 20,
    ) -> str:
        """
        Get Spotify recommendations based on seeds
        Args:
            seed_artists: Comma-separated artist IDs
            seed_tracks: Comma-separated track IDs
            seed_genres: Comma-separated genres
            limit: Number of recommendations
        """
        return await client.recommendations(seed_artists, seed_tracks, seed_genres, limit)
  • Helper method in SpotifyClient class that implements the core logic for fetching Spotify recommendations using the spotipy library.
    async def recommendations(
        self,
        seed_artists: Optional[str] = None,
        seed_tracks: Optional[str] = None,
        seed_genres: Optional[str] = None,
        limit: int = 20,
    ) -> dict:
        """
        Get recommendations based on seed artists, tracks, or genres.
        """
        try:
            recommendations = self.sp.recommendations(
                seed_artists=seed_artists,
                seed_tracks=seed_tracks,
                seed_genres=seed_genres,
                limit=limit,
            )
            return recommendations
        except Exception as e:
            return f"Error getting recommendations: {str(e)}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ashwanth1109/mcp-spotify'

If you have feedback or need assistance with the MCP directory API, please join our Discord server