litellm - 💡(How to fix) Fix MCP OAuth2 callback redirects to non-existent /ui/mcp/oauth/callback [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#24771Fetched 2026-04-08 01:49:12
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Code Example

https://<base_url>/ui/mcp/oauth/callback?code=<code>&state=<state>
RAW_BUFFERClick to expand / collapse

Bug

When setting up an OAuth2 GitHub App-based MCP server (using client_id/secret, not PAT), the OAuth callback redirects to a non-existent page:

https://<base_url>/ui/mcp/oauth/callback?code=<code>&state=<state>

This page does not exist in the LiteLLM UI, resulting in a 404.

Steps to Reproduce

  1. Create an MCP server with OAuth2 auth (GitHub App with client_id + client_secret)
  2. Register callback URL as <base_url>/callback with GitHub
  3. Initiate OAuth flow from the LiteLLM UI
  4. After GitHub authorization, the browser redirects to /ui/mcp/oauth/callback instead of the registered /callback endpoint

Expected Behavior

The OAuth callback should redirect to a URL that:

  1. Exists in the LiteLLM proxy/UI
  2. Matches what can be registered as a callback URL with the OAuth provider
  3. Completes the token exchange and stores credentials

Environment

  • LiteLLM version: latest (main branch)
  • MCP server type: GitHub App (OAuth2 with client_id/secret)

extent analysis

Fix Plan

The fix involves updating the OAuth callback URL to match the registered callback URL with GitHub.

Steps to Fix

  • Update the OAuth callback URL in the MCP server configuration to /callback
  • Ensure the LiteLLM UI handles the /callback endpoint correctly

Example Code

# Update the OAuth callback URL in the MCP server configuration
oauth_config = {
    'client_id': 'your_client_id',
    'client_secret': 'your_client_secret',
    'callback_url': '/callback'  # Update this to match the registered callback URL
}

# Handle the /callback endpoint in the LiteLLM UI
from flask import Flask, request, redirect, url_for
app = Flask(__name__)

@app.route('/callback')
def handle_callback():
    # Complete the token exchange and store credentials
    code = request.args.get('code')
    state = request.args.get('state')
    # Token exchange logic here
    return redirect(url_for('index'))

if __name__ == '__main__':
    app.run()

Verification

  • Test the OAuth flow by initiating authorization from the LiteLLM UI
  • Verify that the browser redirects to the correct /callback endpoint
  • Check that the token exchange is completed successfully and credentials are stored

Extra Tips

  • Ensure the registered callback URL with GitHub matches the updated callback URL in the MCP server configuration
  • Handle any errors that may occur during the token exchange process to prevent authentication issues.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix MCP OAuth2 callback redirects to non-existent /ui/mcp/oauth/callback [1 participants]