Merge pull request #45 from modelcontextprotocol/davidsp/fix-capture

This commit is contained in:
David Soria Parra 2024-11-11 12:33:27 +00:00 • committed by GitHub
commit 94e4e92618
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,6 +108,7 @@ const App = () => {
>
>([]);
const nextRequestId = useRef(0);
const rootsRef = useRef<Root[]>([]);
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);