diff --git a/client/src/App.tsx b/client/src/App.tsx index 39c13c2..e1d5d46 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -216,6 +216,21 @@ const App = () => { localStorage.setItem("lastTransportType", transportType); }, [transportType]); + // Auto-connect if serverUrl is provided in URL params (e.g. after OAuth callback) + useEffect(() => { + const serverUrl = params.get("serverUrl"); + if (serverUrl) { + setSseUrl(serverUrl); + setTransportType("sse"); + // Remove serverUrl from URL without reloading the page + const newUrl = new URL(window.location.href); + newUrl.searchParams.delete("serverUrl"); + window.history.replaceState({}, "", newUrl.toString()); + // Connect to the server + connectMcpServer(); + } + }, []); + useEffect(() => { fetch(`${PROXY_SERVER_URL}/config`) .then((response) => response.json()) diff --git a/client/src/components/OAuthCallback.tsx b/client/src/components/OAuthCallback.tsx index bc3e1dd..3887be1 100644 --- a/client/src/components/OAuthCallback.tsx +++ b/client/src/components/OAuthCallback.tsx @@ -19,8 +19,8 @@ const OAuthCallback = () => { const accessToken = await handleOAuthCallback(serverUrl, code); // Store the access token for future use sessionStorage.setItem(SESSION_KEYS.ACCESS_TOKEN, accessToken); - // Redirect back to the main app - window.location.href = '/'; + // Redirect back to the main app with server URL to trigger auto-connect + window.location.href = `/?serverUrl=${encodeURIComponent(serverUrl)}`; } catch (error) { console.error('OAuth callback error:', error); window.location.href = '/';