From 812fdf92e31027a64e24a65f593ff737c4864823 Mon Sep 17 00:00:00 2001 From: Glen Maddern Date: Mon, 23 Jun 2025 16:11:42 +1000 Subject: [PATCH] Fix MCP tools count update in plug icon indicator - Add onMcpToolsUpdate prop to ConversationThread interface - Pass setMcpTools function from ChatApp down to ConversationThread - Connect McpServerModal onToolsUpdate to parent state update - Now plug icon will correctly show '1 (N)' when N tools are available - Fixes issue where tool count remained at 0 despite successful connection --- examples/chat-ui/src/components/ChatApp.tsx | 1 + examples/chat-ui/src/components/ConversationThread.tsx | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/chat-ui/src/components/ChatApp.tsx b/examples/chat-ui/src/components/ChatApp.tsx index caa52c5..0d56519 100644 --- a/examples/chat-ui/src/components/ChatApp.tsx +++ b/examples/chat-ui/src/components/ChatApp.tsx @@ -143,6 +143,7 @@ const ChatApp: React.FC = () => { onModelChange={handleModelChange} apiKeyUpdateTrigger={apiKeyUpdateTrigger} mcpTools={mcpTools} + onMcpToolsUpdate={setMcpTools} /> diff --git a/examples/chat-ui/src/components/ConversationThread.tsx b/examples/chat-ui/src/components/ConversationThread.tsx index ca8c9bb..0d3bb46 100644 --- a/examples/chat-ui/src/components/ConversationThread.tsx +++ b/examples/chat-ui/src/components/ConversationThread.tsx @@ -27,6 +27,7 @@ interface ConversationThreadProps { onModelChange: (model: Model) => void apiKeyUpdateTrigger: number mcpTools: Tool[] + onMcpToolsUpdate: (tools: Tool[]) => void } const ConversationThread: React.FC = ({ @@ -40,6 +41,7 @@ const ConversationThread: React.FC = ({ onModelChange, apiKeyUpdateTrigger, mcpTools, + onMcpToolsUpdate, }) => { const [input, setInput] = useState('') const [apiKeyModal, setApiKeyModal] = useState<{ isOpen: boolean; model: Model | null }>({ @@ -269,9 +271,7 @@ const ConversationThread: React.FC = ({ setMcpServerModal(false)} - onToolsUpdate={(tools) => { - // This will be handled by the existing MCP tools logic in ChatApp - }} + onToolsUpdate={onMcpToolsUpdate} /> )