From 24e788ba6b08d2a5eb9358f6d6da4f5301238c56 Mon Sep 17 00:00:00 2001 From: Moritz Graf Date: Fri, 11 Sep 2026 21:15:27 +0200 Subject: [PATCH] feat(spotify): add run_spotify_mcp launcher --- skills/spotify/scripts/run_spotify_mcp.py | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 skills/spotify/scripts/run_spotify_mcp.py diff --git a/skills/spotify/scripts/run_spotify_mcp.py b/skills/spotify/scripts/run_spotify_mcp.py new file mode 100755 index 0000000..3e5f238 --- /dev/null +++ b/skills/spotify/scripts/run_spotify_mcp.py @@ -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()