Skip to main content
Glama

Spotify-Claude MCP Server

by DivyamAgg24

get_artist

Retrieve artist names from Spotify to enhance music discovery via natural language queries on the Claude platform. Supports GET/POST requests for streamlined data access.

Instructions

Get Artist name

Input Schema

NameRequiredDescriptionDefault
methodYesGet or post request

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "method": { "description": "Get or post request", "minLength": 3, "type": "string" } }, "required": [ "method" ], "type": "object" }

Implementation Reference

  • Handler function that fetches artist data from Spotify API using the provided HTTP method, processes the response, extracts artist names, and returns them in a text content format.
    async ({ method }) => { const methodUpper = method.toUpperCase(); const artistData = await fetch("https://api.spotify.com/v1/artists?ids=0TnOYISbd1XYRBk9myaseg", { headers: { Authorization: `Bearer ${accessToken}`, }, method }) if (!artistData) { return { content: [ { type: "text", text: "Failed to retrieve tracks", }, ], }; } const allArtistsData = await artistData.json() console.log(allArtistsData) const data = allArtistsData.artists || []; if (data.length===0) { return { content: [ { type: "text", text: `No artists`, }, ], }; } let names = [] for(let i = 0; i<data.length; i++){ names.push(data[i].name) } const finalOutput = `Artist name is ${names}`; return { content: [ { type: "text", text: finalOutput, }, ], }; },
  • Zod schema defining the input parameter 'method' as a string with minimum length 3, described as 'Get or post request'.
    { method: z.string().min(3).describe("Get or post request") },
  • src/index.ts:15-69 (registration)
    Registration of the 'get_artist' tool using server.tool(), including name, description, input schema, and handler function.
    server.tool( "get_artist", "Get Artist name", { method: z.string().min(3).describe("Get or post request") }, async ({ method }) => { const methodUpper = method.toUpperCase(); const artistData = await fetch("https://api.spotify.com/v1/artists?ids=0TnOYISbd1XYRBk9myaseg", { headers: { Authorization: `Bearer ${accessToken}`, }, method }) if (!artistData) { return { content: [ { type: "text", text: "Failed to retrieve tracks", }, ], }; } const allArtistsData = await artistData.json() console.log(allArtistsData) const data = allArtistsData.artists || []; if (data.length===0) { return { content: [ { type: "text", text: `No artists`, }, ], }; } let names = [] for(let i = 0; i<data.length; i++){ names.push(data[i].name) } const finalOutput = `Artist name is ${names}`; return { content: [ { type: "text", text: finalOutput, }, ], }; }, )

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/DivyamAgg24/SpotifyMCP'

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