Sandbox
@rianvdm/lastfm-mcp

Last.fm MCP server for Claude Code and Windsurf

This is a Last.fm connector that exposes music data through MCP. It gives assistants public track and artist lookups without sign-in, and personal listening tools after OAuth login. The server also publishes MCP resources and prompts for listening analysis and music discovery.

47 stars7 forksTypeScriptUpdated 19d ago
Who it's for

Builders who want their agent to query Last.fm track, artist, album, and listening history data.

What it delivers

You can ask your agent about your music history and get Last.fm data without leaving your chat or editor.

What it does

Public music lookups

Provides track, artist, album, similar artist, and similar track tools without requiring sign-in.

Personal listening access

Adds recent tracks, top artists, top albums, loved tracks, user profile, stats, and recommendations after OAuth login.

Historical charts

Lets you query weekly artist and track charts to answer questions about when you listened to something.

MCP resources and prompts

Publishes `lastfm://` resources and prompts like listening insights, music discovery, and track analysis.

Cloudflare Workers OAuth server

Uses OAuth 2.0 with Cloudflare Workers, KV storage, and rate limiting for shared API access.

How to get it

  1. 1Run
    claude mcp add --transport http lastfm "https://lastfm-mcp.com/mcp"
  2. 2Run
    npx @modelcontextprotocol/inspector https://lastfm-mcp.com/mcp
  3. 3Run
    git clone https://github.com/rianvdm/lastfm-mcp.git
    cd lastfm-mcp
    npm install
  4. 4Create .dev.vars (or copy .dev.vars.example)
    LASTFM_API_KEY=your_api_key
    LASTFM_SHARED_SECRET=your_shared_secret
  5. 5Run
    npm run dev
  6. 6Test with the inspector
    npx @modelcontextprotocol/inspector http://localhost:8787/mcp

README

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 with OAuth 2.0 authentication. Public tools (track info, artist info, similar artists) work without signing in -- connect your Last.fm account to access personal listening data.

Quick start

Claude.ai / Claude Desktop

  1. Open Settings -> Connectors -> Add Custom Connector
  2. Enter https://lastfm-mcp.com/mcp
  3. Sign in to Last.fm when prompted

Claude Code

claude mcp add --transport http lastfm "https://lastfm-mcp.com/mcp"

Windsurf

Add to ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "lastfm": {
      "serverUrl": "https://lastfm-mcp.com/mcp"
    }
  }
}

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/mcp

Authentication

The server uses OAuth 2.0. When you connect from a supported client, your browser opens to Last.fm to authorize access. Tokens persist across sessions.

Public tools work without signing in. You only need to connect your account for personal listening data.

Available tools

Public tools

ToolDescription
get_track_infoDetailed information about a track
get_artist_infoArtist information and bio
get_album_infoAlbum details and track listing
get_artist_top_tracksAn artist's globally most-played tracks
get_artist_top_albumsAn artist's globally most-played albums
get_similar_artistsArtists similar to a given artist
get_similar_tracksTracks similar to a given track
pingTest connectivity
server_infoServer status and capabilities
lastfm_auth_statusCheck authentication status

Personal tools (requires sign-in)

ToolDescription
get_recent_tracksRecent listening history (paginated)
get_top_artistsTop artists by time period
get_top_albumsTop albums by time period
get_top_tracksTop tracks by time period
get_loved_tracksLoved/favorited tracks
get_user_infoLast.fm profile information
get_listening_statsListening statistics
get_music_recommendationsPersonalized recommendations

Temporal queries (requires sign-in)

ToolDescription
get_weekly_chart_listAvailable historical time periods
get_weekly_artist_chartArtist charts for a specific time period
get_weekly_track_chartTrack 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 tracks

Prompts

PromptDescriptionArguments
listening_insightsAnalyze listening habits and patternsusername, period?
music_discoveryDiscover music based on listening historyusername, genre?
track_analysisDetailed analysis of a trackartist, track
album_analysisDetailed analysis of an albumartist, album
artist_analysisDetailed analysis of an artistartist
listening_habitsSummarize listening habitsusername, timeframe?

Development

Prerequisites

  • Node.js 20 or newer (CI runs 20)
  • 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 install

Create .dev.vars (or copy .dev.vars.example):

LASTFM_API_KEY=your_api_key
LASTFM_SHARED_SECRET=your_shared_secret
npm run dev

Test with the inspector:

npx @modelcontextprotocol/inspector http://localhost:8787/mcp

Deployment

Set production secrets (or run npm run setup:prod, which creates the KV namespaces and prompts for these):

echo "your_api_key" | wrangler secret put LASTFM_API_KEY --env production
echo "your_shared_secret" | wrangler secret put LASTFM_SHARED_SECRET --env production

Deploy:

npm run deploy:prod

Testing

npm test          # vitest, in workerd via @cloudflare/vitest-pool-workers
npm run lint
npm run build     # wrangler deploy --dry-run: catches type and binding errors

Architecture

  • Runtime: Cloudflare Workers
  • Protocol: MCP (streamable HTTP)
  • Auth: OAuth 2.0 (RFC 9728) via @cloudflare/workers-oauth-provider; the provider owns sessions and tokens
  • Storage: 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 budget
  • API: Last.fm Web API v2.0

Endpoints

EndpointPurpose
/mcpMCP JSON-RPC endpoint (rate-limited per IP)
/authorizeOAuth 2.0 authorization
/oauth/tokenOAuth 2.0 token exchange
/oauth/registerOAuth 2.0 dynamic client registration
/.well-known/oauth-authorization-serverOAuth server metadata
/.well-known/oauth-protected-resourceOAuth resource metadata
/.well-known/mcp.jsonMCP server card (name, version, transport)
/healthHealth check
/Landing page

Contributing

  1. Fork the repo
  2. Create a feature branch
  3. Commit your changes
  4. Open a pull request

License

MIT

Files in the repo

Repository payload26 top-level entries
  • .agents
  • .build
  • .docs
  • .github
  • .vscode
  • .windsurf
  • docs
  • scripts
  • src
  • test
  • .dev.vars.example
  • .editorconfig
  • .eslintrc.cjs
  • .gitignore
  • .nvmrc
  • .prettierrc
  • CLAUDE.md
  • LICENSE
  • opencode.jsonc
  • package-lock.json
  • package.json
  • README.md
  • skills-lock.json
  • tsconfig.json
  • vitest.config.mts
  • wrangler.toml

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface

86k

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

43k

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

14k
okf-memory/
okf-agent-memory

Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300µs in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.

547
tirth8205/
code-review-graph

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.

31k
2akouwu/
reverify

Stop your AI from making things up — it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.

1.1k