on main help sign in
fix(mcp): race condition, logs (#2145)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

commit775cf3ae2609aa95ad1963a68b4a960c331371e1 authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateFri 6 Feb 2026, 10:51 (8 months ago) parentb66f96e
2 files changed+11−8
internal/agent/tools/list_mcp_resources.go+1−2 internal/ui/model/ui.go+10−6
internal/agent/tools/list_mcp_resources.go+1−2
@@ -1,7 +1,6 @@
11package tools
22
33import (
4− "cmp"
54 "context"
65 _ "embed"
76 "fmt"
@@ -43,7 +42,7 @@ func NewListMCPResourcesTool(cfg *config.Config, permissions permission.Service)
4342 return fantasy.ToolResponse{}, fmt.Errorf("session ID is required for listing MCP resources")
4443 }
4544
46− relPath := filepathext.SmartJoin(cfg.WorkingDir(), cmp.Or(params.MCPName, "mcp-resources"))
45+ relPath := filepathext.SmartJoin(cfg.WorkingDir(), params.MCPName)
4746 p, err := permissions.Request(ctx,
4847 permission.CreatePermissionRequest{
4948 SessionID: sessionID,
internal/ui/model/ui.go+10−6
@@ -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