Skip to content

Commit 94e4e92

Browse files
authored
Merge pull request modelcontextprotocol#45 from modelcontextprotocol/davidsp/fix-capture
2 parents 148e843 + ea4484c commit 94e4e92

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

client/src/App.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)