Skip to content

Commit 0bd51fa

Browse files
committed
fix: Do not reconnect on rerender
1 parent 897e637 commit 0bd51fa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

client/src/App.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import ToolsTab from "./components/ToolsTab";
4747
import { DEFAULT_INSPECTOR_CONFIG } from "./lib/constants";
4848
import { InspectorConfig } from "./lib/configurationTypes";
4949
import { useToast } from "@/hooks/use-toast";
50+
5051
const params = new URLSearchParams(window.location.search);
5152
const PROXY_PORT = params.get("proxyPort") ?? "6277";
5253
const PROXY_SERVER_URL = `http://${window.location.hostname}:${PROXY_PORT}`;
@@ -197,8 +198,13 @@ const App = () => {
197198
localStorage.setItem(CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config));
198199
}, [config]);
199200

201+
const hasProcessedRef = useRef(false);
200202
// Auto-connect if serverUrl is provided in URL params (e.g. after OAuth callback)
201203
useEffect(() => {
204+
if (hasProcessedRef.current) {
205+
// Only try to connect once
206+
return;
207+
}
202208
const serverUrl = params.get("serverUrl");
203209
if (serverUrl) {
204210
setSseUrl(serverUrl);
@@ -212,6 +218,7 @@ const App = () => {
212218
title: "Success",
213219
description: "Successfully authenticated with OAuth",
214220
});
221+
hasProcessedRef.current = true;
215222
// Connect to the server
216223
connectMcpServer();
217224
}

0 commit comments

Comments
 (0)