What is the AuthProvider interface and when to use it
mainThe AuthProvider interface in @ivotoby/openapi-mcp-server is used to handle complex authentication scenarios that static headers cannot address. Use it when your target API requires more than a fixed string in a header, such as:
- Token Expiration: Automatically detecting and handling expired tokens.
- Token Refresh: Automatically refreshing tokens (e.g., OAuth2) before they expire.
- Manual Token Updates: Handling APIs that require manual renewal (e.g., copying a token from browser dev tools).
- API Key Management: Managing API keys with specific validation logic.
- Custom Authentication: Implementing any proprietary authentication pattern.
By using an AuthProvider, headers are fetched fresh for each request, allowing for runtime token updates and automatic detection of 401/403 errors.