Fix/Add warning tips for MCP initialization when no valid servers configured (#1497)

* add tips for mcp

* fix test issue
This commit is contained in:
lxowalle
2026-03-13 16:43:00 +08:00
committed by GitHub
parent 87257819f6
commit 9530883d2c
2 changed files with 26 additions and 3 deletions
+16
View File
@@ -63,6 +63,22 @@ func (al *AgentLoop) ensureMCPInitialized(ctx context.Context) error {
return nil
}
if al.cfg.Tools.MCP.Servers == nil || len(al.cfg.Tools.MCP.Servers) == 0 {
logger.WarnCF("agent", "MCP is enabled but no servers are configured, skipping MCP initialization", nil)
return nil
}
findValidServer := false
for _, serverCfg := range al.cfg.Tools.MCP.Servers {
if serverCfg.Enabled {
findValidServer = true
}
}
if !findValidServer {
logger.WarnCF("agent", "MCP is enabled but no valid servers are configured, skipping MCP initialization", nil)
return nil
}
al.mcp.initOnce.Do(func() {
mcpManager := mcp.NewManager()