Your Spotify MCP Server project has been refactored to be a production-ready MCP server package instead of a collection of scripts. This means it's now properly designed to be consumed by AI assistants like Claude Desktop, Cursor, and VS Code.
spotify-mcp-server/
โโโ src/ # MCP server code
โโโ build/ # Compiled server
โโโ *.mjs files # Random test scripts in root
โโโ README.md
spotify-mcp-server/
โโโ src/ # Core MCP server code
โโโ build/ # Compiled server
โโโ examples/ # Organized example scripts
โโโ README.md # MCP server documentation
โโโ REFACTORING.md # Detailed refactoring info
โโโ package.json # Production-ready metadata
โ
package.json now includes:
- Proper description emphasizing MCP purpose
- License, repository, and bugs fields
- Correct
mainentry point - Better scripts:
build,dev,auth,typecheck - Appropriate
filesarray (excludes examples) - Required Node.js version specification
โ
Test scripts moved to examples/:
test-now-playing.mjsbuild-and-play-playlist.mjsadd-songs-to-playlist.mjsget-music-statistics.mjscheck-playback-status.mjsenable-shuffle-v2.mjsskip-next.mjs- And more...
โ Two-tier documentation:
- README.md: MCP server setup and usage
- examples/README.md: Guide to example scripts
- REFACTORING.md: This refactoring summary
โ
Enhanced src/utils.ts with:
- Automatic token refresh on expiration
- Better error handling
- No instance caching (ensures fresh tokens)
- Build the server:
npm run build - Add to
~/.config/claude/config.json:
{
"mcpServers": {
"spotify": {
"command": "node",
"args": ["/path/to/spotify-mcp-server/build/index.js"]
}
}
}- Restart Claude Desktop
- Build:
npm run build - Open Cursor Settings (Cmd + Shift + J)
- Go to MCP tab
- Add:
node /path/to/spotify-mcp-server/build/index.js
- Build:
npm run build - Create/edit
cline_mcp_settings.json:
{
"mcpServers": {
"spotify": {
"command": "node",
"args": ["/path/to/spotify-mcp-server/build/index.js"],
"autoApprove": ["getNowPlaying", "searchSpotify"]
}
}
}# Get now playing
node examples/test-now-playing.mjs
# Build and play a playlist
node examples/build-and-play-playlist.mjs
# Get music statistics
node examples/get-music-statistics.mjs
# And more...# Watch for TypeScript changes
npm run dev
# Type check
npm run typecheck
# Lint
npm run lint
# Lint with fixes
npm run lint:fixThese files are compiled and distributed:
index.ts- MCP server entry pointread.ts- Search, get playlists, etc.play.ts- Playback controlalbums.ts- Album operationsauth.ts- Authentication logicutils.ts- Utilities + token refreshtypes.ts- TypeScript types
Generated JavaScript - do NOT edit directly
For learning and testing - NOT distributed:
- Each script demonstrates a use case
- Can be adapted for your needs
- Run independently with Node.js
.gitignore- Excludes sensitive filespackage.json- Project metadatatsconfig.json- TypeScript configbiome.jsonc- Code formatting rules
The MCP server exposes these tools to AI assistants:
searchSpotify- Search tracks, albums, artists, playlistsgetNowPlaying- Get current trackgetMyPlaylists- Get user's playlistsgetPlaylistTracks- Get tracks in playlistgetRecentlyPlayed- Get recently playedgetUsersSavedTracks- Get liked songsgetQueue- Get playback queue
playMusic- Play track/album/artist/playlistpausePlayback- PauseresumePlayback- ResumeskipToNext- Next trackskipToPrevious- Previous trackaddToQueue- Add to queue
createPlaylist- Create new playlistaddTracksToPlaylist- Add tracks
getAlbums- Get album infogetAlbumTracks- Get album trackssaveOrRemoveAlbumForUser- Save/removecheckUsersSavedAlbums- Check if saved
โ Important security measures:
spotify-config.jsonis git-ignored (contains secrets)- Use
spotify-config.example.jsonas template - Tokens are automatically refreshed
- No credentials in distributed package
- โ MCP server ready
- โ Production-ready package
- โ Example scripts included
- โ Comprehensive documentation
- โ Proper project structure
- โ Token refresh working
- โ TypeScript strict mode
- โ Linting configured
- README.md - MCP server overview and setup
- examples/README.md - How to run example scripts
- REFACTORING.md - Detailed refactoring info
- examples/*.mjs - Working code examples
A: Yes! They're in examples/ folder. Run them with:
node examples/script-name.mjsA: Build the project and add to Claude's config. See README.md for details.
A: In spotify-config.json (git-ignored for security).
A: Yes! The package.json is properly configured. The files field ensures only necessary files are included.
A: Edit files in src/, then run:
npm run dev # Watch mode
npm run build # Compile
npm run lint:fix # Fix formatting- Verify the build:
npm run build(should complete without errors) - Test an example:
node examples/test-now-playing.mjs - Integrate: Add to your MCP client (Claude, Cursor, etc.)
- Customize: Modify tools in
src/as needed
- โ Clear Purpose: This is an MCP server package, not a CLI tool
- โ Professional: Follows npm package best practices
- โ Maintainable: Well-organized, easy to modify
- โ Documented: Comprehensive guides included
- โ Production Ready: Proper error handling and security
- โ User Friendly: Easy setup and integration
For more details, see:
README.md- Project overview and setupexamples/README.md- Example scripts guideREFACTORING.md- Detailed changes made