Your Spotify MCP Server
Connects AI assistants to a self-hosted Your Spotify instance and Spotify's Web API for deep listening analytics and playback control. It enables users to query unlimited listening history, generate custom Wrapped summaries, and manage playlists through natural language.
README
Your Spotify MCP Server
A Model Context Protocol (MCP) server that connects AI assistants to Your Spotify's analytics API and Spotify's Web API.
Requires: A self-hosted Your Spotify instance for unlimited listening history analytics.
Why This MCP Server?
| Feature | Spotify API | Your Spotify MCP |
|---|---|---|
| Listening history | Last 50 tracks | Unlimited |
| Custom time ranges | No | Yes (any period) |
| Play count stats | No | Yes |
| Collaborative analytics | No | Yes (affinity)* |
| Custom Wrapped | Annual only | Any time period |
*Affinity analysis requires authenticated web session; see Known Issues
Features
Tier 1: Core Analytics (Your Spotify API)
- get_track_stats - Detailed listening statistics for any track
- get_top_tracks - Top tracks for any time period
- get_top_artists - Top artists for any time period
- get_artist_stats - Artist listening patterns
- search_listening_history - Search your complete history
Tier 2: Enhanced Analytics
- create_custom_wrapped - Spotify Wrapped for ANY time period
- analyze_affinity - Collaborative listening analysis
- get_listening_timeline - Timeline of listening activity
- get_artist_rank - Your ranking for an artist
- get_track_rank - Your ranking for a track
Tier 3: Power Analytics
- analyze_listening_patterns - Peak listening times, habits
- get_discovery_insights - New music discoveries
- compare_listening_periods - Period-over-period comparisons
- export_listening_data - Export in JSON, CSV, or summary format
Tier 4: Account Management
- get_listening_summary - Overview of listening habits
- update_user_settings - Manage account settings
- generate_public_share_link - Share your stats
Tier 5: Spotify Control (Optional)
Requires Spotify API credentials - see setup below
- control_playback - Play, pause, skip, seek
- manage_playlist - Create and modify playlists
- search_spotify - Search Spotify catalog
Note: Tiers 1-4 (18 tools) work with just Your Spotify. Tier 5 (10 additional tools) requires separate Spotify Web API credentials.
Token-Efficient Output (TOON)
This server supports TOON (Token-Oriented Object Notation) for 40-60% token savings on list responses.
# JSON output (verbose)
{"tracks": [{"name": "Song A", "artist": "Artist 1", "plays": 42}, ...]}
# TOON output (compact, default)
tracks[10]{name,artist,plays}:
Song A,Artist 1,42
Song B,Artist 2,38
...
Most tools support an output_format parameter:
"toon"(default) - Compact format, ideal for AI assistants"json"- Standard JSON for programmatic use
TOON Resources:
- Website: https://toonformat.dev
- GitHub: https://github.com/toon-format/toon
- npm: @toon-format/toon
Requirements
- Node.js 18+
- Your Spotify instance (self-hosted)
- Your Spotify public token (from Your Spotify settings)
Setup
1. Install Dependencies
npm install
2. Build
npm run build
3. Get Your Spotify Token
- Open your Your Spotify dashboard
- Go to Settings
- Generate/copy your public token
4. Configure Environment Variables
Required:
YOUR_SPOTIFY_API_URL- Your Your Spotify API URL (e.g.,https://your-spotify-api.example.com)YOUR_SPOTIFY_TOKEN- Your public token from Your Spotify
Optional (for Tier 5 features):
SPOTIFY_CLIENT_ID- Spotify App Client IDSPOTIFY_CLIENT_SECRET- Spotify App Client SecretSPOTIFY_ACCESS_TOKEN- Spotify OAuth Access TokenSPOTIFY_REFRESH_TOKEN- Spotify OAuth Refresh Token
5. Configure Claude Desktop
Add to your Claude Desktop config (~/.config/Claude/claude_desktop_config.json on Linux):
{
"mcpServers": {
"your-spotify": {
"command": "node",
"args": ["/path/to/your-spotify-mcp/build/index.js"],
"env": {
"YOUR_SPOTIFY_API_URL": "https://your-spotify-api.example.com",
"YOUR_SPOTIFY_TOKEN": "your_public_token_here"
}
}
}
}
More configurations: See examples/ for Claude Code, Gemini, and other client configs.
Usage Examples
Once configured, you can ask Claude:
- "What are my top 10 tracks?"
- "Show me my most played songs from summer 2024"
- "Create my Spotify Wrapped for Q1 2024"
- "How many times have I listened to [track name]?"
- "What songs would my partner and I both enjoy?" (affinity)
Development
# Build and watch for changes
npm run watch
# Run in development mode
npm run dev
# Clean build
npm run clean
Architecture
src/
├── index.ts # Main entry point, MCP server setup
├── lib/
│ ├── your-spotify-client.ts # Your Spotify HTTP client
│ ├── spotify-client.ts # Spotify Web API client
│ └── toon-utils.ts # TOON format utilities
├── services/
│ └── your-spotify-service.ts # Business logic layer
└── tools/
├── tier1/ # Core analytics
├── tier2/ # Enhanced analytics
├── tier3/ # Power analytics
├── tier4/ # Account management
└── tier5/ # Spotify control
Roadmap
Completed (v0.2.x)
- [x] Core analytics tools (Tier 1) - 5 tools
- [x] Enhanced analytics (Tier 2) - Custom Wrapped, Affinity, Rankings
- [x] Power analytics (Tier 3) - Patterns, Comparisons, Export
- [x] Account management (Tier 4) - Settings, Sharing
- [x] TOON format support for token-efficient output
- [x] Public token authentication
Optional (v0.2.x)
- [x] Spotify playback control (Tier 5) - Requires Spotify API credentials
Future
- [ ] Dedicated API token authentication (contribution to Your Spotify upstream)
- [ ] Enhanced rate limiting
- [ ] WebSocket support for real-time updates
Related Projects
- Your Spotify - Self-hosted Spotify tracking dashboard (required)
- TOON Format - Token-efficient data format for LLMs
Documentation
- Usage Guide - Practical examples and workflows
- Tools Reference - Complete API reference for all 28 tools
- Architecture - System design documentation
- Configuration Examples - Ready-to-use configs for Claude, Gemini, etc.
Contributing
See CONTRIBUTING.md for guidelines.
Security
See SECURITY.md for vulnerability reporting.
License
Apache 2.0 - See LICENSE for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。