controlling-spotify
Skill158 starsChanged 8 months agoMITView on GitHub
Control Spotify playback and manage playlists via MCP server. Use when user requests playing music, controlling Spotify, creating playlists, searching songs, or managing their Spotify library.
- Reads credentials
In this repository113 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- accessing-github-reposSkill
- agent-routingSkill
- animating-with-codeSkill
- api-credentialsSkill
- asking-questionsSkill
- assessing-impactSkill
- atprotoingSkill
- bm25Skill
- browsing-blueskySkill
- building-github-indexSkill
- building-github-index-v2Skill
- categorizing-bsky-accountsSkill
- challengingSkill
- chartingSkill
- charting-vega-liteSkill
- check-toolsSkill
- cloning-projectSkill
- closing-issuesSkill
- coding-mojoSkill
- compiling-wgslSkill
- composing-htmlSkill
- configuringSkill
- container-layerSkill
- convening-expertsSkill
- converting-filesSkill
- crafting-instructionsSkill
- creating-bookmarkletsSkill
- creating-kbSkill
- creating-mcp-serversSkill
- creating-skillSkill
- creating-videoSkill
- deciding-with-confidenceSkill
- declaring-invariantsSkill
- declaudingSkill
- delegating-with-contextSkill
- describing-productsSkill
- detecting-tips-zonesSkill
- developing-preactSkill
- dispatching-subagentsSkill
- down-skillingSkill
- drawing-videoSkill
- drawing-with-pycairoSkill
- dunking-anonymouslySkill
- exploring-codebasesSkill
- exploring-dataSkill
- extracting-keywordsSkill
- featuringSkill
- fetching-blocked-urlsSkill
- finding-skillsSkill
- flowingSkill
- forecasting-reversoSkill
- gatingSkill
- generating-patchesSkill
- generative-thinkingSkill
- githubbingSkill
- hallucinating-labelsSkill
- hello-demoSkill
- image-to-svgSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 14 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 39
Create an app and note the Client ID and Client Secret
- Very specific: line 40
Add redirect URI: http://127.0.0.1:8888/callback
- Distinctive: line 48
Add three credentials to this skill:
- Very specific: line 55
Without these credentials, the skill cannot function: If credentials are missing, guide the user through the setup process detailed in …
- Distinctive: line 110
searchSpotify: - Search for tracks, albums, artists, or playlists
- Very specific: line 156
playMusic: - Start playing track/album/artist/playlist
- Distinctive: line 185
addToQueue: - Add track/album to playback queue
- Distinctive: line 194
createPlaylist: - Create new playlist
- Distinctive: line 203
addTracksToPlaylist: - Add tracks to existing playlist
- Distinctive: line 317
Treat them with the same security as passwords
- Distinctive: line 336
Solution: Verify credentials are properly configured:
- Distinctive: line 346
Cause: No Spotify client is currently running/active
- Distinctive: line 350
Start playing something (can pause immediately)
- Distinctive: line 371
Always search before playing: - Don't assume URIs, search for content first
- Very specific: line 372
Check playback state: - Use getNowPlaying to verify device availability
- Distinctive: line 374
Batch operations: - When adding multiple tracks, use single call with array
- Distinctive: line 375
Respect rate limits: - Add delays for bulk operations
- Distinctive: line 387
Never expose credentials in responses to users
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Controlling Spotify
Control Spotify playback, search for music, and manage playlists using the Spotify MCP Server with full user account access.
When to Use
Invoke this skill when users request:
- Playing, pausing, or skipping music on Spotify
- Searching for songs, albums, artists, or playlists
- Creating or modifying playlists
- Viewing currently playing track or playback status
- Managing their Spotify library (saved tracks, albums)
- Queuing songs or albums
Prerequisites
CRITICAL: This skill requires user-provided credentials. The user must complete a one-time setup:
One-Time User Setup
- Create Spotify Developer Application
- Go to https://developer.spotify.com/dashboard/
- Create an app and note the Client ID and Client Secret
- Add redirect URI:
http://127.0.0.1:8888/callback
- Obtain Refresh Token
- User must run the helper script locally (see
references/setup-guide.md) - Script exchanges OAuth code for a long-lived refresh token
- Refresh token is saved as credential in skill configuration
- User must run the helper script locally (see
Configure Credentials
- Add three credentials to this skill:
SPOTIFY_CLIENT_ID: From Spotify Developer DashboardSPOTIFY_CLIENT_SECRET: From Spotify Developer DashboardSPOTIFY_REFRESH_TOKEN: From helper script output
Alternative: Credentials can also be provided via a Project Knowledge file. Ensure the file contains a
.envstyle block with the keys above.- Add three credentials to this skill:
Without these credentials, the skill cannot function. If credentials are missing, guide the user through the setup process detailed in references/setup-guide.md.
MCP Server Installation
The Spotify MCP Server must be installed in the compute environment. Use the provided installation script which handles cloning, patching, and building the server.
# Run the installation script
bash scripts/install-mcp-server.shMCP Server Configuration
Configure the MCP client to connect to the Spotify MCP server. Note the logic to support credentials from Project Knowledge.
from mcp import Client
import asyncio
import re
# 1. Try to get credentials from skill configuration
env_vars = {
"SPOTIFY_CLIENT_ID": credentials.get("SPOTIFY_CLIENT_ID"),
"SPOTIFY_CLIENT_SECRET": credentials.get("SPOTIFY_CLIENT_SECRET"),
"SPOTIFY_REFRESH_TOKEN": credentials.get("SPOTIFY_REFRESH_TOKEN")
}
# 2. If missing, look in Project Knowledge / Context for .env style block
if not all(env_vars.values()):
# Heuristic: Scan context/files for VAR=VALUE patterns
# (Pseudo-code: Implement based on available context access)
pass
# Server configuration
mcp_config = {
"command": "node",
"args": ["/home/claude/spotify-mcp-server/build/index.js"],
"env": env_vars
}
# Initialize client
async def initialize_spotify_mcp():
client = Client()
await client.connect_stdio(
mcp_config["command"],
mcp_config["args"],
mcp_config["env"]
)
return clientAvailable Tools
Read Operations
- searchSpotify - Search for tracks, albums, artists, or playlists
result = await client.call_tool("searchSpotify", { "query": "bohemian rhapsody", "type": "track", "limit": 10 }) - getNowPlaying - Get currently playing track information
result = await client.call_tool("getNowPlaying", {}) - getMyPlaylists - List user's playlists
result = await client.call_tool("getMyPlaylists", { "limit": 20, "offset": 0 }) - getPlaylistTracks - Get tracks from a playlist
result = await client.call_tool("getPlaylistTracks", { "playlistId": "37i9dQZEVXcJZyENOWUFo7" }) - getRecentlyPlayed - Get recently played tracks
result = await client.call_tool("getRecentlyPlayed", { "limit": 10 }) - getUsersSavedTracks - Get user's liked songs
result = await client.call_tool("getUsersSavedTracks", { "limit": 50, "offset": 0 })
Playback Control
- playMusic - Start playing track/album/artist/playlist
# Play by URI result = await client.call_tool("playMusic", { "uri": "spotify:track:6rqhFgbbKwnb9MLmUQDhG6" }) # Or by type and ID result = await client.call_tool("playMusic", { "type": "track", "id": "6rqhFgbbKwnb9MLmUQDhG6" }) - pausePlayback - Pause current playback
result = await client.call_tool("pausePlayback", {}) - skipToNext - Skip to next track
result = await client.call_tool("skipToNext", {}) - skipToPrevious - Skip to previous track
result = await client.call_tool("skipToPrevious", {}) - addToQueue - Add track/album to playback queue
result = await client.call_tool("addToQueue", { "uri": "spotify:track:6rqhFgbbKwnb9MLmUQDhG6" })
Playlist Management
- createPlaylist - Create new playlist
result = await client.call_tool("createPlaylist", { "name": "My Workout Mix", "description": "High energy tracks", "public": False }) - addTracksToPlaylist - Add tracks to existing playlist
result = await client.call_tool("addTracksToPlaylist", { "playlistId": "3cEYpjA9oz9GiPac4AsH4n", "trackUris": [ "spotify:track:4iV5W9uYEdYUVa79Axb7Rh", "spotify:track:6rqhFgbbKwnb9MLmUQDhG6" ] })
Album Operations
- getAlbums - Get album details
result = await client.call_tool("getAlbums", { "albumIds": ["4aawyAB9vmqN3uQ7FjRGTy"] }) - getAlbumTracks - Get tracks from album
result = await client.call_tool("getAlbumTracks", { "albumId": "4aawyAB9vmqN3uQ7FjRGTy" }) - saveOrRemoveAlbumForUser - Save/remove albums
result = await client.call_tool("saveOrRemoveAlbumForUser", { "albumIds": ["4aawyAB9vmqN3uQ7FjRGTy"], "action": "save" })
Workflow Examples
Example 1: Play User's Favorite Song
# 1. Search for the song
search_result = await client.call_tool("searchSpotify", {
"query": "user's favorite song name",
"type": "track",
"limit": 1
})
# 2. Extract track URI from results
track_uri = search_result["tracks"][0]["uri"]
# 3. Play the track
await client.call_tool("playMusic", {
"uri": track_uri
})Example 2: Create Playlist from Genre
# 1. Search for tracks in genre
search_result = await client.call_tool("searchSpotify", {
"query": "genre:rock year:2020-2024",
"type": "track",
"limit": 20
})
# 2. Create new playlist
playlist_result = await client.call_tool("createPlaylist", {
"name": "Modern Rock Mix",
"description": "Recent rock tracks",
"public": False
})
# 3. Extract track URIs
track_uris = [track["uri"] for track in search_result["tracks"]]
# 4. Add tracks to playlist
await client.call_tool("addTracksToPlaylist", {
"playlistId": playlist_result["id"],
"trackUris": track_uris
})Example 3: Show What's Playing
# Get current playback state
now_playing = await client.call_tool("getNowPlaying", {})
# Format and display
print(f"Now Playing: {now_playing['track']['name']}")
print(f"Artist: {now_playing['track']['artists'][0]['name']}")
print(f"Album: {now_playing['track']['album']['name']}")
print(f"Progress: {now_playing['progress_ms']} / {now_playing['duration_ms']} ms")Important Notes
Spotify Premium Required
Playback control operations (play, pause, skip, queue) require Spotify Premium. Read operations (search, get playlists, view tracks) work with free accounts.
Active Device Required
For playback commands to work, the user must have an active Spotify session (web player, desktop app, mobile app) with a device available. If no active device, playback commands will fail.
Rate Limits
Spotify API has rate limits (typically 180 requests per minute). For bulk operations, implement appropriate delays or batching.
Token Security
- Refresh tokens grant full access to user's Spotify account
- Never log or expose refresh tokens
- Treat them with the same security as passwords
- Users can revoke tokens from https://www.spotify.com/account/apps/
URI Format
Spotify uses URIs in the format:
- Track:
spotify:track:ID - Album:
spotify:album:ID - Artist:
spotify:artist:ID - Playlist:
spotify:playlist:ID
Most tools accept either URIs or separate type + id parameters.
Troubleshooting
"Spotify configuration not found"
Cause: Missing environment variables
Solution: Verify credentials are properly configured:
import os
print(os.getenv("SPOTIFY_CLIENT_ID")) # Should not be None
print(os.getenv("SPOTIFY_CLIENT_SECRET")) # Should not be None
print(os.getenv("SPOTIFY_REFRESH_TOKEN")) # Should not be None"No active device"
Cause: No Spotify client is currently running/active
Solution: Guide user to:
- Open Spotify on any device (web, desktop, mobile)
- Start playing something (can pause immediately)
- Try the playback command again
"Premium required"
Cause: User has Spotify Free account
Solution: Playback control requires Spotify Premium. Only search and read operations available for free accounts.
MCP Server Won't Start
Cause: Missing dependencies or incorrect installation
Solution:
# Re-run installation script
bash scripts/install-mcp-server.shBest Practices
- Always search before playing - Don't assume URIs, search for content first
- Check playback state - Use
getNowPlayingto verify device availability - Handle errors gracefully - Provide helpful messages when operations fail
- Batch operations - When adding multiple tracks, use single call with array
- Respect rate limits - Add delays for bulk operations
References
- Setup Guide:
references/setup-guide.md - API Documentation: https://developer.spotify.com/documentation/web-api/
- MCP Specification: https://modelcontextprotocol.io/
Security
This skill requires sensitive credentials. Ensure:
- Credentials are stored securely in skill configuration
- Never expose credentials in responses to users
- Never log credentials
- Users understand they can revoke access anytime
See references/setup-guide.md for detailed security best practices.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

