Skip to main content
Glama

get_my_playlists

Retrieve your Spotify playlists to view, manage, or organize your music collections directly within your workflow.

Instructions

FastMCP tool to get user playlists using SpotifyClient.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler method in SpotifyClient class that fetches the current user's playlists from Spotify API using spotipy, formats them, and returns as a string.
    async def get_my_playlists(self) -> str: """ Get all playlists for the current user. """ try: results = self.sp.current_user_playlists() if not results["items"]: return "No playlists found." playlists = [] for item in results["items"]: name = item["name"].encode("ascii", "ignore").decode() playlist = ( f"Name: {name}\n" f"Tracks: {item['tracks']['total']}\n" f"ID: {item['id']}" ) playlists.append(playlist) return "\n---\n".join(playlists) except Exception as e: return f"Error fetching playlists: {str(e)}"
  • main.py:8-13 (registration)
    Registers the MCP tool 'get_my_playlists' using FastMCP decorator, which calls the SpotifyClient's get_my_playlists method.
    @mcp.tool() async def get_my_playlists() -> str: """ FastMCP tool to get user playlists using SpotifyClient. """ return await client.get_my_playlists()

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