Skip to content

feat: Add SPOTIPY_CACHE_PATH environment variable support - #45

Open
jmward09 wants to merge 1 commit into
varunneal:mainfrom
jmward09:feature/spotipy-cache-path
Open

feat: Add SPOTIPY_CACHE_PATH environment variable support#45
jmward09 wants to merge 1 commit into
varunneal:mainfrom
jmward09:feature/spotipy-cache-path

Conversation

@jmward09

@jmward09 jmward09 commented Nov 5, 2025

Copy link
Copy Markdown

Summary

This PR adds support for the SPOTIPY_CACHE_PATH environment variable, allowing users to specify a custom location for OAuth token cache files.

Motivation

When deploying spotify-mcp in certain environments, it's useful to control where token cache files are stored:

  • Containerized deployments: Cache location needs to match volume mounts
  • Multi-user setups: Different users need separate token storage
  • CI/CD environments: Specific cache paths required by build systems
  • MCP wrapper scripts: Easier token management with explicit paths

Changes

  • Modified spotify_api.py Client initialization to check for SPOTIPY_CACHE_PATH environment variable
  • If set, passes cache_path parameter to SpotifyOAuth
  • If not set, uses spotipy's default behavior (backward compatible)

Testing

Tested in production environment with custom cache path:

export SPOTIPY_CACHE_PATH="/home/user/.cache-spotify"

Token caching works correctly with custom path specified.

Backward Compatibility

✅ Fully backward compatible - if SPOTIPY_CACHE_PATH is not set, behavior is unchanged

Related Issues

None currently open, but this pattern is common across Python projects using environment variables for configuration.

Allows users to specify custom OAuth token cache location via SPOTIPY_CACHE_PATH
environment variable. This is useful for:
- Containerized deployments where cache location needs to be controlled
- Multi-user setups requiring separate token storage
- CI/CD environments with specific cache paths

If SPOTIPY_CACHE_PATH is not set, spotipy's default behavior is preserved,
maintaining backward compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant