Repository navigation
fix: complete OAuth config extraction in API responses (fixes #155) - #164
Merged
Merged
Conversation
Fixes the regression from PR #156 where `auth status` wasn't detecting OAuth-configured servers despite the OAuth field being added to contracts. The bug was in ConvertGenericServersToTyped() which is used by the HTTP API to serialize servers. It extracted all server fields (env, headers, timestamps) but completely missed the OAuth configuration. Changes: - Added OAuth config extraction in ConvertGenericServersToTyped() - Extracts all OAuth fields: auth_url, token_url, client_id, scopes, extra_params, redirect_port - Added comprehensive tests for OAuth extraction scenarios Before fix: $ mcpproxy auth status ℹ️ No servers with OAuth configuration found. After fix: $ mcpproxy auth status Server: sentry Status: ❌ Authentication Failed Error: OAuth authorization required - deferred for background processing Resolves: #155 Related: #156
- Remove omitempty from OAuth field to prevent config file overwrites
- Add DetectOAuthAvailability() function for automatic OAuth detection
- Empty OAuth configs now persist through save/load cycles
This ensures that when users add 'oauth: {}' to their config, it won't
be removed when mcpproxy saves the config back to disk (e.g., when
toggling server enable/disable).
The auto-detection function will be used in a follow-up commit to
automatically detect OAuth availability for HTTP/SSE servers.
Updated OpenAPI artifacts to reflect the removal of omitempty from the OAuth field in config.ServerConfig. This ensures the API documentation accurately reflects that OAuth configs are always serialized, even when empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PR #156 attempted to fix OAuth detection in
auth statusbut had an incomplete implementation. While it added theOAuthfield tocontracts.Serverand implemented extraction inConvertServerConfig(), it missed adding OAuth extraction toConvertGenericServersToTyped()- the function actually used by the HTTP API.This caused
auth statusto still report "No servers with OAuth configuration found" even when servers had"oauth": {}in their config.Root Cause
The HTTP API endpoint
/api/v1/serversusesConvertGenericServersToTyped()to serialize server data. This function extracted all server fields (name, url, env, headers, timestamps, isolation config) except OAuth configuration, causing it to be silently dropped from API responses.Changes
Core Fix
ConvertGenericServersToTyped()(converters.go:238-269)auth_url,token_url,client_id,scopes,extra_params,redirect_portscopes([]interface{}) andextra_params(map[string]interface{})Testing
converters_test.gowith 3 comprehensive test cases:Verification
Before Fix
After Fix
$ mcpproxy auth status ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔐 OAuth Authentication Status ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Server: sentry Status: ❌ Authentication Failed Error: failed to connect: all authentication strategies failed, last error: OAuth authorization required - deferred for background processingAPI Response
Testing
Impact
This completes the OAuth visibility work started in PR #156, enabling:
auth statuscorrectly detects OAuth-configured serversextra_paramssupport (Phase 1+ of Autodetect OAuth without explicit oauth settings #155)Related
Note: This PR focuses solely on fixing the OAuth config extraction bug. The full
extra_paramsimplementation (allowing custom OAuth parameters like RFC 8707resource) is tracked separately and will follow the plan indocs/plans/2025-11-27-oauth-extra-params.md.