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 = () => {
108
108
>
109
109
> ( [ ] ) ;
110
110
const nextRequestId = useRef ( 0 ) ;
111
+ const rootsRef = useRef < Root [ ] > ( [ ] ) ;
111
112
112
113
const handleApproveSampling = ( id : number , result : CreateMessageResult ) => {
113
114
setPendingSampleRequests ( ( prev ) => {
@@ -159,6 +160,10 @@ const App = () => {
159
160
) ;
160
161
} , [ ] ) ;
161
162
163
+ useEffect ( ( ) => {
164
+ rootsRef . current = roots ;
165
+ } , [ roots ] ) ;
166
+
162
167
const pushHistory = ( request : object , response ?: object ) => {
163
168
setRequestHistory ( ( prev ) => [
164
169
...prev ,
@@ -293,7 +298,7 @@ const App = () => {
293
298
} ;
294
299
295
300
const handleRootsChange = async ( ) => {
296
- sendNotification ( { method : "notifications/roots/list_changed" } ) ;
301
+ await sendNotification ( { method : "notifications/roots/list_changed" } ) ;
297
302
} ;
298
303
299
304
const connectMcpServer = async ( ) => {
@@ -337,7 +342,7 @@ const App = () => {
337
342
} ) ;
338
343
339
344
client . setRequestHandler ( ListRootsRequestSchema , async ( ) => {
340
- return { roots } ;
345
+ return { roots : rootsRef . current } ;
341
346
} ) ;
342
347
343
348
setMcpClient ( client ) ;
You can’t perform that action at this time.
0 commit comments