A Model Context Protocol (MCP) server that provides seamless access to Last.fm listening data and music information via AI assistants like Claude.
A powerful, production-ready server that bridges AI assistants with Last.fm's comprehensive music database.
- π§ Personal Listening Data: Recent tracks, top artists, albums, loved tracks
- π΅ Music Information: Detailed track, artist, and album information
- π Music Discovery: Similar artists/tracks, personalized recommendations
- π Listening Statistics: Comprehensive stats and listening habits analysis
- π Secure Authentication: Last.fm Web Authentication with JWT sessions
- β‘ Smart Caching: Intelligent caching with optimized TTLs for performance
- π‘οΈ Rate Limiting: Built-in rate limiting respecting Last.fm API limits
- π Production Ready: Deployed on Cloudflare Workers with global edge and CI/CD
The easiest way to get started:
claude mcp add --transport http lastfm https://lastfm-mcp-prod.rian-db8.workers.devThat's it! Claude Code now supports HTTP transport natively, no additional tools needed.
Recommended Method (Connectors UI):
Claude Desktop now supports remote MCP servers natively:
- Open Claude Desktop
- Go to Settings β Connectors
- Click Add Connector
- Enter the server URL:
https://lastfm-mcp-prod.rian-db8.workers.dev - Click Add
That's it! No configuration files or command-line tools needed. The server will appear in your Connectors list and be ready to use.
Alternative Method (Configuration File):
For advanced users who prefer config files, add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"lastfm": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://lastfm-mcp-prod.rian-db8.workers.dev"]
}
}
}π‘ Note: The Connectors UI method is recommended as it's simpler and doesn't require any command-line tools.
This server works with any MCP client that supports Streamable HTTP transport:
Continue.dev (VS Code/JetBrains):
Add to your Continue config (~/.continue/config.json):
{
"mcpServers": {
"lastfm": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://lastfm-mcp-prod.rian-db8.workers.dev"]
}
}
}Zed Editor:
Add to your Zed settings:
{
"context_servers": {
"lastfm": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://lastfm-mcp-prod.rian-db8.workers.dev"]
}
}
}MCP Inspector (Testing):
Test the server directly:
npx @modelcontextprotocol/inspector https://lastfm-mcp-prod.rian-db8.workers.devCustom Implementation:
Use the MCP client SDK for your language:
- TypeScript/JavaScript:
@modelcontextprotocol/sdk - Python:
mcppackage - Server endpoint:
https://lastfm-mcp-prod.rian-db8.workers.dev - Transport: Streamable HTTP (protocol version 2024-11-05 or 2025-06-18)
If you get "spawn npx NOENT" error
For NixOS users:
{
"mcpServers": {
"lastfm": {
"command": "/run/current-system/sw/bin/npx",
"args": ["mcp-remote", "https://lastfm-mcp-prod.rian-db8.workers.dev/sse"],
"env": {
"PATH": "/run/current-system/sw/bin:$PATH"
}
}
}
}For other systems:
- Find your npx path:
which npx - Use the full path in your config:
{
"command": "/usr/local/bin/npx", // Use your actual path
"args": ["mcp-remote", "https://lastfm-mcp-prod.rian-db8.workers.dev/sse"]
}- Try any authenticated tool (like "Get my recent tracks")
- Claude will provide a Last.fm authentication URL
- Sign in with your Last.fm account and authorize the app
- Return to Claude - you're now authenticated!
- Enjoy access to your personal Last.fm data
| Tool | Description |
|---|---|
get_track_info |
Get detailed information about any track |
get_artist_info |
Get detailed artist information and bio |
get_album_info |
Get album details and track listings |
get_similar_artists |
Find artists similar to a given artist |
get_similar_tracks |
Find tracks similar to a given track |
ping |
Test server connectivity |
server_info |
Get server status and capabilities |
auth_status |
Check your authentication status |
| Tool | Description |
|---|---|
get_recent_tracks |
Your recent listening history (supports pagination) |
get_top_artists |
Your top artists by time period |
get_top_albums |
Your top albums by time period |
get_loved_tracks |
Your loved/favorite tracks |
get_user_info |
Your Last.fm profile information |
get_listening_stats |
Comprehensive listening statistics |
get_music_recommendations |
Personalized music recommendations |
| Tool | Description |
|---|---|
get_weekly_chart_list |
Get available historical time periods for temporal analysis |
get_weekly_artist_chart |
Get artist listening data for specific time periods |
get_weekly_track_chart |
Get track listening data for specific time periods |
Perfect for questions like:
- "When did I start listening to Led Zeppelin?"
- "What was I listening to in March 2023?"
- "How has my music taste evolved over time?"
Access Last.fm data via standardized 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
Rich AI prompts for music analysis and discovery:
| Prompt | Description | Arguments |
|---|---|---|
listening_insights |
Analyze user's listening habits and patterns | username, period? |
music_discovery |
Discover new music based on listening history | username, genre? |
track_analysis |
Get detailed analysis of a specific track | artist, track |
album_analysis |
Get detailed analysis of a specific album | artist, album |
artist_analysis |
Get detailed analysis of a specific artist | artist |
listening_habits |
Analyze and summarize user's listening habits | username, timeframe? |
These prompts generate contextual messages that guide AI assistants to provide meaningful music insights using the available Last.fm tools and data.
- Node.js 18+
- Cloudflare Workers account
- Last.fm API credentials (Get them here)
-
Clone and install:
git clone https://github.com/rianvdm/lastfm-mcp.git cd lastfm-mcp npm install -
Configure environment (
.dev.vars):LASTFM_API_KEY=your_api_key_here LASTFM_SHARED_SECRET=your_shared_secret_here JWT_SECRET=your_secure_jwt_secret
-
Start development server:
npm run dev
-
Connect with Claude Code (for interactive testing):
claude mcp add --transport http lastfm-local http://localhost:8787
Or test with MCP Inspector:
npx @modelcontextprotocol/inspector http://localhost:8787
-
Test with curl (for basic API testing):
curl -X POST http://localhost:8787 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_track_info","arguments":{"artist":"The Beatles","track":"Yesterday"}}}'
-
Set production secrets:
echo "your_api_key" | wrangler secret put LASTFM_API_KEY --env production echo "your_shared_secret" | wrangler secret put LASTFM_SHARED_SECRET --env production echo "your_jwt_secret" | wrangler secret put JWT_SECRET --env production
-
Deploy:
wrangler deploy --env production
-
Test production:
curl https://your-worker.workers.dev
Get track information:
curl -X POST https://lastfm-mcp-prod.rian-db8.workers.dev \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_track_info",
"arguments": {
"artist": "Radiohead",
"track": "Paranoid Android"
}
}
}'Find similar artists:
curl -X POST https://lastfm-mcp-prod.rian-db8.workers.dev \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_similar_artists",
"arguments": {
"artist": "Pink Floyd",
"limit": 10
}
}
}'Get recent tracks with pagination:
curl -X POST https://lastfm-mcp-prod.rian-db8.workers.dev \
-H "Content-Type: application/json" \
-H "Cookie: session=your_session_token" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_recent_tracks",
"arguments": {
"username": "your_username",
"limit": 500,
"page": 2
}
}
}'Get available historical periods:
curl -X POST https://lastfm-mcp-prod.rian-db8.workers.dev \
-H "Content-Type: application/json" \
-H "Cookie: session=your_session_token" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_weekly_chart_list",
"arguments": {
"username": "your_username"
}
}
}'Discover what you were listening to in a specific time period:
curl -X POST https://lastfm-mcp-prod.rian-db8.workers.dev \
-H "Content-Type: application/json" \
-H "Cookie: session=your_session_token" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_weekly_artist_chart",
"arguments": {
"username": "your_username",
"from": 1577836800,
"to": 1578441600
}
}
}'With Claude or other AI assistants, you can now ask natural language questions like:
- "When did I start listening to Led Zeppelin?"
- "What was I obsessed with in summer 2023?"
- "Show me how my music taste has evolved over the years"
- "Find artists similar to my current favorites"
- "What tracks should I check out based on my listening history?"
- π Runtime: Cloudflare Workers (global edge deployment)
- π‘ Protocol: Model Context Protocol (MCP) 2024-11-05
- π Authentication: Last.fm Web Auth + JWT sessions
- πΎ Storage: Cloudflare KV (sessions, caching, rate limiting)
- π΅ API: Last.fm Web API v2.0
- β‘ Performance: Smart caching, rate limiting, retry logic
# Run tests
npm test
# Type checking
npm run typecheck
# Linting
npm run lint
# Build check
npm run build- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details.
- Last.fm for the comprehensive music API
- Model Context Protocol for the MCP specification
- Cloudflare Workers for the serverless runtime
π΅ Built with β€οΈ for music lovers and AI enthusiasts