Skip to main content
Glama

start_playback

Initiate Spotify music playback for tracks, albums, playlists, or artists. Use this tool to start music on smart devices, create voice-activated requests, or build custom music interfaces.

Instructions

Initiate music playback with specific tracks, albums, playlists, or artist collections.

🎯 USE CASES: • Start playing music when users enter smart spaces • Create voice-activated music requests • Build custom music controllers and interfaces • Implement mood-based automatic music selection • Start themed playlists for events, workouts, or activities

📝 WHAT IT RETURNS: • Confirmation of playback initiation • Current track information and playback state • Device information where playback started • Error details if playback couldn't start • Queue information showing what will play next

🔍 EXAMPLES: • "Play my Discover Weekly playlist" • "Start playing the album 'Abbey Road'" • "Play tracks by The Beatles on my laptop" • "Begin playback of my liked songs"

🎵 PLAYBACK OPTIONS: • contextUri: Play entire albums, playlists, or artist catalogs • trackUris: Play specific individual tracks in order • deviceId: Choose which device should start playing • Can resume from where you left off or start fresh

⚠️ REQUIREMENTS: • Valid Spotify access token with user-modify-playback-state scope • User must have an active Spotify device available • Content must be available in user's market

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesSpotify access token for authentication
contextUriNo
trackUrisNo
deviceIdNoSpotify device ID (optional, uses active device if not specified)

Implementation Reference

  • The core handler function for the 'start_playback' MCP tool. It destructures the input arguments and delegates to SpotifyService.playMusic to initiate playback.
    handler: async (args: any, spotifyService: SpotifyService) => {
      const { token, contextUri, trackUris, deviceId } = args;
      return await spotifyService.playMusic(
        token,
        trackUris,
        contextUri,
        deviceId
      );
    },
  • Zod-based input schema for the 'start_playback' tool, defining parameters for token, context URI, track URIs, and target device.
    schema: createSchema({
      token: commonSchemas.token(),
      contextUri: z
        .string()
        .optional()
        .describe("Spotify context URI (album, playlist, artist) to play"),
      trackUris: z
        .array(z.string())
        .optional()
        .describe("Array of specific track URIs to play"),
      deviceId: commonSchemas.deviceId(),
    }),
  • Supporting method in SpotifyService that performs the actual Spotify API call to start playback (/me/player/play), handling track URIs, context URI, and device targeting.
    async playMusic(
      token: string,
      trackUris: string | string[] | null = null,
      contextUri: string | null = null,
      deviceId: string | null = null
    ): Promise<void> {
      const data: Record<string, any> = {};
    
      if (trackUris) {
        data.uris = Array.isArray(trackUris)
          ? trackUris
          : [`spotify:track:${this.extractId(trackUris)}`];
      }
    
      if (contextUri) {
        data.context_uri = contextUri;
      }
    
      const endpoint = deviceId
        ? `me/player/play?device_id=${deviceId}`
        : "me/player/play";
    
      return await this.makeRequest<void>(endpoint, token, {}, "PUT", data);
  • Registration of all tools, including playbackTools (which contains start_playback), into the central allTools registry used by ToolRegistrar for MCP server integration.
    export const allTools: ToolsRegistry = {
      ...albumTools,
    
      ...artistTools,
    
      ...trackTools,
    
      ...playlistTools,
    
      ...playbackTools,
    
      ...userTools,
    
      ...searchTools,
    };
  • MCP server request handler for calling any tool (including start_playback) via ToolRegistrar's createToolHandler, which wraps the original handler with validation.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        const toolHandler = toolRegistrar.createToolHandler(name);
        const result = await toolHandler(args || {});
    
        return {
          content: [
            {
              type: "text",
              text:
                typeof result === "string"
                  ? result
                  : JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error executing tool '${name}': ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
          isError: true,
        };
      }
    });
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing authentication requirements ('Valid Spotify access token'), device requirements ('active Spotify device available'), market restrictions, and return information. It could improve by mentioning rate limits or error handling specifics, but covers most critical behavioral aspects.

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 well-structured with clear sections (USE CASES, WHAT IT RETURNS, EXAMPLES, PLAYBACK OPTIONS, REQUIREMENTS) and every sentence adds value. It's appropriately detailed for a complex playback initiation tool without unnecessary verbosity.

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

Completeness4/5

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

For a 4-parameter tool with no annotations and no output schema, the description provides comprehensive context including return values, examples, usage scenarios, and requirements. The only minor gap is not explicitly documenting all possible error conditions or response formats, but it covers most essential information.

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

Parameters4/5

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

With only 50% schema description coverage (only 'token' and 'deviceId' have descriptions), the description compensates well by explaining 'contextUri' and 'trackUris' in the 'PLAYBACK OPTIONS' section, clarifying their purpose and usage. It adds meaningful context beyond what the sparse schema provides.

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

Purpose5/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 with specific verbs ('initiate music playback') and resources ('tracks, albums, playlists, or artist collections'). It distinguishes this from sibling tools like 'pause_player', 'resume_player', or 'search_and_play_music' by focusing specifically on starting playback with various content types.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance through the 'USE CASES' section with five specific scenarios, 'PLAYBACK OPTIONS' explaining parameter usage, and 'REQUIREMENTS' detailing prerequisites. It implicitly distinguishes from siblings by focusing on initiation rather than control (pause/resume), queue management, or search-and-play functionality.

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

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