diff --git a/examples/chat-ui/index.html b/examples/chat-ui/index.html index e4b78ea..f428a2d 100644 --- a/examples/chat-ui/index.html +++ b/examples/chat-ui/index.html @@ -4,7 +4,7 @@ - Vite + React + TS + use-mcp chat
diff --git a/examples/chat-ui/src/components/messages/ToolCallMessage.tsx b/examples/chat-ui/src/components/messages/ToolCallMessage.tsx index 0c66642..b051e97 100644 --- a/examples/chat-ui/src/components/messages/ToolCallMessage.tsx +++ b/examples/chat-ui/src/components/messages/ToolCallMessage.tsx @@ -1,5 +1,5 @@ import { useState } from 'react' -import { ChevronDown, ChevronRight, Wrench } from 'lucide-react' +import { ChevronDown, Wrench } from 'lucide-react' import { type ToolCallMessage } from '../../types' interface ToolCallMessageProps { @@ -9,36 +9,43 @@ interface ToolCallMessageProps { const ToolCallMessage: React.FC = ({ message }) => { const [expanded, setExpanded] = useState(false) - const argsPreview = JSON.stringify(message.toolArgs).substring(0, 100) - const shouldTruncate = JSON.stringify(message.toolArgs).length > 100 + const json = JSON.stringify(message.toolArgs) + const argsPreview = json.substring(0, 100) + const shouldTruncate = json.length > 100 return (
-
+
-
- Tool Call +
+ Tool Call {message.toolName} -
- -
shouldTruncate && setExpanded(!expanded)} - > -
- - {expanded ? JSON.stringify(message.toolArgs, null, 2) : `${argsPreview}${shouldTruncate ? '...' : ''}`} - - {shouldTruncate && ( - - )} -
- {expanded && shouldTruncate && ( -
{JSON.stringify(message.toolArgs, null, 2)}
+ {!shouldTruncate && ( +
+ {argsPreview} +
)}
+ + {shouldTruncate && ( +
setExpanded(!expanded)} + > + {expanded ? ( +
+                {JSON.stringify(message.toolArgs, null, 2)}
+              
+ ) : ( +
+ {argsPreview} + +
+ )} +
+ )}
) diff --git a/examples/chat-ui/src/components/messages/ToolResultMessage.tsx b/examples/chat-ui/src/components/messages/ToolResultMessage.tsx index 484ce3a..9b1ea2a 100644 --- a/examples/chat-ui/src/components/messages/ToolResultMessage.tsx +++ b/examples/chat-ui/src/components/messages/ToolResultMessage.tsx @@ -1,5 +1,5 @@ import { useState } from 'react' -import { ChevronDown, ChevronRight, CheckCircle } from 'lucide-react' +import { CheckCircle, ChevronDown } from 'lucide-react' import { type ToolResultMessage } from '../../types' interface ToolResultMessageProps { @@ -9,38 +9,43 @@ interface ToolResultMessageProps { const ToolResultMessage: React.FC = ({ message }) => { const [expanded, setExpanded] = useState(false) - const resultPreview = JSON.stringify(message.toolResult).substring(0, 100) - const shouldTruncate = JSON.stringify(message.toolResult).length > 100 + const json = JSON.stringify(message.toolResult) + const resultPreview = json.substring(0, 48) + const shouldTruncate = json.length > 48 return (
-
+
-
- Tool Result +
+ Tool Result {message.toolName} -
- -
shouldTruncate && setExpanded(!expanded)} - > -
- - {expanded ? JSON.stringify(message.toolResult, null, 2) : `${resultPreview}${shouldTruncate ? '...' : ''}`} - - {shouldTruncate && ( - - )} -
- {expanded && shouldTruncate && ( -
-              {JSON.stringify(message.toolResult, null, 2)}
-            
+ {!shouldTruncate && ( +
+ {resultPreview} +
)}
+ + {shouldTruncate && ( +
setExpanded(!expanded)} + > + {expanded ? ( +
+                {JSON.stringify(message.toolResult, null, 2)}
+              
+ ) : ( +
+ {resultPreview} + +
+ )} +
+ )}
) diff --git a/examples/example-server/vengabus/src/index.ts b/examples/example-server/vengabus/src/index.ts index f1bfdd2..5fc2067 100644 --- a/examples/example-server/vengabus/src/index.ts +++ b/examples/example-server/vengabus/src/index.ts @@ -42,7 +42,7 @@ mcpServer.registerTool( inputSchema: {}, }, async () => { - await scheduler.wait(100) + await scheduler.wait(100 + Math.random() * 100) return { content: [ {