From 096b97e43332739740099230eb0a8020f6e399dc Mon Sep 17 00:00:00 2001 From: Kent Dong Date: Mon, 6 Oct 2025 15:09:21 +0800 Subject: [PATCH] fix: Eliminate compatibility risk of matching all domains for an MCP server (#2973) --- pkg/ingress/kube/annotations/mcpserver.go | 3 ++- pkg/ingress/kube/annotations/mcpserver_test.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/ingress/kube/annotations/mcpserver.go b/pkg/ingress/kube/annotations/mcpserver.go index 7812780c5..cd0ab5270 100644 --- a/pkg/ingress/kube/annotations/mcpserver.go +++ b/pkg/ingress/kube/annotations/mcpserver.go @@ -53,7 +53,8 @@ func (a mcpServer) Parse(annotations Annotations, config *Ingress, globalContext var matchRuleDomains []string rawMatchRuleDomains, _ := annotations.ParseStringASAP(mcpServerMatchRuleDomains) if rawMatchRuleDomains == "" || rawMatchRuleDomains == "*" { - // Match all domains. Leave an empty slice. + // Use wildcard to match all domains so we don't rely on the default behavior of empty domain list + matchRuleDomains = []string{"*"} } else if strings.Contains(rawMatchRuleDomains, ",") { matchRuleDomains = strings.Split(rawMatchRuleDomains, ",") } else { diff --git a/pkg/ingress/kube/annotations/mcpserver_test.go b/pkg/ingress/kube/annotations/mcpserver_test.go index b9a8b669b..1e7d6cf38 100644 --- a/pkg/ingress/kube/annotations/mcpserver_test.go +++ b/pkg/ingress/kube/annotations/mcpserver_test.go @@ -132,7 +132,7 @@ func TestMCPServer_Parse(t *testing.T) { }, expect: &mcpserver.McpServer{ Name: "default/route", - Domains: nil, + Domains: []string{"*"}, PathMatchType: "prefix", PathMatchValue: "/mcp", UpstreamType: "rest", @@ -153,7 +153,7 @@ func TestMCPServer_Parse(t *testing.T) { }, expect: &mcpserver.McpServer{ Name: "default/route", - Domains: nil, + Domains: []string{"*"}, PathMatchType: "prefix", PathMatchValue: "/mcp", UpstreamType: "rest",