File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ const App = () => {
108108 >
109109 > ( [ ] ) ;
110110 const nextRequestId = useRef ( 0 ) ;
111+ const rootsRef = useRef < Root [ ] > ( [ ] ) ;
111112
112113 const handleApproveSampling = ( id : number , result : CreateMessageResult ) => {
113114 setPendingSampleRequests ( ( prev ) => {
@@ -159,6 +160,10 @@ const App = () => {
159160 ) ;
160161 } , [ ] ) ;
161162
163+ useEffect ( ( ) => {
164+ rootsRef . current = roots ;
165+ } , [ roots ] ) ;
166+
162167 const pushHistory = ( request : object , response ?: object ) => {
163168 setRequestHistory ( ( prev ) => [
164169 ...prev ,
@@ -293,7 +298,7 @@ const App = () => {
293298 } ;
294299
295300 const handleRootsChange = async ( ) => {
296- sendNotification ( { method : "notifications/roots/list_changed" } ) ;
301+ await sendNotification ( { method : "notifications/roots/list_changed" } ) ;
297302 } ;
298303
299304 const connectMcpServer = async ( ) => {
@@ -337,7 +342,7 @@ const App = () => {
337342 } ) ;
338343
339344 client . setRequestHandler ( ListRootsRequestSchema , async ( ) => {
340- return { roots } ;
345+ return { roots : rootsRef . current } ;
341346 } ) ;
342347
343348 setMcpClient ( client ) ;
You can’t perform that action at this time.
0 commit comments