diff --git a/client/src/App.tsx b/client/src/App.tsx index 1d1556e..9f99511 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1,7 +1,7 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"; import { - CallToolResultSchema, + CompatibilityCallToolResultSchema, ClientRequest, CreateMessageRequestSchema, CreateMessageResult, @@ -19,6 +19,7 @@ import { Root, ServerNotification, Tool, + CompatibilityCallToolResult, } from "@modelcontextprotocol/sdk/types.js"; import { useEffect, useRef, useState } from "react"; @@ -44,7 +45,7 @@ import { FolderTree, } from "lucide-react"; -import { AnyZodObject } from "zod"; +import { ZodType } from "zod"; import "./App.css"; import ConsoleTab from "./components/ConsoleTab"; import HistoryAndNotifications from "./components/History"; @@ -69,7 +70,8 @@ const App = () => { const [prompts, setPrompts] = useState([]); const [promptContent, setPromptContent] = useState(""); const [tools, setTools] = useState([]); - const [toolResult, setToolResult] = useState(""); + const [toolResult, setToolResult] = + useState(null); const [error, setError] = useState(null); const [command, setCommand] = useState(() => { return ( @@ -150,7 +152,7 @@ const App = () => { ]); }; - const makeRequest = async ( + const makeRequest = async >( request: ClientRequest, schema: T, ) => { @@ -254,9 +256,9 @@ const App = () => { }, }, }, - CallToolResultSchema, + CompatibilityCallToolResultSchema, ); - setToolResult(JSON.stringify(response.toolResult, null, 2)); + setToolResult(response); }; const handleRootsChange = async () => { @@ -444,7 +446,7 @@ const App = () => { selectedTool={selectedTool} setSelectedTool={(tool) => { setSelectedTool(tool); - setToolResult(""); + setToolResult(null); }} toolResult={toolResult} nextCursor={nextToolCursor} diff --git a/client/src/components/ToolsTab.tsx b/client/src/components/ToolsTab.tsx index dc6a18f..3334122 100644 --- a/client/src/components/ToolsTab.tsx +++ b/client/src/components/ToolsTab.tsx @@ -8,6 +8,8 @@ import { AlertCircle, Send } from "lucide-react"; import { useState } from "react"; import ListPane from "./ListPane"; +import { CompatibilityCallToolResult } from "@modelcontextprotocol/sdk/types.js"; + const ToolsTab = ({ tools, listTools, @@ -23,12 +25,56 @@ const ToolsTab = ({ callTool: (name: string, params: Record) => void; selectedTool: Tool | null; setSelectedTool: (tool: Tool) => void; - toolResult: string; + toolResult: CompatibilityCallToolResult | null; nextCursor: ListToolsResult["nextCursor"]; error: string | null; }) => { const [params, setParams] = useState>({}); + const renderToolResult = () => { + if (!toolResult) return null; + + if ("content" in toolResult) { + return ( + <> +

+ Tool Result: {toolResult.isError ? "Error" : "Success"} +

+ {toolResult.content.map((item, index) => ( +
+ {item.type === "text" && ( +
+                  {item.text}
+                
+ )} + {item.type === "image" && ( + Tool result image + )} + {item.type === "resource" && ( +
+                  {JSON.stringify(item.resource, null, 2)}
+                
+ )} +
+ ))} + + ); + } else if ("toolResult" in toolResult) { + return ( + <> +

Tool Result (Legacy):

+
+            {JSON.stringify(toolResult.toolResult, null, 2)}
+          
+ + ); + } + }; + return ( Run Tool - {toolResult && ( - <> -

Tool Result:

-
-                    {toolResult}
-                  
- - )} + {toolResult && renderToolResult()} ) : (