Skip to content

Commit a75dd7b

Browse files
authored
Merge pull request modelcontextprotocol#253 from max-stytch/max/fix-reloads
fix: Do not reconnect on rerender
2 parents ce1a9d3 + 0bd51fa commit a75dd7b

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
@@ -50,6 +50,7 @@ import {
5050
getMCPServerRequestTimeout,
5151
} from "./utils/configUtils";
5252
import { useToast } from "@/hooks/use-toast";
53+
5354
const params = new URLSearchParams(window.location.search);
5455
const CONFIG_LOCAL_STORAGE_KEY = "inspectorConfig_v1";
5556

@@ -204,8 +205,13 @@ const App = () => {
204205
localStorage.setItem(CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config));
205206
}, [config]);
206207

208+
const hasProcessedRef = useRef(false);
207209
// Auto-connect if serverUrl is provided in URL params (e.g. after OAuth callback)
208210
useEffect(() => {
211+
if (hasProcessedRef.current) {
212+
// Only try to connect once
213+
return;
214+
}
209215
const serverUrl = params.get("serverUrl");
210216
if (serverUrl) {
211217
setSseUrl(serverUrl);
@@ -219,6 +225,7 @@ const App = () => {
219225
title: "Success",
220226
description: "Successfully authenticated with OAuth",
221227
});
228+
hasProcessedRef.current = true;
222229
// Connect to the server
223230
connectMcpServer();
224231
}

0 commit comments

Comments
 (0)