lastfmcp
Connects to the Last.fm API to read a user's listening history, fetch top artists and tracks, retrieve artist and tag metadata, and generate artist recommendations from similarity and genre-tag graphs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@lastfmcp recommend me new artists based on what I've been listening to this month"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
lastfmcp
A Model Context Protocol (MCP) server that connects Claude to your Last.fm listening history. Ask Claude to recommend new artists, explore genres, or summarize what you've been listening to — all grounded in your actual play data.
How it works
The server exposes four tools that Claude can call during a conversation:
get_playback_history— fetch your recent tracks or top artists/tracks over a time periodget_recommendations— run a fan-out pipeline across Last.fm's similarity graph to surface discovery candidates you're likely to enjoyget_artist_info— look up biography, stats, genre tags, and similar artists for any artistget_tag_info— explore a genre or mood tag and find its top artists
Claude handles the reasoning layer: it reads the raw signals these tools return and synthesizes personalized recommendations with explanations.
Related MCP server: Spotify MCP Server
Requirements
Node.js 18 or later
A Last.fm API key (free, instant)
A Last.fm account with listening history
Setup
1. Clone and build
git clone https://github.com/yourname/lastfmcp
cd lastfmcp
npm install
npm run build2. Get a Last.fm API key
Go to https://www.last.fm/api/account/create, fill in the form (any contact email and application name works), and copy the API key.
3. Configure Claude Desktop
Open ~/Library/Application Support/Claude/claude_desktop_config.json (create it if it doesn't exist) and add:
{
"mcpServers": {
"lastfmcp": {
"command": "node",
"args": ["/absolute/path/to/lastfmcp/dist/index.js"],
"env": {
"LASTFM_API_KEY": "your_api_key_here",
"LASTFM_DEFAULT_USER": "your_lastfm_username"
}
}
}
}Replace the path, API key, and username with your own values. The LASTFM_DEFAULT_USER is used when you don't specify a username in your request — set it to your own account to make every interaction feel seamless.
4. Restart Claude Desktop
Quit and reopen Claude Desktop. The lastfmcp tools will appear in the tool list.
Example prompts
Once set up, try asking Claude:
"What have I been listening to most this month?"
"Recommend me some new artists based on my recent listening."
"I'm in a post-rock mood — what should I listen to?"
"Tell me about Godspeed You! Black Emperor."
"What artists are similar to Four Tet that I haven't heard much of?"
"What were my top 10 artists of all time?"
Environment variables
Variable | Required | Description |
| Yes | Your Last.fm API key. The server will not start without this. |
| No | Last.fm username used when no user is specified in a request. |
| No | Override the Last.fm API base URL. Defaults to |
Tools reference
get_playback_history
Fetches listening history for a Last.fm user.
Parameter | Type | Default | Description |
| string | default user | Last.fm username |
|
| — | Which history view to fetch |
|
|
| Time window for top views |
| number (1–50) | 20 | Number of results |
get_artist_info
Returns biography, listener stats, genre tags, and similar artists for a named artist.
Parameter | Type | Default | Description |
| string | — | Artist name |
| boolean |
| Include up to 5 similar artists |
| boolean |
| Include top 5 tracks |
get_tag_info
Returns a description and top artists for a music tag or genre.
Parameter | Type | Default | Description |
| string | — | Tag name (e.g. |
| boolean |
| Include top artists for the tag |
| number (1–20) | 10 | Number of top artists |
get_recommendations
Runs a multi-step pipeline to generate artist discovery candidates:
Fetches the user's top artists for the given period (seeds)
Fans out to Last.fm's similar-artist graph for each seed
Fetches the user's genre tags and the seeds' tags to compute overlap
Deduplicates candidates, removes already-known artists, and ranks by similarity
Returns a structured candidate list with similarity scores, which artists triggered each recommendation, and shared genre tags. Claude then reasons over this data to produce a personalized recommendation.
Parameter | Type | Default | Description |
| string | default user | Last.fm username |
|
|
| Time period for top artists |
| number (3–15) | 8 | Number of top artists to use as seeds |
| number (5–20) | 10 | Similar artists fetched per seed |
| number (5–50) | 25 | Maximum candidates returned |
Note: A cold call fetches roughly 40 Last.fm API requests and takes 10–15 seconds. Subsequent calls within the same session return in under a second thanks to in-memory caching.
Development
npm run dev # run directly with tsx (no build step)
npm test # run all tests
npm run build # compile to dist/Tests use Vitest and mock all external dependencies. No Last.fm API key is needed to run them.
Caching
All Last.fm responses are cached in memory for the duration of the server process:
Data | Cache duration |
Recent tracks | 2 minutes |
Top artists / tracks / tags | 10 minutes |
Artist and tag metadata | 60 minutes |
The cache is process-scoped — it resets when Claude Desktop restarts the server.
Rate limiting
The server serializes all Last.fm API requests with a 200ms gap between calls, staying within Last.fm's guideline of ~5 requests per second. If a rate limit error is returned, the request is retried once after one second.
Available Tools
4 toolsget_artist_infoA
Retrieves detailed information about a specific music artist from Last.fm. Returns a biography summary, listener and play statistics, top tags (genres/moods), similar artists, and optionally top tracks. Use this when you need to explain why an artist might appeal to a user, or to explore an unfamiliar name from a recommendation list.
Inputs: artist (required), include_similar, include_top_tracks.
get_playback_historyA
Retrieves a Last.fm user's listening history. Use this to understand what music someone has been playing. Provides three views: recent_tracks (chronological, most recent plays), top_artists or top_tracks (aggregated by play count over a time period). Call this first to understand a user's taste before making recommendations.
Inputs: view (required), user, limit, period.
get_recommendationsA
Generates a raw candidate list for music artist recommendations by combining a user's top artists with their similar artists and shared tag analysis. Returns a deduplicated list of artists the user likely doesn't know well yet, along with signals explaining each candidate (which known artist triggered them, similarity score, shared tags). This provides the raw material — use your own reasoning to rank, explain, and personalize the final recommendations. Note: a cold call fetches ~40 API requests and takes 10-15 seconds; subsequent calls are fast due to caching.
Inputs: user, period, max_candidates, similar_per_seed, +1 more.
get_tag_infoA
Retrieves information about a music tag or genre from Last.fm, including a description and the top artists associated with that tag. Use this when a user mentions a genre, mood, or style, or when you want to find artists in a specific niche that overlaps with a user's known taste.
Inputs: tag (required), limit, include_top_artists.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a distinct entity: user history, an artist, a tag/genre, and a recommendation candidate list. get_recommendations internally uses history data, but the descriptions make the boundary explicit and the intended call order (history first, then recommendations) removes any overlap.
All four tools follow a uniform snake_case get_<noun> pattern (get_playback_history, get_artist_info, get_tag_info, get_recommendations). The convention is predictable and readable throughout.
Four tools is lean but each serves a clear role in a read-only taste-analysis workflow. It sits at the low end of the range and could reasonably add a lookup/search tool, but nothing here feels redundant or missing its purpose.
The core discovery chain (history -> artist/tag exploration -> recommendations) is covered, but there is no artist/track/album search tool, no track-level metadata, and no user profile or write operations (love/rate). Agents can work around this with tag and artist lookups, but gaps are notable for a Last.fm surface.
Maintenance
Related MCP Connectors
Connect Claude to Fathom meeting recordings, transcripts, and summaries
Connect Claude to your Platform7n workspaces: chat, links, work and decks. One-click OAuth.
Connect Claude to your Platform7n workspaces: chat, links, work and decks. One-click OAuth.
Connect Claude to your Intervals.icu watch data for fitness, workout review, and plan writing.
Related MCP Servers
- AlicenseCqualityDmaintenanceA tool that connects to the Spotify API and enables Claude to access artist information for enhanced music discovery through natural language queries.1ISC
- AlicenseNot gradedqualityNot gradedmaintenanceConnects Claude to Spotify for music discovery, playlist creation, and collection analysis through natural language. Enables searching songs, analyzing music diversity, creating playlists, and getting recommendations using Spotify's API.-
- FlicenseNot gradedqualityDmaintenanceEnables Claude to analyze the song you're currently playing on Spotify by looking up what's playing via Last.fm and fetching lyrics from Genius.-
- AlicenseBqualityCmaintenanceEnables Claude to manage Spotify playlists and analyze personal listening history, including account reads, playlist writes, local analytics from data exports, and building playlists from track lists.35MIT