npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@iflow-mcp/rianvdm-lastfm-mcp

v0.0.0

Published

Model Context Protocol server for Last.fm music data integration

Readme

🎵 Last.fm MCP Server

License: MIT TypeScript Cloudflare Workers Last.fm MCP CI

A Model Context Protocol (MCP) server that provides seamless access to Last.fm listening data and music information via AI assistants like Claude.

✨ Features

  • 🎧 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
  • 🔐 OAuth 2.0 Authentication: Industry-standard auth with session persistence
  • 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

🚀 Quick Start

Claude.ai

  1. Go to SettingsIntegrationsAdd Integration
  2. Enter the MCP server URL:
    https://lastfm-mcp.com/mcp
  3. Click Connect - your browser will open to Last.fm
  4. Sign in and authorize the app
  5. Done! Your session persists across conversations.

Claude Desktop

  1. Open Claude Desktop → SettingsIntegrations
  2. Click Add Integration
  3. Enter the URL:
    https://lastfm-mcp.com/mcp
  4. Click Add - authenticate with Last.fm when prompted

Claude Code

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

When you first use a Last.fm tool, you'll be prompted to authenticate.

Windsurf

Add to your Windsurf MCP config (~/.codeium/windsurf/mcp_config.json):

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

MCP Inspector (Testing)

npx @modelcontextprotocol/inspector https://lastfm-mcp.com/mcp

Other MCP Clients

Continue.dev (VS Code/JetBrains):

{
	"mcpServers": {
		"lastfm": {
			"command": "npx",
			"args": ["-y", "mcp-remote", "https://lastfm-mcp.com/mcp"]
		}
	}
}

Zed Editor:

{
	"context_servers": {
		"lastfm": {
			"command": "npx",
			"args": ["-y", "mcp-remote", "https://lastfm-mcp.com/mcp"]
		}
	}
}

🔐 Authentication

This server uses OAuth 2.0 for authentication. When you connect from any supported client:

  1. The client detects the 401 response with OAuth metadata
  2. Your browser opens to Last.fm for authentication
  3. After authorizing, tokens are stored and persist across sessions

All major MCP clients (Claude.ai, Claude Desktop, Claude Code, Windsurf) support OAuth.

Note: Public tools (track info, artist info, similar artists, etc.) work without authentication. You only need to sign in to access your personal listening data.

🛠️ Available Tools

🔓 Public Tools (No Authentication Required)

| 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 | | lastfm_auth_status | Check your authentication status |

🔐 Personal Tools (Authentication Required)

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

🕰️ Temporal Query Tools (Authentication Required)

| 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?"

📚 MCP Resources

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

🤖 MCP Prompts

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.

🏗️ Development

Prerequisites

  • Node.js 18+
  • Cloudflare Workers account
  • Last.fm API credentials (Get them here)

Local Setup

  1. Clone and install:

    git clone https://github.com/rianvdm/lastfm-mcp.git
    cd lastfm-mcp
    npm install
  2. Configure environment (.dev.vars):

    LASTFM_API_KEY=your_api_key_here
    LASTFM_SHARED_SECRET=your_shared_secret_here
    JWT_SECRET=your_secure_jwt_secret
  3. Start development server:

    npm run dev
  4. Test with MCP Inspector:

    npx @modelcontextprotocol/inspector http://localhost:8787/mcp
  5. Test authentication locally:

    • Visit http://localhost:8787/login to authenticate
    • Use the session ID in your local testing

🚀 Deployment

  1. 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
  2. Deploy:

    npm run deploy:prod
  3. Verify deployment:

    curl https://lastfm-mcp.com/

📋 Example Usage

🎵 Public Music Data (No Authentication)

Get track information:

curl -X POST https://lastfm-mcp.com/mcp \
  -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.com/mcp \
  -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
      }
    }
  }'

🔐 Personal Data (Requires Authentication)

For authenticated requests, use the session_id parameter:

curl -X POST "https://lastfm-mcp.com/mcp?session_id=YOUR_SESSION_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "get_recent_tracks",
      "arguments": {
        "limit": 10
      }
    }
  }'

🤖 AI Assistant Examples

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?"

🏗️ Architecture

  • 🌐 Runtime: Cloudflare Workers (global edge deployment)
  • 📡 Protocol: Model Context Protocol (MCP) 2024-11-05 / 2025-06-18
  • 🔐 Authentication: OAuth 2.0 (RFC 9728) + Session ID fallback
  • 💾 Storage: Cloudflare KV (sessions, OAuth tokens, caching)
  • 🎵 API: Last.fm Web API v2.0
  • ⚡ Performance: Smart caching, rate limiting, retry logic

API Endpoints

| Endpoint | Purpose | | ----------------------------------------- | ------------------------------ | | /mcp | MCP JSON-RPC endpoint | | /login | Manual authentication (legacy) | | /authorize | OAuth 2.0 authorization | | /.well-known/oauth-authorization-server | OAuth server metadata | | /.well-known/oauth-protected-resource | OAuth resource metadata |

🧪 Testing

# Run tests
npm test

# Type checking
npm run typecheck

# Linting
npm run lint

# Build check
npm run build

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments


🎵 Built with ❤️ for music lovers and AI enthusiasts