@@ -7,6 +7,7 @@ import (
77 "path/filepath"
88 "regexp"
99 "strings"
10+ "time"
1011
1112 "github.com/charmbracelet/crush/internal/agent/tools/mcp"
1213 "github.com/charmbracelet/crush/internal/config"
@@ -221,8 +222,12 @@ func isMarkdownFile(name string) bool {
221222}
222223
223224func GetMCPPrompt(cfg *config.ConfigStore, clientID, promptID string, args map[string]string) (string, error) {
224− // TODO: we should pass the context down
225− result, err := mcp.GetPromptMessages(context.Background(), cfg, clientID, promptID, args)
225+ // Create a context with timeout since tea.Cmd doesn't support context passing.
226+ // The MCP client has its own timeout, but this provides an additional safeguard.
227+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
228+ defer cancel()
229+
230+ result, err := mcp.GetPromptMessages(ctx, cfg, clientID, promptID, args)
226231 if err != nil {
227232 return "", err
228233 }