KosmoKrator

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, configure, and verify
# 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.

KeyEnv varTypeRequiredLabel
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.

Generic CLI call
kosmo integrations:call spotify.spotify_search '{"q":"example_q","type":"example_type","limit":1,"offset":1}' --json
Provider shortcut
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.

Discovery commands
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 read
Parameters
q, type, limit, offset
Generic call
kosmo integrations:call spotify.spotify_search '{"q":"example_q","type":"example_type","limit":1,"offset":1}' --json
Shortcut
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 read
Parameters
id
Generic call
kosmo integrations:call spotify.spotify_get_track '{"id":"example_id"}' --json
Shortcut
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 read
Parameters
id
Generic call
kosmo integrations:call spotify.spotify_get_artist '{"id":"example_id"}' --json
Shortcut
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 read
Parameters
limit, offset
Generic call
kosmo integrations:call spotify.spotify_list_playlists '{"limit":1,"offset":1}' --json
Shortcut
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 read
Parameters
id, limit, offset
Generic call
kosmo integrations:call spotify.spotify_get_playlist '{"id":"example_id","limit":1,"offset":1}' --json
Shortcut
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 write
Parameters
user_id, name, description, public
Generic call
kosmo integrations:call spotify.spotify_create_playlist '{"user_id":"example_user_id","name":"example_name","description":"example_description","public":true}' --json
Shortcut
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 read
Parameters
id, include_groups, limit, offset
Generic call
kosmo integrations:call spotify.spotify_list_albums '{"id":"example_id","include_groups":"example_include_groups","limit":1,"offset":1}' --json
Shortcut
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 read
Parameters
none
Generic call
kosmo integrations:call spotify.spotify_get_current_user '{}' --json
Shortcut
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_get_track 1 parameters
Schema command
kosmo integrations:schema spotify.spotify_get_track --json
ParameterTypeRequiredDescription
id string yes The Spotify track ID (e.g., "4cOdK2wGLETKBW3PvgPWqT").
spotify.spotify_get_artist 1 parameters
Schema command
kosmo integrations:schema spotify.spotify_get_artist --json
ParameterTypeRequiredDescription
id string yes The Spotify artist ID (e.g., "1dfeR4HaWDbWqFHLkxsg1d").
spotify.spotify_list_playlists 2 parameters
Schema command
kosmo integrations:schema spotify.spotify_list_playlists --json
ParameterTypeRequiredDescription
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
Schema command
kosmo integrations:schema spotify.spotify_get_playlist --json
ParameterTypeRequiredDescription
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
Schema command
kosmo integrations:schema spotify.spotify_create_playlist --json
ParameterTypeRequiredDescription
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
Schema command
kosmo integrations:schema spotify.spotify_list_albums --json
ParameterTypeRequiredDescription
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
Schema command
kosmo integrations:schema spotify.spotify_get_current_user --json
ParameterTypeRequiredDescription
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.