Change summary
internal/agent/coordinator.go | 6 ------
internal/app/app.go | 9 +++++++++
2 files changed, 9 insertions(+), 6 deletions(-)
Detailed changes
@@ -20,7 +20,6 @@ import (
"github.com/charmbracelet/crush/internal/agent/hyper"
"github.com/charmbracelet/crush/internal/agent/prompt"
"github.com/charmbracelet/crush/internal/agent/tools"
- "github.com/charmbracelet/crush/internal/agent/tools/mcp"
"github.com/charmbracelet/crush/internal/config"
"github.com/charmbracelet/crush/internal/csync"
"github.com/charmbracelet/crush/internal/history"
@@ -412,11 +411,6 @@ func (c *coordinator) buildTools(ctx context.Context, agent config.Agent) ([]fan
}
}
- // Wait for MCP initialization to complete before reading MCP tools.
- if err := mcp.WaitForInit(ctx); err != nil {
- return nil, fmt.Errorf("failed to wait for MCP initialization: %w", err)
- }
-
for _, tool := range tools.GetMCPTools(c.permissions, c.cfg.WorkingDir()) {
if agent.AllowedMCP == nil {
// No MCP restrictions
@@ -173,6 +173,15 @@ func (app *App) RunNonInteractive(ctx context.Context, output io.Writer, prompt
spinner = nil
}
}
+
+ // Wait for MCP initialization to complete before reading MCP tools.
+ if err := mcp.WaitForInit(ctx); err != nil {
+ return fmt.Errorf("failed to wait for MCP initialization: %w", err)
+ }
+
+ // force update of agent models before running so mcp tools are loaded
+ app.AgentCoordinator.UpdateModels(ctx)
+
defer stopSpinner()
const maxPromptLengthForTitle = 100