feat(spotify): add run_spotify_mcp launcher

This commit is contained in:
Moritz Graf
2026-09-11 21:15:27 +02:00
parent 9c32d8e44c
commit 24e788ba6b
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""
Spotify MCP Server Launcher for OpenClaw.
Ensures credentials.json is configured from SPOTIFY_REFRESH_TOKEN, then executes uvx mcp-server-spotify.
"""
import json
import os
import sys
from pathlib import Path
def main():
refresh_token = os.environ.get("SPOTIFY_REFRESH_TOKEN")
client_id = os.environ.get("SPOTIFY_CLIENT_ID")
client_secret = os.environ.get("SPOTIFY_CLIENT_SECRET")
creds_dir = Path.home() / ".spotify-mcp"
creds_file = creds_dir / "credentials.json"
if refresh_token:
try:
creds_dir.mkdir(parents=True, exist_ok=True)
creds = {
"access_token": "init",
"refresh_token": refresh_token,
"expires_at": 0,
}
creds_file.write_text(json.dumps(creds, indent=2))
try:
creds_file.chmod(0o600)
except Exception:
pass
except Exception as e:
print(f"[run_spotify_mcp] Warning: Could not write credentials file: {e}", file=sys.stderr)
# Launch mcp-server-spotify via uvx
os.execvp("uvx", ["uvx", "mcp-server-spotify"])
if __name__ == "__main__":
main()