MCPcopy Create free account
hub / github.com/diillson/chatcli / shouldAutoEnableMCP

Function shouldAutoEnableMCP

cli/cli.go:1636–1644  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1634// later: we still need the fsnotify watcher running on the parent
1635// directory so the Create event can fire Reload.
1636func 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,

Calls 1

DirMethod · 0.45