Skip to content

Commit

Permalink
Merge pull request #45 from modelcontextprotocol/davidsp/fix-capture
Browse files Browse the repository at this point in the history
  • Loading branch information
dsp-ant authored Nov 11, 2024
2 parents 148e843 + ea4484c commit 94e4e92
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const App = () => {
>
>([]);
const nextRequestId = useRef(0);
const rootsRef = useRef<Root[]>([]);

const handleApproveSampling = (id: number, result: CreateMessageResult) => {
setPendingSampleRequests((prev) => {
Expand Down Expand Up @@ -159,6 +160,10 @@ const App = () => {
);
}, []);

useEffect(() => {
rootsRef.current = roots;
}, [roots]);

const pushHistory = (request: object, response?: object) => {
setRequestHistory((prev) => [
...prev,
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -337,7 +342,7 @@ const App = () => {
});

client.setRequestHandler(ListRootsRequestSchema, async () => {
return { roots };
return { roots: rootsRef.current };
});

setMcpClient(client);
Expand Down

0 comments on commit 94e4e92

Please sign in to comment.