Spotify MCP(媒体控制协议)服务器是一款用于管理和控制 Spotify 音乐播放的工具。它提供了多种交互方式,如 Web 界面、命令行界面和语音控制,极大地提升了用户管理音乐播放的便捷性。
npm install
.env
文件,添加以下内容:PORT=8000
BRIDGE_PORT=9000
VOICE_PORT=8001
CLIENT_ID=your_spotify_client_id
CLIENT_SECRET=your_spotify_client_secret
npm start
npm install
在项目根目录创建 .env
文件,并按如下内容配置:
PORT=8000
BRIDGE_PORT=9000
VOICE_PORT=8001
CLIENT_ID=your_spotify_client_id
CLIENT_SECRET=your_spotify_client_secret
npm start
打开浏览器访问 http://localhost:8000
,按照提示完成 Spotify 认证。
npm run play
npm run pause
npm run next
curl http://localhost:8000/api/currently-playing
curl -X POST http://localhost:8000/api/play
curl -X POST http://localhost:8000/api/pause
GET /api/currently-playing
POST /api/play
POST /api/pause
在语音控制界面中,进入设置菜单,输入您喜欢的触发词(例如“小爱同学”),然后保存。
node speech/voice-server.js
http://localhost:8001
,进入语音控制界面。创建一个名为 start-all.js
的文件:
const { spawn } = require('child_process');
const mcp = spawn('npm', ['start'], { stdio: 'inherit' });
setTimeout(() => {
const bridge = spawn('node', ['bridge/claude-spotify-bridge.js'], { stdio: 'inherit' });
const voice = spawn('node', ['speech/voice-server.js'], { stdio: 'inherit' });
}, 1000);
运行:
node start-all.js
npm run dev
.env
文件中的端口号。本项目遵循 MIT 协议,代码可以自由使用和修改。