| 87 | } |
| 88 | |
| 89 | func (i *imlMcpController) AppHandleStreamHTTP(ctx *gin.Context) { |
| 90 | apikey := ctx.Request.Header.Get("Authorization") |
| 91 | apikey = strings.TrimPrefix(apikey, "Bearer ") |
| 92 | if apikey == "" { |
| 93 | ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": "invalid apikey", "success": "fail"}) |
| 94 | return |
| 95 | } |
| 96 | appId := ctx.Request.Header.Get("X-Application-Id") |
| 97 | if appId == "" { |
| 98 | ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": "invalid app id", "success": "fail"}) |
| 99 | return |
| 100 | } |
| 101 | cfg := i.settingModule.Get(ctx) |
| 102 | req := ctx.Request.WithContext(utils.SetGatewayInvoke(ctx.Request.Context(), cfg.InvokeAddress)) |
| 103 | |
| 104 | req = req.WithContext(utils.SetLabel(req.Context(), "apikey", apikey)) |
| 105 | req = req.WithContext(utils.SetLabel(req.Context(), "app", appId)) |
| 106 | req.URL.Path = mcp_server.OpenGlobalMCPPath |
| 107 | i.openStreamableServer.ServeHTTP(ctx.Writer, req) |
| 108 | } |
| 109 | |
| 110 | func (i *imlMcpController) AppMCPConfig(ctx *gin.Context, appId string) (string, error) { |
| 111 | cfg := i.settingModule.Get(ctx) |