diff --git a/client/src/App.tsx b/client/src/App.tsx index 8160fa4ed..e8c7e084c 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -108,6 +108,7 @@ const App = () => { > >([]); const nextRequestId = useRef(0); + const rootsRef = useRef([]); const handleApproveSampling = (id: number, result: CreateMessageResult) => { setPendingSampleRequests((prev) => { @@ -159,6 +160,10 @@ const App = () => { ); }, []); + useEffect(() => { + rootsRef.current = roots; + }, [roots]); + const pushHistory = (request: object, response?: object) => { setRequestHistory((prev) => [ ...prev, @@ -293,7 +298,7 @@ const App = () => { }; const handleRootsChange = async () => { - sendNotification({ method: "notifications/roots/list_changed" }); + await sendNotification({ method: "notifications/roots/list_changed" }); }; const connectMcpServer = async () => { @@ -337,7 +342,7 @@ const App = () => { }); client.setRequestHandler(ListRootsRequestSchema, async () => { - return { roots }; + return { roots: rootsRef.current }; }); setMcpClient(client);