You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: refresh stale credentials on auth failure without restart (#245)
* fix: refresh stale credentials on auth failure without restart
When AWS credentials expire, the proxy now automatically picks up
refreshed credentials on the next request without requiring a restart.
Problem:
- boto3.Session was created once at startup and cached forever
- session.get_credentials() returned the same stale Credentials object
- Even after refreshing creds on disk (ada, aws sso login), the proxy
kept using the old frozen session until restarted
Fix:
- Add SessionHolder that wraps the boto3 session with lazy refresh
- On 401/403, mark the session for refresh (don't refresh immediately,
since creds on disk may not be updated yet)
- On the next request's signing, create a fresh boto3.Session that
reads the current credentials from disk
- Improve error messages: credential errors now clearly say 'expired
or invalid AWS credentials' instead of 'Unknown tool'
The lazy refresh pattern ensures the new session is created at signing
time (after the user has refreshed creds), not at error time (when
creds may still be stale).
* fix: address review comments on credential refresh
* chore: fix ruff lint and format issues
* test: add unit tests for credential refresh flow
* fix: address PR review comments
---------
Co-authored-by: Ian de Villiers <iddv@amazon.com>
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -353,8 +353,10 @@ For long-running sessions, consider using long-lived credentials:
353
353
- Use an AWS profile via `--profile`
354
354
- Use IAM Identity Center and run `aws sso login` before starting the proxy
355
355
356
+
If your credentials do expire during a session, the proxy will automatically detect the auth failure and pick up refreshed credentials on the next request — no restart required. Simply refresh your credentials (e.g., `aws sso login`) and retry.
357
+
356
358
### Client hangs on tool calls
357
-
If your MCP client hangs waiting for a tool call response (e.g., due to expired credentials or an unresponsive endpoint), use `--tool-timeout` to set a maximum duration in seconds for each tool call. When the timeout is exceeded, the proxy returns a graceful error to the agent instead of hanging indefinitely.
359
+
If your MCP client hangs waiting for a tool call response (e.g., due to an unresponsive endpoint), use `--tool-timeout` to set a maximum duration in seconds for each tool call. When the timeout is exceeded, the proxy returns a graceful error to the agent instead of hanging indefinitely.
0 commit comments