shouldAutoEnableMCP returns true when MCP should be initialized automatically (i.e., without `CHATCLI_MCP_ENABLED=true`). It says yes when either the config file already exists OR its parent directory exists — the latter is what keeps hot-reload alive when the user opens chatcli with no `mcp_servers
(mcpConfigPath string)
| 1634 | // later: we still need the fsnotify watcher running on the parent |
| 1635 | // directory so the Create event can fire Reload. |
| 1636 | func shouldAutoEnableMCP(mcpConfigPath string) bool { |
| 1637 | if _, err := os.Stat(mcpConfigPath); err == nil { //#nosec G304 -- env-supplied path; only Stat, no read |
| 1638 | return true |
| 1639 | } |
| 1640 | if info, err := os.Stat(filepath.Dir(mcpConfigPath)); err == nil && info.IsDir() { //#nosec G304 -- env-supplied path; only Stat of parent directory |
| 1641 | return true |
| 1642 | } |
| 1643 | return false |
| 1644 | } |
| 1645 | |
| 1646 | // bootstrapMCP wires up the MCP manager + config watcher during |
| 1647 | // chatcli startup. Pulled out of NewChatCLI so the auto-enable rule, |