From ad6e07588fae82ee82b66a66fccb552842496146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Tue, 1 Sep 2026 13:41:18 +0800 Subject: [PATCH] fix(apigateway): update mcp api addr (#25456) --- pkg/apigateway/handler/mcp_agent.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/apigateway/handler/mcp_agent.go b/pkg/apigateway/handler/mcp_agent.go index 5ba27355e1..80f51c56e4 100644 --- a/pkg/apigateway/handler/mcp_agent.go +++ b/pkg/apigateway/handler/mcp_agent.go @@ -11,7 +11,6 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" - "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/apigateway/options" "yunion.io/x/onecloud/pkg/appsrv" @@ -22,12 +21,7 @@ import ( ) func mcpServersConfigHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - serviceName := "mcp-server" - url, err := auth.GetPublicServiceURL(serviceName, options.Options.Region, "", httputils.GET) - if err != nil { - log.Warningf("GetPublicServiceURL for %s failed: %v", serviceName, err) - } - sseURL := fmt.Sprintf("%s/sse", url) + sseURL := fmt.Sprintf("%s/api/s/mcp-server/sse", options.Options.ApiServer) responseType := r.URL.Query().Get("type") switch responseType { @@ -38,6 +32,11 @@ func mcpServersConfigHandler(ctx context.Context, w http.ResponseWriter, r *http w.Header().Set("Content-Type", "text/plain; charset=utf-8") w.Write([]byte(cmd)) return + case "openclaw": + cmd := fmt.Sprintf("openclaw mcp add --transport sse %s --header \"X-API-Key: <填写 token 或 base64(AK:SK)>\"", sseURL) + w.Header().Set("Content-Type", "text/plain; charset=utf-8") + w.Write([]byte(cmd)) + return case "cursor": // fall through to JSON default: