mirror of
https://github.com/alibaba/higress.git
synced 2026-06-09 12:47:28 +08:00
fix typos (#2656)
Signed-off-by: co63oc <co63oc@users.noreply.github.com>
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/nacos-group/nacos-sdk-go/v2/vo"
|
"github.com/nacos-group/nacos-sdk-go/v2/vo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NacosMcpRegsitry struct {
|
type NacosMcpRegistry struct {
|
||||||
serviceMatcher map[string]string
|
serviceMatcher map[string]string
|
||||||
configClient config_client.IConfigClient
|
configClient config_client.IConfigClient
|
||||||
namingClient naming_client.INamingClient
|
namingClient naming_client.INamingClient
|
||||||
@@ -27,7 +27,7 @@ type NacosMcpRegsitry struct {
|
|||||||
const DEFAULT_SERVICE_LIST_MAX_PGSIZXE = 10000
|
const DEFAULT_SERVICE_LIST_MAX_PGSIZXE = 10000
|
||||||
const MCP_TOOL_SUBFIX = "-mcp-tools.json"
|
const MCP_TOOL_SUBFIX = "-mcp-tools.json"
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) ListToolsDesciption() []*registry.ToolDescription {
|
func (n *NacosMcpRegistry) ListToolsDescription() []*registry.ToolDescription {
|
||||||
if n.toolsDescription == nil {
|
if n.toolsDescription == nil {
|
||||||
n.refreshToolsList()
|
n.refreshToolsList()
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ func (n *NacosMcpRegsitry) ListToolsDesciption() []*registry.ToolDescription {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) GetToolRpcContext(toolName string) (*registry.RpcContext, bool) {
|
func (n *NacosMcpRegistry) GetToolRpcContext(toolName string) (*registry.RpcContext, bool) {
|
||||||
if n.toolsRpcContext == nil {
|
if n.toolsRpcContext == nil {
|
||||||
n.refreshToolsList()
|
n.refreshToolsList()
|
||||||
}
|
}
|
||||||
@@ -47,11 +47,11 @@ func (n *NacosMcpRegsitry) GetToolRpcContext(toolName string) (*registry.RpcCont
|
|||||||
return tool, ok
|
return tool, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) RegisterToolChangeEventListener(listener registry.ToolChangeEventListener) {
|
func (n *NacosMcpRegistry) RegisterToolChangeEventListener(listener registry.ToolChangeEventListener) {
|
||||||
n.toolChangeEventListeners = append(n.toolChangeEventListeners, listener)
|
n.toolChangeEventListeners = append(n.toolChangeEventListeners, listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) refreshToolsList() bool {
|
func (n *NacosMcpRegistry) refreshToolsList() bool {
|
||||||
changed := false
|
changed := false
|
||||||
for group, serviceMatcher := range n.serviceMatcher {
|
for group, serviceMatcher := range n.serviceMatcher {
|
||||||
if n.refreshToolsListForGroup(group, serviceMatcher) {
|
if n.refreshToolsListForGroup(group, serviceMatcher) {
|
||||||
@@ -61,7 +61,7 @@ func (n *NacosMcpRegsitry) refreshToolsList() bool {
|
|||||||
return changed
|
return changed
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) refreshToolsListForGroup(group string, serviceMatcher string) bool {
|
func (n *NacosMcpRegistry) refreshToolsListForGroup(group string, serviceMatcher string) bool {
|
||||||
services, err := n.namingClient.GetAllServicesInfo(vo.GetAllServiceInfoParam{
|
services, err := n.namingClient.GetAllServicesInfo(vo.GetAllServiceInfoParam{
|
||||||
GroupName: group,
|
GroupName: group,
|
||||||
PageNo: 1,
|
PageNo: 1,
|
||||||
@@ -134,7 +134,7 @@ func getFormatServiceName(group string, service string) string {
|
|||||||
return fmt.Sprintf("%s_%s", group, service)
|
return fmt.Sprintf("%s_%s", group, service)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) deleteToolForService(group string, service string) {
|
func (n *NacosMcpRegistry) deleteToolForService(group string, service string) {
|
||||||
toolsNeedReset := []string{}
|
toolsNeedReset := []string{}
|
||||||
|
|
||||||
formatServiceName := getFormatServiceName(group, service)
|
formatServiceName := getFormatServiceName(group, service)
|
||||||
@@ -150,7 +150,7 @@ func (n *NacosMcpRegsitry) deleteToolForService(group string, service string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) refreshToolsListForServiceWithContent(group string, service string, newConfig *string, instances *[]model.Instance) bool {
|
func (n *NacosMcpRegistry) refreshToolsListForServiceWithContent(group string, service string, newConfig *string, instances *[]model.Instance) bool {
|
||||||
|
|
||||||
if newConfig == nil {
|
if newConfig == nil {
|
||||||
dataId := makeToolsConfigId(service)
|
dataId := makeToolsConfigId(service)
|
||||||
@@ -243,7 +243,7 @@ func (n *NacosMcpRegsitry) refreshToolsListForServiceWithContent(group string, s
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) GetCredential(name string, group string) *registry.CredentialInfo {
|
func (n *NacosMcpRegistry) GetCredential(name string, group string) *registry.CredentialInfo {
|
||||||
dataId := makeCredentialDataId(name)
|
dataId := makeCredentialDataId(name)
|
||||||
content, err := n.configClient.GetConfig(vo.ConfigParam{
|
content, err := n.configClient.GetConfig(vo.ConfigParam{
|
||||||
DataId: dataId,
|
DataId: dataId,
|
||||||
@@ -265,11 +265,11 @@ func (n *NacosMcpRegsitry) GetCredential(name string, group string) *registry.Cr
|
|||||||
return &credential
|
return &credential
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) refreshToolsListForService(group string, service string) bool {
|
func (n *NacosMcpRegistry) refreshToolsListForService(group string, service string) bool {
|
||||||
return n.refreshToolsListForServiceWithContent(group, service, nil, nil)
|
return n.refreshToolsListForServiceWithContent(group, service, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NacosMcpRegsitry) listenToService(group string, service string) {
|
func (n *NacosMcpRegistry) listenToService(group string, service string) {
|
||||||
|
|
||||||
// config changed, tools description may be changed
|
// config changed, tools description may be changed
|
||||||
err := n.configClient.ListenConfig(vo.ConfigParam{
|
err := n.configClient.ListenConfig(vo.ConfigParam{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func (l *McpServerToolsChangeListener) OnToolChanged(reg registry.McpServerRegis
|
|||||||
resetToolsToMcpServer(l.mcpServer, reg)
|
resetToolsToMcpServer(l.mcpServer, reg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateNacosMcpRegsitry(config *NacosConfig) (*NacosMcpRegsitry, error) {
|
func CreateNacosMcpRegistry(config *NacosConfig) (*NacosMcpRegistry, error) {
|
||||||
sc := []constant.ServerConfig{
|
sc := []constant.ServerConfig{
|
||||||
*constant.NewServerConfig(*config.ServerAddr, 8848, constant.WithContextPath("/nacos")),
|
*constant.NewServerConfig(*config.ServerAddr, 8848, constant.WithContextPath("/nacos")),
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ func CreateNacosMcpRegsitry(config *NacosConfig) (*NacosMcpRegsitry, error) {
|
|||||||
return nil, fmt.Errorf("failed to initial naming config client: %w", err)
|
return nil, fmt.Errorf("failed to initial naming config client: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &NacosMcpRegsitry{
|
return &NacosMcpRegistry{
|
||||||
configClient: configClient,
|
configClient: configClient,
|
||||||
namingClient: namingClient,
|
namingClient: namingClient,
|
||||||
serviceMatcher: *config.ServiceMatcher,
|
serviceMatcher: *config.ServiceMatcher,
|
||||||
@@ -143,7 +143,7 @@ func (c *NacosConfig) NewServer(serverName string) (*common.MCPServer, error) {
|
|||||||
"1.0.0",
|
"1.0.0",
|
||||||
)
|
)
|
||||||
|
|
||||||
nacosRegistry, err := CreateNacosMcpRegsitry(c)
|
nacosRegistry, err := CreateNacosMcpRegistry(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to initialize NacosMcpRegistry: %w", err)
|
return nil, fmt.Errorf("failed to initialize NacosMcpRegistry: %w", err)
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ func (c *NacosConfig) NewServer(serverName string) (*common.MCPServer, error) {
|
|||||||
|
|
||||||
func resetToolsToMcpServer(mcpServer *common.MCPServer, reg registry.McpServerRegistry) {
|
func resetToolsToMcpServer(mcpServer *common.MCPServer, reg registry.McpServerRegistry) {
|
||||||
wrappedTools := []common.ServerTool{}
|
wrappedTools := []common.ServerTool{}
|
||||||
tools := reg.ListToolsDesciption()
|
tools := reg.ListToolsDescription()
|
||||||
for _, tool := range tools {
|
for _, tool := range tools {
|
||||||
wrappedTools = append(wrappedTools, common.ServerTool{
|
wrappedTools = append(wrappedTools, common.ServerTool{
|
||||||
Tool: mcp.NewToolWithRawSchema(tool.Name, tool.Description, tool.InputSchema),
|
Tool: mcp.NewToolWithRawSchema(tool.Name, tool.Description, tool.InputSchema),
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ type ToolChangeEventListener interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type McpServerRegistry interface {
|
type McpServerRegistry interface {
|
||||||
ListToolsDesciption() []*ToolDescription
|
ListToolsDescription() []*ToolDescription
|
||||||
GetToolRpcContext(toolname string) (*RpcContext, bool)
|
GetToolRpcContext(toolname string) (*RpcContext, bool)
|
||||||
RegisterToolChangeEventListener(listener ToolChangeEventListener)
|
RegisterToolChangeEventListener(listener ToolChangeEventListener)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ func selectOneInstance(ctx *RpcContext) (*Instance, error) {
|
|||||||
return &select_instance, nil
|
return &select_instance, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRemoteCallhandle(ctx *RpcContext) (RemoteCallHandle, error) {
|
func getRemoteCallHandle(ctx *RpcContext) (RemoteCallHandle, error) {
|
||||||
if ctx.Protocol == PROTOCOL_HTTP || ctx.Protocol == PROTOCOL_HTTPS {
|
if ctx.Protocol == PROTOCOL_HTTP || ctx.Protocol == PROTOCOL_HTTPS {
|
||||||
return newHttpRemoteCallHandle(ctx)
|
return newHttpRemoteCallHandle(ctx)
|
||||||
} else {
|
} else {
|
||||||
@@ -192,7 +192,7 @@ func CommonRemoteCall(reg McpServerRegistry, toolName string, parameters map[str
|
|||||||
return nil, fmt.Errorf("Unknown tool %s", toolName)
|
return nil, fmt.Errorf("Unknown tool %s", toolName)
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteHandle, err := getRemoteCallhandle(ctx)
|
remoteHandle, err := getRemoteCallHandle(ctx)
|
||||||
if remoteHandle == nil {
|
if remoteHandle == nil {
|
||||||
return nil, fmt.Errorf("Unknown backend protocol %s", ctx.Protocol)
|
return nil, fmt.Errorf("Unknown backend protocol %s", ctx.Protocol)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Higress API MCP Server 提供了 MCP 工具来管理 Higress 路由、服务来
|
|||||||
### 插件管理
|
### 插件管理
|
||||||
- `get-plugin`: 获取插件配置
|
- `get-plugin`: 获取插件配置
|
||||||
- `delete-plugin`: 删除插件
|
- `delete-plugin`: 删除插件
|
||||||
- `update-request-block-plguin`: 更新 request-block 插件配置
|
- `update-request-block-plugin`: 更新 request-block 插件配置
|
||||||
|
|
||||||
## 配置参数
|
## 配置参数
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Higress 提供了运行 Ingress API 一致性测试和 wasmplugin 测试的 make
|
|||||||
4. kube-load-image: 将 dev higress-controller 镜像加载到 kind 集群中。
|
4. kube-load-image: 将 dev higress-controller 镜像加载到 kind 集群中。
|
||||||
5. install-dev: 使用 helm 安装带有 dev 镜像的 higress-controller,并安装最新的 higress-gateway、istiod。
|
5. install-dev: 使用 helm 安装带有 dev 镜像的 higress-controller,并安装最新的 higress-gateway、istiod。
|
||||||
6. run-e2e-test:
|
6. run-e2e-test:
|
||||||
1. 所有测试都在 `test/e2e/conformance/tests` 中定义,并在初始化阶段被注册到`ConformanceTests`中。`ConormanceTests` 是一个全局变量,用于存储所有的一致性测试用例。
|
1. 所有测试都在 `test/e2e/conformance/tests` 中定义,并在初始化阶段被注册到`ConformanceTests`中。`ConformanceTests` 是一个全局变量,用于存储所有的一致性测试用例。
|
||||||
2. 准备资源并将它们安装到集群中,例如后端服务/部署。
|
2. 准备资源并将它们安装到集群中,例如后端服务/部署。
|
||||||
3. 加载选择打开的一致性测试,并逐个运行它们,如果不符合预期,则失败。
|
3. 加载选择打开的一致性测试,并逐个运行它们,如果不符合预期,则失败。
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ Higress 提供了运行 Ingress API 一致性测试和 wasmplugin 测试的 make
|
|||||||
|
|
||||||
要添加新的测试用例,首先需要在 `test/ingress/conformance/tests` 中添加 `xxx.go` 和 `xxx.yaml`。`xxx.yaml` 是您需要在集群中应用的 Ingress 资源,`xxx.go` 定义了 HigressConformanceTest。
|
要添加新的测试用例,首先需要在 `test/ingress/conformance/tests` 中添加 `xxx.go` 和 `xxx.yaml`。`xxx.yaml` 是您需要在集群中应用的 Ingress 资源,`xxx.go` 定义了 HigressConformanceTest。
|
||||||
|
|
||||||
然后,您应该将您定义的测试用例注册到`ConormanceTests`中,方法是在xxx.go中使用`init()` 函数调用`Register(YOUR_PLUGIN_SHORT_NAME)`。
|
然后,您应该将您定义的测试用例注册到`ConformanceTests`中,方法是在xxx.go中使用`init()` 函数调用`Register(YOUR_PLUGIN_SHORT_NAME)`。
|
||||||
|
|
||||||
通过查看 `test/ingress/conformance/tests/httproute-simple-same-namespace.go` 和 `test/ingress/conformance/tests/httproute-simple-same-namespace.yaml` 中的代码,您可以快速了解并尝试编写一个测试用例。
|
通过查看 `test/ingress/conformance/tests/httproute-simple-same-namespace.go` 和 `test/ingress/conformance/tests/httproute-simple-same-namespace.yaml` 中的代码,您可以快速了解并尝试编写一个测试用例。
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,10 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
metadata:
|
metadata:
|
||||||
name: consul-standlone
|
name: consul-standalone
|
||||||
namespace: higress-conformance-app-backend
|
namespace: higress-conformance-app-backend
|
||||||
labels:
|
labels:
|
||||||
name: consul-standlone
|
name: consul-standalone
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: consul
|
- name: consul
|
||||||
@@ -46,7 +46,7 @@ metadata:
|
|||||||
name: consul-service
|
name: consul-service
|
||||||
namespace: higress-conformance-app-backend
|
namespace: higress-conformance-app-backend
|
||||||
labels:
|
labels:
|
||||||
name: consul-standlone
|
name: consul-standalone
|
||||||
spec:
|
spec:
|
||||||
clusterIP: None
|
clusterIP: None
|
||||||
ports:
|
ports:
|
||||||
@@ -55,7 +55,7 @@ spec:
|
|||||||
protocol: TCP
|
protocol: TCP
|
||||||
targetPort: 8500
|
targetPort: 8500
|
||||||
selector:
|
selector:
|
||||||
name: consul-standlone
|
name: consul-standalone
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
|
|||||||
Reference in New Issue
Block a user