fix: MCP OAuth callback routing and URL handling #17789
Merged
+88
−21
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.
Title
fix: MCP OAuth callback routing and URL handling
Relevant issues
#N/A
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitType
🐛 Bug Fix
Changes
This PR addresses two issues with the MCP OAuth callback flow:
The proxy’s UI restructuring logic only converted top-level *.html files into
<route>/index.html.Nested routes like
mcp/oauth/callbackstayed as callback.html, so /ui/mcp/oauth/callback 404’d once the dashboard bundle was mounted behind the Python server. The fix walks the entire exported UI tree and moves every non-index HTML file into a matching folder, restoring nested routes automatically.Callback URLs generated in useMcpOAuthFlow (and the callback page itself) didn’t honor the /ui prefix or custom server_root_path, so they returned to / or the proxy root regardless of environment.
The new logic inspects the current pathname to prepend /ui whenever the UI is being served from that path, ensuring both dev (npm run dev on port 3000) and proxy deployments redirect back to the correct dashboard entry point.
https://www.loom.com/share/84bfd182579e4cc69bd815f0755d4d20