Skip to main content
Glama

set_volume

Adjust the volume level on your active Spotify device by setting a percentage from 0 to 100, enabling precise audio control during playback.

Instructions

Adjust the volume level for the user's active Spotify device.

🎯 USE CASES: β€’ Create dynamic volume adjustments for different times of day β€’ Build smart home automation with volume control β€’ Implement voice commands for hands-free volume changes β€’ Adjust volume based on ambient noise levels β€’ Create custom audio experience controls

πŸ“ WHAT IT RETURNS: β€’ Confirmation of successful volume change β€’ Current volume level after adjustment β€’ Device information showing updated state β€’ Previous volume level for potential undo functionality β€’ Playback state with new volume settings

πŸ” EXAMPLES: β€’ "Set volume to 50%" β€’ "Lower the volume to 25" β€’ "Turn up the music to 80%" β€’ "Make it quieter, set to 15%"

πŸ”Š VOLUME CONTROL: β€’ Range: 0-100 percent β€’ 0 = Complete silence (muted) β€’ 100 = Maximum device volume β€’ Changes apply instantly during playback β€’ Preserves volume setting for future sessions

⚠️ REQUIREMENTS: β€’ Valid Spotify access token with user-modify-playback-state scope β€’ Active device that supports volume control β€’ Device must be currently available and responsive

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesSpotify access token for authentication
volume_percentYesVolume level as a percentage (0-100)
deviceIdNoSpotify device ID (optional, uses active device if not specified)

Implementation Reference

  • Core handler implementation in SpotifyService that clamps the volume percent to 0-100 and makes a PUT request to Spotify API endpoint /me/player/volume?volume_percent={volume}[&device_id={deviceId}] to set the volume on the specified or active device.
    async setVolume( token: string, volumePercent: number, deviceId: string | null = null ): Promise<void> { const volume = Math.min(Math.max(volumePercent, 0), 100); let endpoint = `me/player/volume?volume_percent=${volume}`; if (deviceId) { endpoint += `&device_id=${deviceId}`; } return await this.makeRequest<void>(endpoint, token, {}, "PUT"); }
  • MCP tool registration for 'set_volume' including title, description, input schema, and handler that delegates to SpotifyService.setVolume.
    set_volume: { title: "Set Player Volume", description: `Adjust the volume level for the user's active Spotify device. 🎯 USE CASES: β€’ Create dynamic volume adjustments for different times of day β€’ Build smart home automation with volume control β€’ Implement voice commands for hands-free volume changes β€’ Adjust volume based on ambient noise levels β€’ Create custom audio experience controls πŸ“ WHAT IT RETURNS: β€’ Confirmation of successful volume change β€’ Current volume level after adjustment β€’ Device information showing updated state β€’ Previous volume level for potential undo functionality β€’ Playback state with new volume settings πŸ” EXAMPLES: β€’ "Set volume to 50%" β€’ "Lower the volume to 25" β€’ "Turn up the music to 80%" β€’ "Make it quieter, set to 15%" πŸ”Š VOLUME CONTROL: β€’ Range: 0-100 percent β€’ 0 = Complete silence (muted) β€’ 100 = Maximum device volume β€’ Changes apply instantly during playback β€’ Preserves volume setting for future sessions ⚠️ REQUIREMENTS: β€’ Valid Spotify access token with user-modify-playback-state scope β€’ Active device that supports volume control β€’ Device must be currently available and responsive`, schema: createSchema({ token: commonSchemas.token(), volume_percent: commonSchemas.volumePercent(), deviceId: commonSchemas.deviceId(), }), handler: async (args: any, spotifyService: SpotifyService) => { const { token, volume_percent, deviceId } = args; return await spotifyService.setVolume(token, volume_percent, deviceId); }, },
  • Input schema definition for the set_volume tool using Zod validation for token, volume_percent (0-100), and optional deviceId.
    token: commonSchemas.token(), volume_percent: commonSchemas.volumePercent(), deviceId: commonSchemas.deviceId(), }),
  • Reusable Zod schema helper for volume_percent parameter, enforcing 0-100 integer range with description.
    volumePercent: () => z.number().min(0).max(100).describe("Volume level as a percentage (0-100)"),

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/latiftplgu/Spotify-OAuth-MCP-server'

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