Skip to main content
Glama

get-user-playlists

Retrieve a comprehensive list of Spotify playlists from the user's account, enabling easy access and management through the MCP Claude Spotify integration.

Instructions

Get a list of the user's playlists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the 'get-user-playlists' tool. Parses input arguments using GetUserPlaylistsSchema, fetches user's playlists from Spotify API endpoint '/me/playlists', formats the response with playlist details and pagination info.
          if (name === "get-user-playlists") {
            const { limit, offset } = GetUserPlaylistsSchema.parse(args);
    
            const params = new URLSearchParams({
              limit: limit.toString(),
              offset: offset.toString(),
            });
    
            const playlists = await spotifyApiRequest(`/me/playlists?${params}`);
    
            if (playlists.items.length === 0) {
              return {
                content: [
                  {
                    type: "text",
                    text: offset > 0
                      ? "No more playlists found."
                      : "You don't have any playlists.",
                  },
                ],
              };
            }
    
            const formattedPlaylists = playlists.items
              .map(
                (playlist: any) => `
    Name: ${playlist.name}
    ID: ${playlist.id}
    Owner: ${playlist.owner.display_name}
    Tracks: ${playlist.tracks.total}
    Public: ${playlist.public ? "Yes" : "No"}
    URL: ${playlist.external_urls.spotify}
    ---`
              )
              .join("\n");
    
            const paginationInfo = `
    Showing ${offset + 1}-${offset + playlists.items.length} of ${playlists.total} total playlists`;
    
            return {
              content: [
                {
                  type: "text",
                  text: `Your playlists:${paginationInfo}\n${formattedPlaylists}`,
                },
              ],
            };
          }
  • Zod schema for validating input parameters of the get-user-playlists tool: limit (1-50, default 20) and offset (default 0). Used in the handler.
    const GetUserPlaylistsSchema = z.object({
      limit: z.number().min(1).max(50).default(20),
      offset: z.number().min(0).default(0),
    });
  • index.ts:712-728 (registration)
    Tool registration in ListToolsRequestHandler, including name, description, and input schema matching the Zod schema.
    {
      name: "get-user-playlists",
      description: "Get a list of the user's playlists",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "number",
            description: "Maximum number of playlists to return (1-50, default: 20)",
          },
          offset: {
            type: "number",
            description: "The index of the first playlist to return (default: 0)",
          },
        },
      },
    },
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