@@ -10,11 +10,13 @@ import {
1010 ListPromptsResultSchema ,
1111 ListResourcesResultSchema ,
1212 ListResourceTemplatesResultSchema ,
13+ ListRootsRequestSchema ,
1314 ListToolsResultSchema ,
1415 ProgressNotificationSchema ,
1516 ReadResourceResultSchema ,
1617 Resource ,
1718 ResourceTemplate ,
19+ Root ,
1820 ServerNotification ,
1921 Tool ,
2022} from "@modelcontextprotocol/sdk/types.js" ;
@@ -39,6 +41,7 @@ import {
3941 Play ,
4042 Send ,
4143 Terminal ,
44+ FolderTree ,
4245} from "lucide-react" ;
4346
4447import { AnyZodObject } from "zod" ;
@@ -49,6 +52,7 @@ import PingTab from "./components/PingTab";
4952import PromptsTab , { Prompt } from "./components/PromptsTab" ;
5053import RequestsTab from "./components/RequestsTabs" ;
5154import ResourcesTab from "./components/ResourcesTab" ;
55+ import RootsTab from "./components/RootsTab" ;
5256import SamplingTab , { PendingRequest } from "./components/SamplingTab" ;
5357import Sidebar from "./components/Sidebar" ;
5458import ToolsTab from "./components/ToolsTab" ;
@@ -86,6 +90,7 @@ const App = () => {
8690 > ( [ ] ) ;
8791 const [ mcpClient , setMcpClient ] = useState < Client | null > ( null ) ;
8892 const [ notifications , setNotifications ] = useState < ServerNotification [ ] > ( [ ] ) ;
93+ const [ roots , setRoots ] = useState < Root [ ] > ( [ ] ) ;
8994
9095 const [ pendingSampleRequests , setPendingSampleRequests ] = useState <
9196 Array <
@@ -254,6 +259,16 @@ const App = () => {
254259 setToolResult ( JSON . stringify ( response . toolResult , null , 2 ) ) ;
255260 } ;
256261
262+ const handleRootsChange = async ( ) => {
263+ if ( mcpClient ) {
264+ try {
265+ await mcpClient . sendRootsListChanged ( ) ;
266+ } catch ( e ) {
267+ console . error ( "Failed to send roots list changed notification:" , e ) ;
268+ }
269+ }
270+ } ;
271+
257272 const connectMcpServer = async ( ) => {
258273 try {
259274 const client = new Client ( {
@@ -293,6 +308,10 @@ const App = () => {
293308 } ) ;
294309 } ) ;
295310
311+ client . setRequestHandler ( ListRootsRequestSchema , async ( ) => {
312+ return { roots } ;
313+ } ) ;
314+
296315 setMcpClient ( client ) ;
297316 setConnectionStatus ( "connected" ) ;
298317 } catch ( e ) {
@@ -387,6 +406,10 @@ const App = () => {
387406 </ span >
388407 ) }
389408 </ TabsTrigger >
409+ < TabsTrigger value = "roots" >
410+ < FolderTree className = "w-4 h-4 mr-2" />
411+ Roots
412+ </ TabsTrigger >
390413 </ TabsList >
391414
392415 < div className = "w-full" >
@@ -443,6 +466,11 @@ const App = () => {
443466 onApprove = { handleApproveSampling }
444467 onReject = { handleRejectSampling }
445468 />
469+ < RootsTab
470+ roots = { roots }
471+ setRoots = { setRoots }
472+ onRootsChange = { handleRootsChange }
473+ />
446474 </ div >
447475 </ Tabs >
448476 ) : (
0 commit comments