Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
dry_runNoPreview only: perform the read side and return a PLAN without changing anything. Default true — pass false to commit.
keep_whichNoGreedy direction: keep the first N that fit, the last N, or a random draw. Default firstfirst
max_resultsNoMax items to return (default: SPOTIFY_MCP_MAX_ITEMS env or 50)
playlist_idYesPlaylist to trim, as ID or spotify:playlist: URI
tolerance_secNoAcceptable deviation from the target, in seconds. Default 30
target_minutesYesTarget runtime in minutes
response_formatNo'concise' = human prose, 'detailed' = more fields in prose, 'json' = raw API objectconcise
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does it well: it discloses the selection algorithm, the ±tolerance behavior, the atomic all-or-nothing replace, and the API quota (GET + 1 PUT). This is exactly the behavioral context an agent needs before mutating a playlist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences front-load the use case and algorithm, then add sibling differentiation and quota. Every sentence contributes meaningful information with no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given seven parameters and no annotations or output schema, the description covers the essential operational facts: purpose, algorithm, side-effect atomicity, quota, and relation to a sibling. It doesn't describe return shapes in prose, but the schema's dry_run and response_format parameter descriptions already handle those, so the remaining gap is minor.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3 and the description does not need to repeat parameter details. It adds value by explaining how target_minutes, tolerance_sec, and keep_which interact through greedy selection within tolerance, which goes beyond individual schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource ('Fit a playlist to a target runtime') and adds the key algorithm details: greedy keep-first/last/random selection within a tolerance. It also explicitly contrasts with the item-count sibling playlist_trim, so the agent can distinguish the two tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The 'Complements item-count playlist_trim' line names the closest alternative and implies the duration-vs-count selection criterion, and the commute example gives a concrete use case. It doesn't enumerate all possible alternatives like playlist_filter_runtime or split_playlist_by_duration, but the context is clear enough.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/NovaLux12/spotify-mcp-server'

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