Skip to main content
Glama
superseoworld

MCP Spotify Server

search

Find tracks, albums, artists, or playlists in Spotify's music catalog using specific search queries and filters.

Instructions

Search for tracks, albums, artists, or playlists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
typeYesType of item to search for
limitNoMaximum number of results (1-50)

Implementation Reference

  • The SearchHandler class provides the core implementation of the 'search' tool, handling input validation and making an API request to Spotify's search endpoint.
    export class SearchHandler {
      constructor(private api: SpotifyApi) {}
    
      async search(args: SearchArgs) {
        const { query, type, limit = 20 } = args;
    
        if (limit < 1 || limit > 50) {
          throw new McpError(
            ErrorCode.InvalidParams,
            'Limit must be between 1 and 50'
          );
        }
    
        const params = {
          q: encodeURIComponent(query),
          type,
          limit
        };
    
        return this.api.makeRequest(`/search${this.api.buildQueryString(params)}`);
      }
    } 
  • TypeScript interfaces defining the input (SearchArgs) and output (SearchResponse) structures for the 'search' tool.
    export interface SearchArgs {
      query: string;
      type: 'track' | 'album' | 'artist' | 'playlist';
      limit?: number;
    }
    
    export interface SearchResponse {
      tracks?: {
        items: any[];
        limit: number;
        next: string | null;
        offset: number;
        previous: string | null;
        total: number;
      };
      albums?: {
        items: any[];
        limit: number;
        next: string | null;
        offset: number;
        previous: string | null;
        total: number;
      };
      artists?: {
        items: any[];
        limit: number;
        next: string | null;
        offset: number;
        previous: string | null;
        total: number;
      };
      playlists?: {
        items: any[];
        limit: number;
        next: string | null;
        offset: number;
        previous: string | null;
        total: number;
      };
    } 
  • src/index.ts:116-140 (registration)
    Registration of the 'search' tool in the ListTools response, including name, description, and input schema.
      name: 'search',
      description: 'Search for tracks, albums, artists, or playlists',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query'
          },
          type: {
            type: 'string',
            description: 'Type of item to search for',
            enum: ['track', 'album', 'artist', 'playlist']
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results (1-50)',
            minimum: 1,
            maximum: 50,
            default: 20
          }
        },
        required: ['query', 'type']
      },
    },
  • src/index.ts:702-708 (registration)
    Handler for CallTool requests named 'search', which validates arguments and delegates to SearchHandler.search().
    case 'search': {
      const args = this.validateArgs<SearchArgsType>(request.params.arguments, ['query', 'type']);
      const result = await this.searchHandler.search(args);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • src/index.ts:87-87 (registration)
    Instantiation of the SearchHandler instance used by the MCP server.
    this.searchHandler = new SearchHandler(this.api);
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 what the tool does but reveals nothing about rate limits, authentication requirements, pagination behavior, or result format. For a search tool with no annotation coverage, this leaves significant behavioral unknowns that could impact agent decisions.

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 that states the core functionality without unnecessary words. It's appropriately sized for a search tool and front-loads the essential information. Every word earns its place in this concise formulation.

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?

Given no annotations, no output schema, and multiple sibling tools with overlapping functionality, the description is insufficiently complete. It doesn't address how results are returned, what authentication is needed, or how this tool relates to the many specific retrieval tools in the sibling list. For a search tool in this context, more guidance is needed.

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 already documents all three parameters thoroughly. The description mentions the searchable types which aligns with the 'type' parameter's enum values, but adds no additional semantic context beyond what's in the schema. This meets the baseline expectation when schema coverage is complete.

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 verb 'search' and specifies the resources: 'tracks, albums, artists, or playlists'. It distinguishes this as a general search function, but doesn't explicitly differentiate it from sibling tools like get_recommendations or get_category_playlists which also retrieve content. The purpose is clear but sibling differentiation is incomplete.

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?

The description provides no guidance on when to use this tool versus alternatives. With many sibling tools that retrieve specific content (like get_album, get_artist, get_playlist), there's no indication whether this search tool should be used first for discovery or when the exact identifier is known. No exclusions or preferred contexts are mentioned.

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

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