data
Spotify CLI for AI Agents
Use the Spotify CLI from KosmoKrator to call Spotify tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Spotify CLI Setup
Spotify can be configured headlessly with `kosmokrator integrations:configure spotify`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure spotify --set access_token="$SPOTIFY_ACCESS_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor spotify --json
kosmokrator integrations:status --json Credentials
Authentication type: Manual OAuth token oauth2_manual_token. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
access_token | SPOTIFY_ACCESS_TOKEN | Secret secret | yes | Access Token |
url | SPOTIFY_URL | URL url | no | API URL |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call spotify.spotify_search '{"q":"example_q","type":"example_type","limit":1,"offset":1}' --json kosmo integrations:spotify spotify_search '{"q":"example_q","type":"example_type","limit":1,"offset":1}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs spotify --json
kosmo integrations:docs spotify.spotify_search --json
kosmo integrations:schema spotify.spotify_search --json
kosmo integrations:search "Spotify" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
spotify.spotify_search
Search for tracks, artists, albums, or playlists on Spotify. Returns matching items with basic metadata. Use specific get tools for detailed information about a single item.
read - Parameters
- q, type, limit, offset
kosmo integrations:call spotify.spotify_search '{"q":"example_q","type":"example_type","limit":1,"offset":1}' --json kosmo integrations:spotify spotify_search '{"q":"example_q","type":"example_type","limit":1,"offset":1}' --json spotify.spotify_get_track
Get detailed information about a specific Spotify track, including artists, album, duration, and popularity.
read - Parameters
- id
kosmo integrations:call spotify.spotify_get_track '{"id":"example_id"}' --json kosmo integrations:spotify spotify_get_track '{"id":"example_id"}' --json spotify.spotify_get_artist
Get detailed information about a specific Spotify artist, including followers, genres, and popularity.
read - Parameters
- id
kosmo integrations:call spotify.spotify_get_artist '{"id":"example_id"}' --json kosmo integrations:spotify spotify_get_artist '{"id":"example_id"}' --json spotify.spotify_list_playlists
List the current user's Spotify playlists. Returns playlist names, IDs, and track counts.
read - Parameters
- limit, offset
kosmo integrations:call spotify.spotify_list_playlists '{"limit":1,"offset":1}' --json kosmo integrations:spotify spotify_list_playlists '{"limit":1,"offset":1}' --json spotify.spotify_get_playlist
Get detailed information about a Spotify playlist, including its tracks with artist and album details.
read - Parameters
- id, limit, offset
kosmo integrations:call spotify.spotify_get_playlist '{"id":"example_id","limit":1,"offset":1}' --json kosmo integrations:spotify spotify_get_playlist '{"id":"example_id","limit":1,"offset":1}' --json spotify.spotify_create_playlist
Create a new Spotify playlist for the current user. Use the "Get Current User" tool first if you need the user ID.
write - Parameters
- user_id, name, description, public
kosmo integrations:call spotify.spotify_create_playlist '{"user_id":"example_user_id","name":"example_name","description":"example_description","public":true}' --json kosmo integrations:spotify spotify_create_playlist '{"user_id":"example_user_id","name":"example_name","description":"example_description","public":true}' --json spotify.spotify_list_albums
List albums by a specific Spotify artist. Includes singles and compilations by default.
read - Parameters
- id, include_groups, limit, offset
kosmo integrations:call spotify.spotify_list_albums '{"id":"example_id","include_groups":"example_include_groups","limit":1,"offset":1}' --json kosmo integrations:spotify spotify_list_albums '{"id":"example_id","include_groups":"example_include_groups","limit":1,"offset":1}' --json spotify.spotify_get_current_user
Get the authenticated user's Spotify profile, including their user ID (needed for creating playlists), display name, and follower count.
read - Parameters
- none
kosmo integrations:call spotify.spotify_get_current_user '{}' --json kosmo integrations:spotify spotify_get_current_user '{}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
spotify.spotify_search 4 parameters
kosmo integrations:schema spotify.spotify_search --json | Parameter | Type | Required | Description |
|---|---|---|---|
q | string | yes | The search query (e.g., "Bohemian Rhapsody", "artist:Queen"). Supports Spotify search operators like artist:, album:, track:, year:, genre:. |
type | string | no | Type of results: "track", "artist", "album", or "playlist". Defaults to "track". |
limit | integer | no | Maximum number of results (default 20, max 50). |
offset | integer | no | The index of the first result (default 0, use for pagination). |
spotify.spotify_get_track 1 parameters
kosmo integrations:schema spotify.spotify_get_track --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Spotify track ID (e.g., "4cOdK2wGLETKBW3PvgPWqT"). |
spotify.spotify_get_artist 1 parameters
kosmo integrations:schema spotify.spotify_get_artist --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Spotify artist ID (e.g., "1dfeR4HaWDbWqFHLkxsg1d"). |
spotify.spotify_list_playlists 2 parameters
kosmo integrations:schema spotify.spotify_list_playlists --json | Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of playlists to return (default 20, max 50). |
offset | integer | no | The index of the first playlist (default 0, use for pagination). |
spotify.spotify_get_playlist 3 parameters
kosmo integrations:schema spotify.spotify_get_playlist --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Spotify playlist ID. |
limit | integer | no | Maximum number of tracks to return (default 20, max 100). |
offset | integer | no | The index of the first track (default 0, use for pagination). |
spotify.spotify_create_playlist 4 parameters
kosmo integrations:schema spotify.spotify_create_playlist --json | Parameter | Type | Required | Description |
|---|---|---|---|
user_id | string | yes | The Spotify user ID. Get this from the "Get Current User" tool. |
name | string | yes | The name for the new playlist. |
description | string | no | An optional description for the playlist. |
public | boolean | no | Whether the playlist should be public (default true). |
spotify.spotify_list_albums 4 parameters
kosmo integrations:schema spotify.spotify_list_albums --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Spotify artist ID. |
include_groups | string | no | Album types to include, comma-separated: "album", "single", "appears_on", "compilation". Defaults to "album,single". |
limit | integer | no | Maximum number of albums to return (default 20, max 50). |
offset | integer | no | The index of the first album (default 0, use for pagination). |
spotify.spotify_get_current_user 0 parameters
kosmo integrations:schema spotify.spotify_get_current_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults with
integrations:configure. Add --force only for trusted automation that should bypass that policy.