Skip to main content
Glama

pause-playback

Control Spotify playback by pausing music directly through Claude Desktop. Integrates with MCP Claude Spotify for easy natural language commands.

Instructions

Pause the user's playback

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • index.ts:688-695 (registration)
    Registration of the 'pause-playback' tool in the ListTools response, including its name, description, and empty input schema.
    {
      name: "pause-playback",
      description: "Pause the user's playback",
      inputSchema: {
        type: "object",
        properties: {},
      },
    },
  • Handler implementation for the 'pause-playback' tool. It makes a PUT request to Spotify's /me/player/pause endpoint using the shared spotifyApiRequest helper.
    if (name === "pause-playback") {
      await spotifyApiRequest("/me/player/pause", "PUT");
      
      return {
        content: [
          {
            type: "text",
            text: "Playback paused.",
          },
        ],
      };
    }
  • Shared helper function spotifyApiRequest used by the pause-playback handler (and other tools) to make authenticated API calls to Spotify.
    async function spotifyApiRequest(endpoint: string, method: string = "GET", data: any = null) {
      console.error(`Starting API request to ${endpoint}`);
    
      if (!accessToken || !refreshToken) {
        console.error(`No tokens in memory, trying to load from file...`);
        try {
          if (fs.existsSync(TOKEN_PATH)) {
            const fileContent = fs.readFileSync(TOKEN_PATH, 'utf8');
            console.error(`Read ${fileContent.length} bytes from token file`);
            
            if (fileContent.trim() !== '') {
              const tokenData = JSON.parse(fileContent);
              accessToken = tokenData.accessToken;
              refreshToken = tokenData.refreshToken;
              tokenExpirationTime = tokenData.tokenExpirationTime;
              console.error(`Tokens loaded successfully`);
            } else {
              console.error(`Token file is empty, cannot load tokens`);
            }
          } else {
            console.error(`Token file does not exist: ${TOKEN_PATH}`);
          }
        } catch (err) {
          console.error(`Error loading tokens from file: ${err}`);
        }
      }
    
      if (!accessToken) {
        console.error(`No access token available for request to ${endpoint}`);
        throw new Error("Not authenticated. Please authorize the app first.");
      }
    
      const now = Date.now();
      if (now >= tokenExpirationTime - 60000) {
        if (refreshToken) {
          try {
            console.error(`Token expired, attempting to refresh...`);
            const response = await axios.post(
              `${SPOTIFY_AUTH_BASE}/api/token`,
              querystring.stringify({
                grant_type: "refresh_token",
                refresh_token: refreshToken,
              }),
              {
                headers: {
                  "Content-Type": "application/x-www-form-urlencoded",
                  Authorization: `Basic ${Buffer.from(
                    `${CLIENT_ID}:${CLIENT_SECRET}`
                  ).toString("base64")}`,
                },
              }
            );
            
            accessToken = response.data.access_token;
            tokenExpirationTime = now + response.data.expires_in * 1000;
            
            if (response.data.refresh_token) {
              refreshToken = response.data.refresh_token;
            }
            
            console.error(`Token refreshed successfully, expires at ${new Date(tokenExpirationTime).toISOString()}`);
            
            try {
              if (!fs.existsSync(TOKEN_DIR)) {
                fs.mkdirSync(TOKEN_DIR, { recursive: true });
              }
              
              const tokenData = JSON.stringify({
                accessToken,
                refreshToken,
                tokenExpirationTime
              }, null, 2);
              
              fs.writeFileSync(TOKEN_PATH, tokenData);
              console.error(`Refreshed tokens saved to file`);
            } catch (saveError) {
              console.error(`Failed to save refreshed tokens: ${saveError}`);
            }
          } catch (refreshError) {
            console.error(`Failed to refresh token: ${refreshError}`);
            accessToken = null;
            refreshToken = null;
            tokenExpirationTime = 0;
            throw new Error("Authentication expired. Please authenticate again.");
          }
        } else {
          console.error(`Token expired but no refresh token available`);
          accessToken = null;
          tokenExpirationTime = 0;
          throw new Error("Authentication expired. Please authenticate again.");
        }
      }
      
      console.error(`Making authenticated request to ${endpoint}`);
      
      try {
        const response = await axios({
          method,
          url: `${SPOTIFY_API_BASE}${endpoint}`,
          headers: {
            Authorization: `Bearer ${accessToken}`,
            "Content-Type": "application/json",
          },
          data: data ? data : undefined,
        });
        
        console.error(`Request to ${endpoint} succeeded`);
        return response.data;
      } catch (error: any) {
        console.error(`Spotify API error: ${error.message}`);
        if (error.response) {
          console.error(`Status: ${error.response.status}`);
          console.error(`Data:`, error.response.data);
          
          if (error.response.status === 401) {
            console.error(`Token appears to be invalid, clearing tokens`);
            accessToken = null;
            refreshToken = null;
            tokenExpirationTime = 0;
            throw new Error("Authorization expired. Please authenticate again.");
          }
        }
        throw new Error(`Spotify API error: ${error.message}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action but doesn't mention side effects (e.g., whether playback can be resumed, if it requires specific permissions, or error conditions like no active playback). This leaves significant gaps for a mutation tool.

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 a single, efficient sentence with no wasted words. It's appropriately sized for a simple tool and front-loads the essential action, making it easy to parse quickly.

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

Completeness2/5

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

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after pausing, potential errors, or return values, leaving the agent with incomplete operational context.

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?

The tool has zero parameters with 100% schema description coverage, so the schema already fully documents the lack of inputs. The description appropriately doesn't add unnecessary parameter information, maintaining a clean baseline for parameterless tools.

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 action ('Pause') and target ('the user's playback'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'play-track' or 'get-current-playback' beyond the obvious pause vs play distinction, which prevents a perfect score.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'play-track' or 'next-track', nor does it mention prerequisites such as requiring active playback. The description only states what it does without contextual usage information.

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

Related 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/imprvhub/mcp-claude-spotify'

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