playlist_trim_to_duration
Adjust a Spotify playlist to a target runtime: select tracks greedily by first/last/random until the duration falls within your tolerance, with preview before applying.
Instructions
Fit a playlist to a target runtime (e.g. "exactly 30 min for the commute"): greedy keep-first/last/random selection within ±tolerance seconds, written as one atomic replace. Complements item-count playlist_trim. Quota: đŸŸ¢ GET + 1 PUT.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dry_run | No | Preview only: perform the read side and return a PLAN without changing anything. Default true — pass false to commit. | |
| keep_which | No | Greedy direction: keep the first N that fit, the last N, or a random draw. Default first | first |
| max_results | No | Max items to return (default: SPOTIFY_MCP_MAX_ITEMS env or 50) | |
| playlist_id | Yes | Playlist to trim, as ID or spotify:playlist: URI | |
| tolerance_sec | No | Acceptable deviation from the target, in seconds. Default 30 | |
| target_minutes | Yes | Target runtime in minutes | |
| response_format | No | 'concise' = human prose, 'detailed' = more fields in prose, 'json' = raw API object | concise |