on main help sign in
fix: do not wait for MCP on interactive mode
c0662f1Kujtim Hoxha
internal/agent/coordinator.go−6
@@ -20,7 +20,6 @@ import (
20 "github.com/charmbracelet/crush/internal/agent/hyper"
20 "github.com/charmbracelet/crush/internal/agent/hyper"
21 "github.com/charmbracelet/crush/internal/agent/prompt"
21 "github.com/charmbracelet/crush/internal/agent/prompt"
22 "github.com/charmbracelet/crush/internal/agent/tools"
22 "github.com/charmbracelet/crush/internal/agent/tools"
23− "github.com/charmbracelet/crush/internal/agent/tools/mcp"
24 "github.com/charmbracelet/crush/internal/config"
23 "github.com/charmbracelet/crush/internal/config"
25 "github.com/charmbracelet/crush/internal/csync"
24 "github.com/charmbracelet/crush/internal/csync"
26 "github.com/charmbracelet/crush/internal/history"
25 "github.com/charmbracelet/crush/internal/history"
@@ -412,11 +411,6 @@ func (c *coordinator) buildTools(ctx context.Context, agent config.Agent) ([]fan
412 }
411 }
413 }
412 }
414
413
415− // Wait for MCP initialization to complete before reading MCP tools.
416− if err := mcp.WaitForInit(ctx); err != nil {
417− return nil, fmt.Errorf("failed to wait for MCP initialization: %w", err)
418− }
419−
420 for _, tool := range tools.GetMCPTools(c.permissions, c.cfg.WorkingDir()) {
414 for _, tool := range tools.GetMCPTools(c.permissions, c.cfg.WorkingDir()) {
421 if agent.AllowedMCP == nil {
415 if agent.AllowedMCP == nil {
422 // No MCP restrictions
416 // No MCP restrictions
internal/app/app.go+9
@@ -173,6 +173,15 @@ func (app *App) RunNonInteractive(ctx context.Context, output io.Writer, prompt
173 spinner = nil
173 spinner = nil
174 }
174 }
175 }
175 }
176+
177+ // Wait for MCP initialization to complete before reading MCP tools.
178+ if err := mcp.WaitForInit(ctx); err != nil {
179+ return fmt.Errorf("failed to wait for MCP initialization: %w", err)
180+ }
181+
182+ // force update of agent models before running so mcp tools are loaded
183+ app.AgentCoordinator.UpdateModels(ctx)
184+
176 defer stopSpinner()
185 defer stopSpinner()
177
186
178 const maxPromptLengthForTitle = 100
187 const maxPromptLengthForTitle = 100