@@ -97,6 +97,10 @@ type (
9797 mcpPromptsLoadedMsg struct {
9898 Prompts []commands.MCPPrompt
9999 }
100+ // mcpStateChangedMsg is sent when there is a change in MCP client states.
101+ mcpStateChangedMsg struct {
102+ states map[string]mcp.ClientInfo
103+ }
100104 // sendMessageMsg is sent to send a message.
101105 // currently only used for mcp prompts.
102106 sendMessageMsg struct {
@@ -429,6 +433,9 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
429433 if ok {
430434 commands.SetCustomCommands(m.customCommands)
431435 }
436+
437+ case mcpStateChangedMsg:
438+ m.mcpStates = msg.states
432439 case mcpPromptsLoadedMsg:
433440 m.mcpPrompts = msg.Prompts
434441 dia := m.dialog.Dialog(dialog.CommandsID)
@@ -3149,16 +3156,15 @@ func (m *UI) runMCPPrompt(clientID, promptID string, arguments map[string]string
31493156}
31503157
31513158func (m *UI) handleStateChanged() tea.Cmd {
3152− slog.Warn("handleStateChanged")
31533159 return func() tea.Msg {
31543160 m.com.App.UpdateAgentModel(context.Background())
3155− m.mcpStates = mcp.GetStates()
3156− return nil
3161+ return mcpStateChangedMsg{
3162+ states: mcp.GetStates(),
3163+ }
31573164 }
31583165}
31593166
31603167func handleMCPPromptsEvent(name string) tea.Cmd {
3161− slog.Warn("handleMCPPromptsEvent")
31623168 return func() tea.Msg {
31633169 mcp.RefreshPrompts(context.Background(), name)
31643170 return nil
@@ -3166,7 +3172,6 @@ func handleMCPPromptsEvent(name string) tea.Cmd {
31663172}
31673173
31683174func handleMCPToolsEvent(cfg *config.Config, name string) tea.Cmd {
3169− slog.Warn("handleMCPToolsEvent")
31703175 return func() tea.Msg {
31713176 mcp.RefreshTools(
31723177 context.Background(),
@@ -3178,7 +3183,6 @@ func handleMCPToolsEvent(cfg *config.Config, name string) tea.Cmd {
31783183}
31793184
31803185func handleMCPResourcesEvent(name string) tea.Cmd {
3181− slog.Warn("handleMCPResourcesEvent")
31823186 return func() tea.Msg {
31833187 mcp.RefreshResources(context.Background(), name)
31843188 return nil