From eb7b22d2b9f96c85c10a3fb3dbd731a8774c007f Mon Sep 17 00:00:00 2001 From: aias00 Date: Thu, 15 Jan 2026 10:46:21 +0800 Subject: [PATCH] fix: skip unhealthy or disabled services form nacos and always marshal `AllowTools` field (#3220) Co-authored-by: EricaLiu <30773688+Erica177@users.noreply.github.com> --- registry/mcp_model.go | 2 +- registry/nacos/mcpserver/watcher.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/registry/mcp_model.go b/registry/mcp_model.go index 9a491149b..19567f8bc 100644 --- a/registry/mcp_model.go +++ b/registry/mcp_model.go @@ -43,7 +43,7 @@ type McpServerRule struct { MatchRoute []string `json:"_match_route_,omitempty"` Server *ServerConfig `json:"server,omitempty"` Tools []*McpTool `json:"tools,omitempty"` - AllowTools []string `json:"allowTools,omitempty"` + AllowTools []string `json:"allowTools"` } type ServerConfig struct { diff --git a/registry/nacos/mcpserver/watcher.go b/registry/nacos/mcpserver/watcher.go index 4472df70d..ba8319f1f 100644 --- a/registry/nacos/mcpserver/watcher.go +++ b/registry/nacos/mcpserver/watcher.go @@ -434,7 +434,7 @@ func (w *watcher) processToolConfig(dataId, data string, credentials map[string] rule.Server.SecuritySchemes = toolsDescription.SecuritySchemes } - var allowTools []string + allowTools := []string{} for _, t := range toolsDescription.Tools { convertTool := &provider.McpTool{Name: t.Name, Description: t.Description} @@ -813,6 +813,9 @@ func generateServiceEntry(host string, services *model.Service) *v1alpha3.Servic endpoints := make([]*v1alpha3.WorkloadEntry, 0) for _, service := range services.Hosts { + if !service.Healthy || !service.Enable { + continue + } protocol := common.HTTP if service.Metadata != nil && service.Metadata["protocol"] != "" { protocol = common.ParseProtocol(service.Metadata["protocol"])