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
bugfix: OAuth Discovery Robustness, Logging, and Test Coverage (#1)
* Add robustness improvements for OAuth discovery
Make WWW-Authenticate header optional with fallback to well-known endpoints.
This enables discovery to work with partially-compliant MCP servers that:
- Don't provide WWW-Authenticate headers
- Provide unparseable WWW-Authenticate headers
- Return non-401 responses that still require OAuth
Changes:
- Make WWW-Authenticate optional: log warning if missing/unparseable instead of failing
- Add nil check before calling FindResourceMetadataURL(challenges)
- Continue discovery even if initial response isn't 401 (log warning)
- Fallback to /.well-known/oauth-protected-resource when resource_metadata URL not available
This aligns with RFC 9728 requirement that servers MUST provide the well-known
endpoint, making it a valid fallback when WWW-Authenticate is unavailable.
Fixes issue with Neon server and other servers that don't fully implement
MCP Authorization Specification Section 4.1.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add structured logging via context pattern
Replace fmt.Printf with proper structured logging that integrates
with caller's logging infrastructure.
Changes:
- Add Logger interface with Infof/Warnf/Errorf methods
- Support context-based logger injection via WithLogger/LoggerFromContext
- Provide WrapLogger helper to adapt any compatible logger
- Update DiscoverOAuthRequirements to use logger from context
- Fallback to default stderr logger if no logger provided
Benefits:
- Logs from library now appear with proper component tags ([com.docker.backend.dcr])
- No messy grep patterns needed - logs integrate naturally
- Pluggable logging - works with any logger (logrus, zap, slog, etc.)
- Backward compatible - uses default logger if none provided
This is the Go-idiomatic approach for library logging, following the
context pattern used throughout the Go ecosystem.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add ci + tests
* Add template, fix logs
* fix comment + redirect URL
---------
Co-authored-by: Claude <[email protected]>
0 commit comments