feat: enable unauthenticated server startup with runtime OAuth and update CI/CD to append Docker pull instructions to release notes
This commit is contained in:
@@ -16,7 +16,6 @@ def validate_credentials() -> None:
|
||||
required = {
|
||||
"STRAVA_CLIENT_ID": os.getenv("STRAVA_CLIENT_ID"),
|
||||
"STRAVA_CLIENT_SECRET": os.getenv("STRAVA_CLIENT_SECRET"),
|
||||
"STRAVA_REFRESH_TOKEN": os.getenv("STRAVA_REFRESH_TOKEN"),
|
||||
}
|
||||
missing = [k for k, v in required.items() if not v]
|
||||
if missing:
|
||||
@@ -25,6 +24,10 @@ def validate_credentials() -> None:
|
||||
print(f" - {key}")
|
||||
print("\nCopy .env.example to .env and fill in your Strava API credentials.")
|
||||
sys.exit(1)
|
||||
|
||||
if not os.getenv("STRAVA_REFRESH_TOKEN"):
|
||||
print("ℹ️ No STRAVA_REFRESH_TOKEN found. Server starting in unauthenticated mode.")
|
||||
print(" Use the 'get_new_oauth_token' tool via MCP to authenticate.")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -39,6 +42,7 @@ def main() -> None:
|
||||
|
||||
mcp = FastMCP(
|
||||
"Strava MCP Server",
|
||||
instructions="Dates returned by this server are generally in ISO-8601 (UTC) or formatted as DD.MM.YYYY HH:MM. Always present dates, times, and durations to the user in a natural, human-readable format appropriate for their language.",
|
||||
host=host,
|
||||
port=port,
|
||||
streamable_http_path="/mcp",
|
||||
|
||||
@@ -36,6 +36,9 @@ class StravaClient:
|
||||
|
||||
async def get_valid_token(self) -> str:
|
||||
"""Returns a valid access token, refreshing it if necessary."""
|
||||
if not self.refresh_token:
|
||||
raise ValueError("No Strava refresh token found. Please run the 'get_new_oauth_token' MCP tool to authenticate first.")
|
||||
|
||||
if not self.access_token or time.time() > self.expires_at - 60:
|
||||
await self._refresh_access_token()
|
||||
return self.access_token
|
||||
|
||||
Reference in New Issue
Block a user