Skip to main content
Glama
playback.ts1.58 kB
import { SpotifyClient } from '../spotify/client.js'; export async function controlPlayback( client: SpotifyClient, action: 'play' | 'pause' | 'skip-next' | 'skip-previous' | 'volume', value?: number, deviceId?: string ) { switch (action) { case 'play': await client.resume(deviceId); return { success: true, message: 'Playback resumed' }; case 'pause': await client.pause(deviceId); return { success: true, message: 'Playback paused' }; case 'skip-next': await client.skipToNext(deviceId); return { success: true, message: 'Skipped to next track' }; case 'skip-previous': await client.skipToPrevious(deviceId); return { success: true, message: 'Skipped to previous track' }; case 'volume': if (value === undefined || value < 0 || value > 100) { throw new Error('Volume must be between 0 and 100'); } await client.setVolume(value, deviceId); return { success: true, message: `Volume set to ${value}%` }; default: throw new Error(`Unknown action: ${action}`); } } export async function getCurrentPlaying(client: SpotifyClient) { const track = await client.getCurrentlyPlaying(); if (!track) { return { success: true, playing: false, message: 'No track currently playing', }; } return { success: true, playing: track.isPlaying, track: { name: track.name, artist: track.artist, album: track.album, uri: track.uri, progressMs: track.progressMs, }, }; }

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/Ackberry/spotify_mcp'

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