Skip to main content
Glama

search_tracks

Search and retrieve Spotify tracks by entering a query and optional limit. Part of the Multi-MCPs server, which integrates multiple APIs for unified access to web services.

Instructions

Search tracks on Spotify

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
queryYes

Implementation Reference

  • The handler function that implements the core logic for the 'search_tracks' tool. It validates the Spotify configuration, extracts and validates the query and optional limit parameters, and calls the SpotifyClient's searchTracks method.
    async search_tracks(args: Record<string, unknown>) { if (!cfg.spotifyClientId || !cfg.spotifyClientSecret) throw new Error("SPOTIFY_CLIENT_ID/SECRET are not configured"); const query = String(args.query || ""); if (!query) throw new Error("query is required"); const limit = args.limit ? Number(args.limit) : undefined; return client.searchTracks(query, limit); },
  • Input schema for the 'search_tracks' tool, defining an object with required 'query' (string) and optional 'limit' (number).
    inputSchema: { type: "object", properties: { query: { type: "string" }, limit: { type: "number" } }, required: ["query"], },
  • Registration of the 'search_tracks' tool in the tools array of the Spotify ToolRegistration, including name, description, and input schema.
    { name: "search_tracks", description: "Search tracks on Spotify", inputSchema: { type: "object", properties: { query: { type: "string" }, limit: { type: "number" } }, required: ["query"], }, },
  • Helper method in SpotifyClient class that performs the actual API request to Spotify's search endpoint for tracks.
    async searchTracks(query: string, limit?: number) { return this.request("/search", { headers: await this.authHeaders(), query: { q: query, type: "track", limit: limit ?? 10 }, }); }

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/TaylorChen/muti-mcps'

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