Spotify ACTION
Add Items to a Playlist
Add tracks or podcast episodes to an existing Spotify playlist that the current user can modify. Use List Playlist ID Options to find the playlist ID, or Create a Playlist to make a new one first. Items are identified by Spotify URI, not bare ID: tracks as
spotify:track:<id> and episodes as spotify:episode:<id>. Use Search with type track or episode to find them: pass the uri from tracks.items[] or episodes.items[]. Up to 100 items per call; split larger batches into several calls. Items are added in the order given, appended to the end unless Position is set. Returns { snapshot_id }, the playlist's new version ID. Use Get a Playlist's Items to confirm the result, or Remove Items from a Playlist to undo. See the documentation- Action
- Writes data
- OAuth
- SDK
- MCP
IMPLEMENTATION
Call this tool
Connect a user's Spotify account once, then configure and run Add Items to a Playlist from your backend or agent.
import { PipedreamClient } from "@pipedream/sdk"
const pd = new PipedreamClient({
projectId: process.env.PIPEDREAM_PROJECT_ID!,
clientId: process.env.PIPEDREAM_CLIENT_ID!,
clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
projectEnvironment: "production",
})
const result = await pd.actions.run({
id: "spotify-add-items-to-playlist",
externalUserId: "{external_user_id}", // any stable ID for this user in your system
configuredProps: {
spotify: { authProvisionId: "apn_xxxxxxx" },
playlistId: "Playlist ID",
uris: ["Track or Episode URIs"],
},
})
console.log(result)curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
-H "Content-Type: application/json" \
-H "X-PD-Environment: production" \
-H "Authorization: Bearer {access_token}" \
-d '{
"external_user_id": "{external_user_id}",
"id": "spotify-add-items-to-playlist",
"configured_props": {
"spotify": { "authProvisionId": "apn_xxxxxxx" },
"playlistId": "Playlist ID",
"uris": ["Track or Episode URIs"]
}
}'// accessToken: mint a short-lived token with the Connect SDK — see the MCP guide
const transport = new StreamableHTTPClientTransport(
new URL("https://remote.mcp.pipedream.net/v3"),
{
requestInit: {
headers: {
Authorization: `Bearer ${accessToken}`,
"x-pd-project-id": "{project_id}",
"x-pd-environment": "production",
"x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
"x-pd-app-slug": "spotify",
},
},
},
)
const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)
const { tools } = await mcp.listTools()
// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
name: "spotify-add-items-to-playlist",
arguments: {
playlistId: "Playlist ID",
uris: ["Track or Episode URIs"],
},
})SCHEMA
Inputs
Pipedream supplies the connected account. Your application provides the operation-specific values below. Dynamic inputs are resolved against that user's account.
| Property | Type | Description |
|---|---|---|
playlistId Playlist ID | string | The Spotify ID of the playlist to add items to, e.g. 3cEYpjA9oz9GiPac4AsH4n (the ID only, not the spotify:playlist: URI or the URL). Use List Playlist ID Options to find it. Required |
uris Track or Episode URIs | string[] | Spotify URIs of the items to add, in the order they should appear, e.g. ["spotify:track:4iV5W9uYEdYUVa79Axb7Rh", "spotify:episode:512ojhOuo1ktJprKbVcKyQ"]. Only track and episode URIs are accepted. Maximum 100 per call. Use Search to find URIs. Required |
position Position | integer | Zero-based index at which to insert the items. 0 inserts at the top of the playlist; 2 inserts before the current third item. Omit to append to the end. Optional |
REFERENCE
Tool details
Behavior hints are published with the component in the Pipedream registry and surface as MCP tool annotations, so an agent can reason about a tool before it calls it.
- Registry key
- spotify-add-items-to-playlist
- Version
- 0.2.0
- App
- Spotify
- Authentication
- OAuth
- Read-only
- No
- Destructive
- No
- Open world
- Yes
- Source
- View on GitHub ↗