@@ -37,6 +37,10 @@ const (
3737)
3838
3939// Commands represents a dialog that shows available commands.
40+type dockerMCPAvailabilityCheckedMsg struct {
41+ available bool
42+}
43+
4044type Commands struct {
4145 com *common.Common
4246 keyMap struct {
@@ -66,6 +70,9 @@ type Commands struct {
6670
6771 customCommands []commands.CustomCommand
6872 mcpPrompts []commands.MCPPrompt
73+
74+ dockerMCPAvailable *bool
75+ dockerMCPCheckInFlight bool
6976}
7077
7178var _ Dialog = (*Commands)(nil)
@@ -126,6 +133,10 @@ func NewCommands(com *common.Common, sessionID string, hasSession, hasTodos, has
126133 closeKey.SetHelp("esc", "cancel")
127134 c.keyMap.Close = closeKey
128135
136+ if available, known := config.DockerMCPAvailabilityCached(); known {
137+ c.dockerMCPAvailable = &available
138+ }
139+
129140 // Set initial commands
130141 c.setCommandItems(c.selected)
131142
@@ -145,6 +156,13 @@ func (c *Commands) ID() string {
145156// HandleMsg implements [Dialog].
146157func (c *Commands) HandleMsg(msg tea.Msg) Action {
147158 switch msg := msg.(type) {
159+ case dockerMCPAvailabilityCheckedMsg:
160+ c.dockerMCPAvailable = &msg.available
161+ c.dockerMCPCheckInFlight = false
162+ if c.selected == SystemCommands {
163+ c.setCommandItems(c.selected)
164+ }
165+ return nil
148166 case spinner.TickMsg:
149167 if c.loading {
150168 var cmd tea.Cmd
@@ -207,6 +225,20 @@ func (c *Commands) HandleMsg(msg tea.Msg) Action {
207225 return nil
208226}
209227
228+func checkDockerMCPAvailabilityCmd() tea.Cmd {
229+ return func() tea.Msg {
230+ return dockerMCPAvailabilityCheckedMsg{available: config.RefreshDockerMCPAvailability()}
231+ }
232+}
233+
234+func (c *Commands) InitialCmd() tea.Cmd {
235+ if c.dockerMCPAvailable != nil || c.dockerMCPCheckInFlight {
236+ return nil
237+ }
238+ c.dockerMCPCheckInFlight = true
239+ return checkDockerMCPAvailabilityCmd()
240+}
241+
210242// Cursor returns the cursor position relative to the dialog.
211243func (c *Commands) Cursor() *tea.Cursor {
212244 return InputCursor(c.com.Styles, c.input.Cursor())
@@ -446,8 +478,8 @@ func (c *Commands) defaultCommands() []*CommandItem {
446478 commands = append(commands, NewCommandItem(c.com.Styles, "open_external_editor", "Open External Editor", "ctrl+o", ActionExternalEditor{}))
447479 }
448480
449− // Add Docker MCP command if available and not already enabled
450− if config.IsDockerMCPAvailable() && !cfg.IsDockerMCPEnabled() {
481+ // Add Docker MCP command if available and not already enabled.
482+ if !cfg.IsDockerMCPEnabled() && c.dockerMCPAvailable != nil && *c.dockerMCPAvailable {
451483 commands = append(commands, NewCommandItem(c.com.Styles, "enable_docker_mcp", "Enable Docker MCP Catalog", "", ActionEnableDockerMCP{}))
452484 }
453485