diff --git a/src/monarch_mcp_custom/auth.py b/src/monarch_mcp_custom/auth.py index 0b82ff0..edf1a3b 100644 --- a/src/monarch_mcp_custom/auth.py +++ b/src/monarch_mcp_custom/auth.py @@ -123,8 +123,15 @@ def retry_on_auth_error(max_retries: int = 1): "401" in error_str or "unauthorized" in error_str or "authentication" in error_str - or isinstance(e, (RequestFailedException, LoginFailedException)) + or isinstance(e, LoginFailedException) ) + is_rate_limit = "429" in error_str or "rate limit" in error_str + + if is_rate_limit and attempt < max_retries: + import asyncio + logger.warning(f"Rate limited in {func.__name__}, waiting 15s before retry...") + await asyncio.sleep(15) + continue if is_auth_error and attempt < max_retries: logger.warning(