diff --git a/internal/commands/commands.go b/internal/commands/commands.go index 786f99019d737b32affb44392e0262ca069ab1d2..65192c59e276cec5d3eabb2cc1250a437139797c 100644 --- a/internal/commands/commands.go +++ b/internal/commands/commands.go @@ -7,6 +7,7 @@ import ( "path/filepath" "regexp" "strings" + "time" "github.com/charmbracelet/crush/internal/agent/tools/mcp" "github.com/charmbracelet/crush/internal/config" @@ -221,8 +222,12 @@ func isMarkdownFile(name string) bool { } func GetMCPPrompt(cfg *config.ConfigStore, clientID, promptID string, args map[string]string) (string, error) { - // TODO: we should pass the context down - result, err := mcp.GetPromptMessages(context.Background(), cfg, clientID, promptID, args) + // Create a context with timeout since tea.Cmd doesn't support context passing. + // The MCP client has its own timeout, but this provides an additional safeguard. + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + + result, err := mcp.GetPromptMessages(ctx, cfg, clientID, promptID, args) if err != nil { return "", err }