diff --git a/registry/nacos/mcpserver/watcher.go b/registry/nacos/mcpserver/watcher.go index 3b47fd381..73f66eaf4 100644 --- a/registry/nacos/mcpserver/watcher.go +++ b/registry/nacos/mcpserver/watcher.go @@ -689,7 +689,7 @@ func (w *watcher) getServiceCallback(server *provider.McpServer, configGroup, da Meta: config.Meta{ GroupVersionKind: gvk.ServiceEntry, Name: fmt.Sprintf("%s-%s-%s", provider.IstioMcpAutoGeneratedSeName, configGroup, strings.TrimSuffix(dataId, ".json")), - Namespace: w.namespace, + Namespace: "mcp", }, Spec: serviceEntry, } @@ -706,12 +706,12 @@ func (w *watcher) getServiceCallback(server *provider.McpServer, configGroup, da w.cache.UpdateConfigCache(gvk.DestinationRule, configKey, dr, false) } w.cache.UpdateConfigCache(gvk.ServiceEntry, configKey, se, false) - vs := w.buildVirtualServiceForMcpServer(serviceEntry, configGroup, dataId, path, server.Name) + vs := w.buildVirtualServiceForMcpServer(serviceEntry, configGroup, dataId, path, server) w.cache.UpdateConfigCache(gvk.VirtualService, configKey, vs, false) } } -func (w *watcher) buildVirtualServiceForMcpServer(serviceentry *v1alpha3.ServiceEntry, group, dataId, path, serverName string) *config.Config { +func (w *watcher) buildVirtualServiceForMcpServer(serviceentry *v1alpha3.ServiceEntry, group, dataId, path, server *provider.McpServer) *config.Config { if serviceentry == nil { return nil } @@ -728,7 +728,7 @@ func (w *watcher) buildVirtualServiceForMcpServer(serviceentry *v1alpha3.Service common2.CreateConvertedName(constants.IstioIngressGatewayName, cleanHost)) } routeName := fmt.Sprintf("%s-%s-%s", provider.IstioMcpAutoGeneratedHttpRouteName, group, strings.TrimSuffix(dataId, ".json")) - mergePath := "/" + serverName + mergePath := "/" + server.Name if w.McpServerBaseUrl != "/" { mergePath = strings.TrimSuffix(w.McpServerBaseUrl, "/") + mergePath } @@ -762,6 +762,12 @@ func (w *watcher) buildVirtualServiceForMcpServer(serviceentry *v1alpha3.Service }}, } + if server.Protocol == provider.McpStreambleProtocol { + vs.Http[0].Rewrite = &v1alpha3.HTTPRewrite{ + Uri: path, + } + } + mcpServerLog.Debugf("construct virtualservice %v", vs) return &config.Config{