Skip to main content
Glama

save_tracks

Add tracks to your Spotify library to create a permanent collection of favorite music for future listening and offline access.

Instructions

Add tracks to the user's personal library, creating a permanent collection of favorite music.

🎯 USE CASES: β€’ Save discovered tracks for future listening β€’ Build personal music library from recommendations β€’ Like tracks during music discovery sessions β€’ Create permanent collections of favorite songs β€’ Save music for offline listening and easy access

πŸ“ WHAT IT RETURNS: β€’ Confirmation of successful track saves β€’ Updated library count and collection size β€’ Timestamp information for when tracks were saved β€’ Error details for tracks that couldn't be saved β€’ Success status for bulk save operations

πŸ” EXAMPLES: β€’ "Save 'Bohemian Rhapsody' to my library" β€’ "Add these 5 discovered tracks to my liked songs" β€’ "Save track IDs: 4uLU6hMCjMI75M1A2tKUQC, 7qiZfU4dY1lWllzX7mkmht" β€’ "Like all tracks from this great album"

πŸ’– BUILDING YOUR COLLECTION: β€’ Creates permanent access to favorite music β€’ Tracks appear in your "Liked Songs" playlist β€’ Enables offline playback for saved content β€’ Perfect for building personalized music libraries β€’ Essential for music discovery and curation

πŸ’‘ COLLECTION STRATEGIES: β€’ Save tracks immediately during discovery β€’ Build thematic collections of related music β€’ Use bulk saves for efficiency with multiple tracks β€’ Regular saving helps track music evolution β€’ Create personal "greatest hits" collections

⚠️ REQUIREMENTS: β€’ Valid Spotify access token with user-library-modify scope β€’ Tracks must be available in user's market β€’ Maximum 50 tracks can be saved per request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesSpotify access token for authentication
trackIdsYesArray of Spotify track IDs to save

Implementation Reference

  • Core implementation of the saveTracks function in SpotifyService. Extracts track IDs, formats them, and makes a PUT request to Spotify API endpoint /me/tracks to save tracks to user's library.
    async saveTracks(token: string, trackIds: string | string[]): Promise<void> { const ids = Array.isArray(trackIds) ? trackIds.map((id) => this.extractId(id)) : [this.extractId(trackIds)]; const params = { ids: ids.join(",") }; return await this.makeRequest<void>("me/tracks", token, params, "PUT"); }
  • The MCP tool handler for 'save_tracks' that validates arguments and delegates execution to the SpotifyService.saveTracks method.
    handler: async (args: any, spotifyService: SpotifyService) => { const { token, trackIds } = args; return await spotifyService.saveTracks(token, trackIds); },
  • Zod-based input schema definition for the 'save_tracks' tool, requiring a Spotify token and an array of track IDs.
    schema: createSchema({ token: commonSchemas.token(), trackIds: z .array(z.string()) .describe("Array of Spotify track IDs to save"), }),
  • Complete registration of the 'save_tracks' tool as part of the trackTools object, including title, detailed description, schema, and handler reference.
    save_tracks: { title: "Save Tracks to Library", description: `Add tracks to the user's personal library, creating a permanent collection of favorite music. 🎯 USE CASES: β€’ Save discovered tracks for future listening β€’ Build personal music library from recommendations β€’ Like tracks during music discovery sessions β€’ Create permanent collections of favorite songs β€’ Save music for offline listening and easy access πŸ“ WHAT IT RETURNS: β€’ Confirmation of successful track saves β€’ Updated library count and collection size β€’ Timestamp information for when tracks were saved β€’ Error details for tracks that couldn't be saved β€’ Success status for bulk save operations πŸ” EXAMPLES: β€’ "Save 'Bohemian Rhapsody' to my library" β€’ "Add these 5 discovered tracks to my liked songs" β€’ "Save track IDs: 4uLU6hMCjMI75M1A2tKUQC, 7qiZfU4dY1lWllzX7mkmht" β€’ "Like all tracks from this great album" πŸ’– BUILDING YOUR COLLECTION: β€’ Creates permanent access to favorite music β€’ Tracks appear in your "Liked Songs" playlist β€’ Enables offline playback for saved content β€’ Perfect for building personalized music libraries β€’ Essential for music discovery and curation πŸ’‘ COLLECTION STRATEGIES: β€’ Save tracks immediately during discovery β€’ Build thematic collections of related music β€’ Use bulk saves for efficiency with multiple tracks β€’ Regular saving helps track music evolution β€’ Create personal "greatest hits" collections ⚠️ REQUIREMENTS: β€’ Valid Spotify access token with user-library-modify scope β€’ Tracks must be available in user's market β€’ Maximum 50 tracks can be saved per request`, schema: createSchema({ token: commonSchemas.token(), trackIds: z .array(z.string()) .describe("Array of Spotify track IDs to save"), }), handler: async (args: any, spotifyService: SpotifyService) => { const { token, trackIds } = args; return await spotifyService.saveTracks(token, trackIds); }, },
  • Registration of trackTools (including save_tracks) into the central allTools registry used by ToolRegistrar for MCP tool definitions.
    ...trackTools,

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/latiftplgu/Spotify-OAuth-MCP-server'

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