Spotify MCP服务器
一个简单的模型上下文协议(MCP)服务器,允许您通过Claude与Spotify进行交互。此服务器使Claude能够使用您的Spotify帐户搜索歌曲、创建播放列表、获取推荐等。
特性
- 在Spotify上搜索曲目
- 查看您的Spotify个人资料
- 创建播放列表
- 将曲目添加到播放列表
- 获取个性化音乐推荐
可用工具
| 工具名称 | 描述 |
|---|---|
set-spotify-credentials | 设置您的Spotify身份验证凭据 |
check-credentials-status | 检查您的凭据是否有效以及谁登录了 |
search-tracks | 按名称、艺术家或关键字搜索曲目 |
get-current-user | 获取您的Spotify个人资料信息 |
create-playlist | 在您的帐户上创建新的播放列表 |
add-tracks-to-playlist | 将曲目添加到现有播放列表 |
get-recommendations | 根据种子轨迹获取推荐 |
安装说明
即插即用-HTTP Spotify MCP服务器
- 首选 克劳德 AI
- 单击添加连接器
- 单击管理连接器
- 添加自定义连接器
- 添加https服务器链接
- 邮件hrishi0102business@gmail.com将您的spotify ID/邮件列入白名单
- 就是这样。你的克劳德已经准备好使用Spotify了。系统将提示您使用spotify OAuth登录。
在本地运行Spotify MCP
1.先决条件
- Node.js v16或更高版本
- npm
- Spotify帐户
- 已注册的Spotify开发者应用程序
2.创建Spotify开发者应用程序
- 首选 Spotify开发者仪表板
- 使用您的Spotify帐户登录
- 点击“创建应用程序”
- 填写应用程序名称和描述
- 添加
http://localhost:8888/callback作为重定向URI - 记下您的客户端ID和客户端密码
3.安装项目
# Clone or download the project first
cd spotify-mcp-server
# Install dependencies
npm install4.获取您的Spotify代币
编辑 spotify-auth.js 文件中包含您的客户端ID和客户端密码:
// Replace these with your Spotify app credentials
const CLIENT_ID = "your_client_id_here";
const CLIENT_SECRET = "your_client_secret_here";然后运行身份验证脚本:
node spotify-auth.js这将:
- 在浏览器中打开URL
- 提示您登录Spotify
- 请求您允许访问您的帐户
- 将令牌保存到
secrets.json
5.构建MCP服务器
npm run build6.配置克劳德桌面
编辑您的Claude Desktop配置文件:
- 在 macOS 上:
~/Library/Application Support/Claude/claude_desktop_config.json - 在Windows上:
%APPDATA%\Claude\claude_desktop_config.json
添加以下配置:
{
"mcpServers": {
"spotify": {
"command": "node",
"args": ["/full/path/to/spotify-mcp-server/build/spotify-mcp-server.js"]
}
}
}替换 /full/path/to/spotify-mcp-server 带有项目目录的实际路径。
7.重新启动克劳德桌面
关闭并重新打开Claude Desktop以加载新配置。
用法
当您与Claude开始对话时,您首先需要设置您的Spotify凭据:
- 看看你的
secrets.json文件以获取您的凭据 - 使用
set-spotify-credentials身份验证工具 - 然后使用任何其他Spotify工具
示例提示
设置凭据
I want to connect to my Spotify account. Here are my credentials from secrets.json:
Tool: set-spotify-credentials
Parameters:
{
"clientId": "your_client_id",
"clientSecret": "your_client_secret",
"accessToken": "your_access_token",
"refreshToken": "your_refresh_token"
}基本命令
检查您的帐户:
Can you check who I'm logged in as on Spotify?
Tool: get-current-user
Parameters: {}搜索曲目:
Search for songs by Weekend
Tool: search-tracks
Parameters:
{
"query": "Taylor Swift",
"limit": 5
}创建播放列表:
Create a new playlist called "My Pretty pretty girlfriend"
Tool: create-playlist
Parameters:
{
"name": "My Pretty pretty girlfriend",
"description": "For my girlfriend. Created with Claude and the Spotify MCP server"
}多步骤任务
创建包含歌曲的播放列表:
I want to create a workout playlist with energetic songs. First, search for some high-energy songs. Then create a playlist called "Workout Mix" and add those songs to it.根据收藏夹获取推荐:
I like the song "Blinding Lights" by The Weeknd. Can you search for it, then find similar songs, and create a playlist with those recommendations?故障排除
- 错误:没有可用的访问令牌:您需要先使用设置凭据
set-spotify-credentials工具 - 身份验证失败:您的令牌可能已过期。再次运行auth脚本以获取新令牌
- 无效凭证:仔细检查您是否使用了正确的客户端ID和客户端密码
备注
- 服务器仅将凭据存储在内存中
- 每次开始新对话时,您都需要设置凭据
- 如果Claude Desktop重新启动,您需要再次设置凭据
