search_spotify
Search Spotify for tracks, artists, albums, or playlists using a query, content type, and result limit to find specific music content.
Instructions
Search Spotify for tracks, artists, albums, or playlists.
Args:
query: Search term
type: One of 'track', 'artist', 'album', 'playlist'
limit: Max number of results
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| type | No | track | |
| limit | No |
Implementation Reference
- main.py:32-41 (handler)MCP tool handler for 'search_spotify' that invokes SpotifyClient.search@mcp.tool() async def search_spotify(query: str, type: str = "track", limit: int = 20) -> str: """ Search Spotify for tracks, artists, albums, or playlists. Args: query: Search term type: One of 'track', 'artist', 'album', 'playlist' limit: Max number of results """ return await client.search(query, type, limit)
- spotify.py:135-147 (helper)SpotifyClient.search method implementing the core search logic using spotipy libraryasync def search(self, query: str, qtype: str = "track", limit: int = 20) -> dict: """ Search for tracks, artists, albums, or playlists. - query: Search query - qtype: Either "track", "artist", "album", or "playlist" - limit: Max number of results (default 20) """ try: results = self.sp.search(q=query, type=qtype, limit=limit) return results except Exception as e: return f"Error searching: {str(e)}"