spotify-mcp-web 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spotify_mcp_web/__init__.py +20 -0
- spotify_mcp_web/app.py +56 -0
- spotify_mcp_web/cli.py +73 -0
- spotify_mcp_web/server.py +4116 -0
- spotify_mcp_web/templates/guide.html +2109 -0
- spotify_mcp_web/templates/index.html +5276 -0
- spotify_mcp_web/templates/tools.html +2694 -0
- spotify_mcp_web-1.0.0.dist-info/METADATA +150 -0
- spotify_mcp_web-1.0.0.dist-info/RECORD +12 -0
- spotify_mcp_web-1.0.0.dist-info/WHEEL +4 -0
- spotify_mcp_web-1.0.0.dist-info/entry_points.txt +2 -0
- spotify_mcp_web-1.0.0.dist-info/licenses/LICENSE.md +21 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""
|
|
2
|
+
spotify-mcp-web
|
|
3
|
+
===============
|
|
4
|
+
Soundtrack Curator & Staging Studio — self-hosted FastAPI web app.
|
|
5
|
+
|
|
6
|
+
Quick start::
|
|
7
|
+
|
|
8
|
+
pip install spotify-mcp-web
|
|
9
|
+
soundtrack-studio
|
|
10
|
+
# → Opens http://127.0.0.1:8000 in your browser
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
__version__ = version("spotify-mcp-web")
|
|
17
|
+
except PackageNotFoundError:
|
|
18
|
+
__version__ = "0.0.0"
|
|
19
|
+
|
|
20
|
+
__all__ = ["__version__"]
|
spotify_mcp_web/app.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""
|
|
2
|
+
app.py — FastAPI application factory for the Soundtrack Studio.
|
|
3
|
+
|
|
4
|
+
This module wraps the existing mcp-soundtrack-app/server.py logic,
|
|
5
|
+
resolving template paths relative to the installed package rather than
|
|
6
|
+
the source tree.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
# ---------------------------------------------------------------------------
|
|
14
|
+
# Resolve template directory: prefer the package-bundled templates,
|
|
15
|
+
# then fall back to a user-provided path via env var.
|
|
16
|
+
# ---------------------------------------------------------------------------
|
|
17
|
+
_PKG_DIR = Path(__file__).parent
|
|
18
|
+
_TEMPLATES_DIR = _PKG_DIR / "templates"
|
|
19
|
+
|
|
20
|
+
if not _TEMPLATES_DIR.exists():
|
|
21
|
+
# Allow overriding with SOUNDTRACK_TEMPLATES_DIR env var
|
|
22
|
+
_env_dir = os.getenv("SOUNDTRACK_TEMPLATES_DIR")
|
|
23
|
+
if _env_dir:
|
|
24
|
+
_TEMPLATES_DIR = Path(_env_dir)
|
|
25
|
+
else:
|
|
26
|
+
raise RuntimeError(
|
|
27
|
+
f"[spotify-mcp-web] Templates directory not found at {_TEMPLATES_DIR}.\n"
|
|
28
|
+
"Reinstall the package or set SOUNDTRACK_TEMPLATES_DIR to your templates folder."
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
# Make the templates path available to the server module
|
|
32
|
+
os.environ.setdefault("SOUNDTRACK_TEMPLATES_DIR", str(_TEMPLATES_DIR))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def create_app():
|
|
36
|
+
"""
|
|
37
|
+
Create and return the Soundtrack Curator & Staging Studio FastAPI application.
|
|
38
|
+
|
|
39
|
+
The app is loaded from the bundled server module. Template paths are
|
|
40
|
+
resolved relative to this installed package.
|
|
41
|
+
"""
|
|
42
|
+
import importlib.util
|
|
43
|
+
|
|
44
|
+
server_path = _PKG_DIR / "server.py"
|
|
45
|
+
spec = importlib.util.spec_from_file_location("spotify_mcp_web_server", server_path)
|
|
46
|
+
if not spec or not spec.loader:
|
|
47
|
+
raise RuntimeError(f"[spotify-mcp-web] Could not load server module from {server_path}")
|
|
48
|
+
|
|
49
|
+
module = importlib.util.module_from_spec(spec)
|
|
50
|
+
spec.loader.exec_module(module)
|
|
51
|
+
|
|
52
|
+
app = getattr(module, "app", None)
|
|
53
|
+
if app is None:
|
|
54
|
+
raise RuntimeError("[spotify-mcp-web] 'app' not found in bundled server module.")
|
|
55
|
+
|
|
56
|
+
return app
|
spotify_mcp_web/cli.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""
|
|
2
|
+
cli.py — Entry point for the spotify-mcp-web package.
|
|
3
|
+
|
|
4
|
+
Console script: `soundtrack-studio`
|
|
5
|
+
Launches the Soundtrack Curator & Staging Studio FastAPI app with Uvicorn.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
import webbrowser
|
|
11
|
+
import threading
|
|
12
|
+
import time
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _setup_env():
|
|
17
|
+
"""Load .env from cwd or home config dir."""
|
|
18
|
+
from dotenv import load_dotenv
|
|
19
|
+
|
|
20
|
+
cwd_env = Path.cwd() / ".env"
|
|
21
|
+
home_env = Path.home() / ".spotify-mcp" / ".env"
|
|
22
|
+
|
|
23
|
+
if cwd_env.exists():
|
|
24
|
+
load_dotenv(dotenv_path=cwd_env)
|
|
25
|
+
elif home_env.exists():
|
|
26
|
+
load_dotenv(dotenv_path=home_env)
|
|
27
|
+
else:
|
|
28
|
+
load_dotenv()
|
|
29
|
+
|
|
30
|
+
client_id = os.getenv("SPOTIPY_CLIENT_ID") or os.getenv("SPOTIFY_CLIENT_ID")
|
|
31
|
+
if not client_id:
|
|
32
|
+
print(
|
|
33
|
+
"\n[soundtrack-studio] ⚠️ No SPOTIPY_CLIENT_ID found.\n"
|
|
34
|
+
"Create a .env file in your working directory:\n\n"
|
|
35
|
+
" SPOTIPY_CLIENT_ID=your_client_id_here\n"
|
|
36
|
+
" SPOTIPY_REDIRECT_URI=http://127.0.0.1:8888/callback\n\n"
|
|
37
|
+
"Get yours at https://developer.spotify.com/dashboard\n",
|
|
38
|
+
file=sys.stderr,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def run():
|
|
43
|
+
"""
|
|
44
|
+
Console script: `soundtrack-studio`
|
|
45
|
+
|
|
46
|
+
Starts the Soundtrack Curator & Staging Studio web application on
|
|
47
|
+
http://127.0.0.1:8000 (or the port specified by the PORT env var)
|
|
48
|
+
and opens it in your default browser.
|
|
49
|
+
"""
|
|
50
|
+
_setup_env()
|
|
51
|
+
|
|
52
|
+
import uvicorn
|
|
53
|
+
from spotify_mcp_web.app import create_app
|
|
54
|
+
|
|
55
|
+
host = os.getenv("HOST", "127.0.0.1")
|
|
56
|
+
port = int(os.getenv("PORT", "8000"))
|
|
57
|
+
open_browser = os.getenv("OPEN_BROWSER", "true").strip().lower() not in ("0", "false", "no")
|
|
58
|
+
|
|
59
|
+
app = create_app()
|
|
60
|
+
|
|
61
|
+
url = f"http://{host}:{port}"
|
|
62
|
+
print(f"\n[Soundtrack Studio] Starting at {url}\n", file=sys.stderr)
|
|
63
|
+
|
|
64
|
+
if open_browser:
|
|
65
|
+
def _open():
|
|
66
|
+
time.sleep(1.2)
|
|
67
|
+
try:
|
|
68
|
+
webbrowser.open(url)
|
|
69
|
+
except Exception:
|
|
70
|
+
pass
|
|
71
|
+
threading.Thread(target=_open, daemon=True).start()
|
|
72
|
+
|
|
73
|
+
uvicorn.run(app, host=host, port=port, log_level="warning", access_log=False)
|