Skip to content

Commit 0648ba4

Browse files
committed
Auto-reconnect after OAuth
1 parent c22f918 commit 0648ba4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

client/src/App.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,21 @@ const App = () => {
216216
localStorage.setItem("lastTransportType", transportType);
217217
}, [transportType]);
218218

219+
// Auto-connect if serverUrl is provided in URL params (e.g. after OAuth callback)
220+
useEffect(() => {
221+
const serverUrl = params.get("serverUrl");
222+
if (serverUrl) {
223+
setSseUrl(serverUrl);
224+
setTransportType("sse");
225+
// Remove serverUrl from URL without reloading the page
226+
const newUrl = new URL(window.location.href);
227+
newUrl.searchParams.delete("serverUrl");
228+
window.history.replaceState({}, "", newUrl.toString());
229+
// Connect to the server
230+
connectMcpServer();
231+
}
232+
}, []);
233+
219234
useEffect(() => {
220235
fetch(`${PROXY_SERVER_URL}/config`)
221236
.then((response) => response.json())

client/src/components/OAuthCallback.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const OAuthCallback = () => {
1919
const accessToken = await handleOAuthCallback(serverUrl, code);
2020
// Store the access token for future use
2121
sessionStorage.setItem(SESSION_KEYS.ACCESS_TOKEN, accessToken);
22-
// Redirect back to the main app
23-
window.location.href = '/';
22+
// Redirect back to the main app with server URL to trigger auto-connect
23+
window.location.href = `/?serverUrl=${encodeURIComponent(serverUrl)}`;
2424
} catch (error) {
2525
console.error('OAuth callback error:', error);
2626
window.location.href = '/';

0 commit comments

Comments
 (0)