lastfm-mcp
Provides access to Last.fm listening history, music discovery, and detailed track/artist/album information.
Last.fm MCP Server
A Model Context Protocol (MCP) server for Last.fm. Gives AI assistants access to your listening history, music discovery, and detailed track/artist/album information.
Runs on Cloudflare Workers. Your MCP client signs you in with OAuth the first time it connects, and after that every tool is available, from track and artist lookups to your own listening history.
Quick start
lastfm-mcp.com has setup steps for each app, including ChatGPT, Codex, Cursor, Devin Desktop (formerly Windsurf) and OpenCode. If an AI agent is setting it up for you, point it at lastfm-mcp.com/llms.txt.
Claude.ai / Claude Desktop
Go to Customize -> Connectors
Click Add, then Add custom connector. Name it Last.fm, enter
https://lastfm-mcp.com/mcpand click ContinueLeave the sign-in settings as they are, click Add, then Connect, and sign in to Last.fm
Claude Code
claude mcp add --scope user --transport http lastfm "https://lastfm-mcp.com/mcp"Then start Claude Code, run /mcp, choose lastfm, then Authenticate, and sign in to Last.fm in your browser.
Other MCP clients
For clients that don't support remote servers directly (Continue.dev, Zed, etc.), use mcp-remote:
{
"mcpServers": {
"lastfm": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://lastfm-mcp.com/mcp"]
}
}
}MCP Inspector
npx @modelcontextprotocol/inspector https://lastfm-mcp.com/mcpRelated MCP server: lastfm-mcp
Authentication
The server uses OAuth 2.0. The first time your client connects, your browser opens a short page on lastfm-mcp.com that names the app asking for access and the address that access will go to. Approve it, then sign in to Last.fm. That browser remembers the approval for a year, so reconnecting the same app skips the page.
Access is read-only: the server can read your listening history and profile, but it can't scrobble or change anything. Sign-ins expire after 30 days, and your client then asks you to sign in again.
Available tools
Lookups and diagnostics
Tool | Description |
| Detailed information about a track |
| Artist information and bio |
| Album details and track listing |
| An artist's globally most-played tracks |
| An artist's globally most-played albums |
| Artists similar to a given artist |
| Tracks similar to a given track |
| Test connectivity |
| Server status and capabilities |
| Check authentication status |
Your listening data
Tool | Description |
| Recent listening history (paginated) |
| Top artists by time period |
| Top albums by time period |
| Top tracks by time period |
| Loved/favorited tracks |
| Last.fm profile information |
| Listening statistics |
| New-to-you artists, with the reason for each pick and starter tracks |
Your listening history over time
Tool | Description |
| Available historical time periods |
| Artist charts for a specific time period |
| Track charts for a specific time period |
Good for questions like "when did I start listening to Led Zeppelin?" or "what was I into last March?"
Resources
The server exposes MCP resource URIs:
lastfm://user/{username}/recent # Recent tracks
lastfm://user/{username}/top-artists # Top artists
lastfm://user/{username}/top-albums # Top albums
lastfm://user/{username}/loved # Loved tracks
lastfm://user/{username}/profile # User profile
lastfm://track/{artist}/{track} # Track info
lastfm://artist/{artist} # Artist info
lastfm://album/{artist}/{album} # Album info
lastfm://artist/{artist}/similar # Similar artists
lastfm://track/{artist}/{track}/similar # Similar tracksPrompts
Prompt | Description | Arguments |
| Analyze listening habits and patterns |
|
| Discover music based on listening history |
|
| Detailed analysis of a track |
|
| Detailed analysis of an album |
|
| Detailed analysis of an artist |
|
| Summarize listening habits |
|
Development
Prerequisites
Node.js 22 (see
.nvmrc; CI runs 22)Cloudflare Workers account
Last.fm API key (create one here)
Local setup
git clone https://github.com/rianvdm/lastfm-mcp.git
cd lastfm-mcp
npm installCreate .dev.vars (or copy .dev.vars.example):
LASTFM_API_KEY=your_api_key
LASTFM_SHARED_SECRET=your_shared_secret
CONSENT_SECRET=any_random_string_of_32_or_more_charactersnpm run devTest with the inspector:
npx @modelcontextprotocol/inspector http://localhost:8787/mcpDeployment
Set production secrets (or run npm run setup:prod, which creates the KV namespaces, prompts for the two Last.fm values and generates CONSENT_SECRET):
echo "your_api_key" | wrangler secret put LASTFM_API_KEY --env production
echo "your_shared_secret" | wrangler secret put LASTFM_SHARED_SECRET --env production
openssl rand -base64 32 | wrangler secret put CONSENT_SECRET --env productionCONSENT_SECRET signs the cookie that remembers which apps a browser approved. Rotating it shows the consent page again to everyone; if it's missing or shorter than 32 characters, approvals aren't remembered, but sign-ins still work.
Upgrading a deployment from v2.6.0 or earlier: v2.7.0 added the consent page and the CONSENT_SECRET secret. Set it with the openssl line above before you deploy, or right after. Until it's set, the consent page shows on every sign-in.
Deploy:
npm run deploy:prodTesting
npm test # vitest, in workerd via @cloudflare/vitest-pool-workers
npm run lint
npm run build # wrangler deploy --dry-run: catches type and binding errorsArchitecture
Runtime: Cloudflare Workers
Protocol: MCP (streamable HTTP)
Auth: OAuth 2.0 (RFC 9728) via
@cloudflare/workers-oauth-provider; the provider owns sessions and tokensStorage: Cloudflare KV for OAuth state, sessions, caching, and rate-limit counters
Rate limiting: per-IP on
/mcp, so one client can't exhaust the shared Last.fm API key's budgetAPI: Last.fm Web API v2.0
Endpoints
Endpoint | Purpose |
| MCP JSON-RPC endpoint (rate-limited per IP) |
| OAuth 2.0 authorization |
| OAuth 2.0 token exchange |
| OAuth 2.0 dynamic client registration |
| OAuth server metadata |
| OAuth resource metadata |
| MCP server card (name, version, transport) |
| Setup instructions for AI agents |
| Health check |
| Landing page |
Contributing
Fork the repo
Create a feature branch
Commit your changes
Open a pull request
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for Producer/Riffusion AI music generation
Social media MCP server: your Instagram, TikTok, YouTube, LinkedIn and Threads history for your AI.
Official Fibery MCP server: query and update your workspace from any AI client via OAuth.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceSearch, rate and organise your Discogs collection, wantlist and folders from an AI assistant. Self-hosted: deploy your own copy to Cloudflare Workers with the Deploy to Cloudflare button in the README. Not affiliated with Discogs.20MIT
- AlicenseAqualityDmaintenanceAn MCP server for the Last.fm API that enables LLM agents to access music data including user profiles, listening history, top charts, search, and artist/album/track metadata.16MIT
- AlicenseAqualityCmaintenanceMCP server to control Spotify conversationally from Claude, Cursor, and other AI clients.11364 npm2MIT
- AlicenseNot gradedqualityBmaintenanceAn MCP server for the Last.fm API, exposing artist, album, track, chart, and user data as read-only tools. Supports optional writes, auth, and experimental methods over stdio or HTTP.MIT