Skip to content

fix: client robustness improvements#14

Merged
brendanjryan merged 1 commit intomainfrom
fix/client-robustness
Feb 3, 2026
Merged

fix: client robustness improvements#14
brendanjryan merged 1 commit intomainfrom
fix/client-robustness

Conversation

@brendanjryan
Copy link
Collaborator

Summary

Ports valuable non-breaking improvements from the closed PR #7.

Changes

Multiple WWW-Authenticate header handling (RFC 9110)

  • Servers may return multiple WWW-Authenticate headers with different auth schemes
  • Client now iterates through all headers to find a matching Payment challenge
  • Correctly handles mixed auth schemes (e.g., Bearer + Payment)

Client-side expiry check

  • If challenge has expires and it's already passed, skip payment attempt
  • UX guardrail to fail fast rather than wasting a transaction
  • Logs warning when challenge is expired

MCP decorator refactor

  • Removed duplicated verification logic from @requires_payment decorator
  • Now uses shared verify_or_challenge() function
  • Preserves actual verification error messages in responses

Testing

  • Added test_skips_expired_challenge - verifies client doesn't pay expired challenges
  • Added test_handles_multiple_www_authenticate_headers - verifies multi-header parsing
  • All 123 tests pass

- Handle multiple WWW-Authenticate headers (per RFC 9110)
- Client-side expiry check before paying (UX guardrail)
- Refactor MCP decorator to use shared verify_or_challenge
- Pass through actual verification error messages
@brendanjryan brendanjryan merged commit cc89526 into main Feb 3, 2026
2 checks passed
@brendanjryan brendanjryan deleted the fix/client-robustness branch February 3, 2026 23:34
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