fix: Eliminate compatibility risk of matching all domains for an MCP server (#2973)

This commit is contained in:
Kent Dong
2025-10-06 15:09:21 +08:00
committed by GitHub
parent aebe354055
commit 096b97e433
2 changed files with 4 additions and 3 deletions

View File

@@ -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 {

View File

@@ -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",