Skip to main content
Glama
marcelmarais

Spotify MCP Server

by marcelmarais

adjustVolume

Control Spotify playback volume by increasing or decreasing levels using positive or negative values. Requires Spotify Premium subscription.

Instructions

Adjust the playback volume up or down by a relative amount. Use positive values to increase, negative to decrease. Requires Spotify Premium.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
adjustmentYesThe amount to adjust volume by (-100 to 100). Positive increases, negative decreases.
deviceIdNoThe Spotify device ID to adjust volume on

Implementation Reference

  • Handler function that retrieves current playback state, calculates new volume by adding the adjustment (clamped between 0-100), sets the volume using Spotify API, and returns a success message.
      handler: async (args, _extra: SpotifyHandlerExtra) => {
        const { adjustment, deviceId } = args;
    
        try {
          // First get the current playback state to find current volume
          const playback = await handleSpotifyRequest(async (spotifyApi) => {
            return await spotifyApi.player.getPlaybackState();
          });
    
          if (!playback?.device) {
            return {
              content: [
                {
                  type: 'text',
                  text: 'No active device found. Make sure Spotify is open and playing on a device.',
                },
              ],
            };
          }
    
          const currentVolume = playback.device.volume_percent;
          if (currentVolume === null || currentVolume === undefined) {
            return {
              content: [
                {
                  type: 'text',
                  text: 'Unable to get current volume from device.',
                },
              ],
            };
          }
    
          const newVolume = Math.min(100, Math.max(0, currentVolume + adjustment));
    
          await handleSpotifyRequest(async (spotifyApi) => {
            await spotifyApi.player.setPlaybackVolume(
              Math.round(newVolume),
              deviceId || '',
            );
          });
    
          const direction = adjustment > 0 ? 'increased' : 'decreased';
          return {
            content: [
              {
                type: 'text',
                text: `Volume ${direction} from ${currentVolume}% to ${Math.round(newVolume)}%`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error adjusting volume: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
          };
        }
      },
    };
  • Input schema using Zod: 'adjustment' (number between -100 and 100), optional 'deviceId' (string).
    schema: {
      adjustment: z
        .number()
        .min(-100)
        .max(100)
        .describe(
          'The amount to adjust volume by (-100 to 100). Positive increases, negative decreases.',
        ),
      deviceId: z
        .string()
        .optional()
        .describe('The Spotify device ID to adjust volume on'),
    },
  • src/play.ts:499-510 (registration)
    The adjustVolume tool is included in the exported playTools array.
    export const playTools = [
      playMusic,
      pausePlayback,
      skipToNext,
      skipToPrevious,
      createPlaylist,
      addTracksToPlaylist,
      resumePlayback,
      addToQueue,
      setVolume,
      adjustVolume,
    ];
  • src/index.ts:12-14 (registration)
    playTools array (including adjustVolume) is spread and each tool is registered with the MCP server via server.tool().
    [...readTools, ...playTools, ...albumTools].forEach((tool) => {
      server.tool(tool.name, tool.description, tool.schema, tool.handler);
    });
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the relative adjustment mechanism (positive/negative values) and the Spotify Premium requirement. However, it doesn't mention side effects (e.g., whether it affects playback state), error conditions (e.g., invalid deviceId), or response format. It adds value beyond the schema but leaves gaps in behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by concise usage notes. Every sentence adds value (directionality and Premium requirement) with zero waste. It's efficiently structured for quick comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It covers the basic operation and Premium requirement but lacks details on behavioral outcomes (e.g., what happens on success/failure) and doesn't leverage context from siblings (e.g., contrasting with 'setVolume'). It's adequate but could be more comprehensive for a mutation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters. The description adds minimal semantic context: it clarifies the meaning of positive/negative values for 'adjustment' but doesn't provide additional insights beyond what's in the schema (e.g., typical usage ranges or deviceId sourcing). With high schema coverage, the baseline is 3, and the description meets this without significant enhancement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Adjust the playback volume up or down by a relative amount.' It specifies the verb ('adjust') and resource ('playback volume'), and distinguishes it from sibling tools like 'setVolume' by indicating relative adjustment rather than absolute setting. However, it doesn't explicitly contrast with 'setVolume' beyond the 'relative amount' phrasing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides some usage context: 'Use positive values to increase, negative to decrease. Requires Spotify Premium.' This implies when to use it (for relative volume changes with Premium) but doesn't explicitly state when to choose this over alternatives like 'setVolume' or mention prerequisites beyond Premium. It offers basic guidance but lacks explicit comparison or exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/marcelmarais/spotify-mcp-server'

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