feat: look up MCP applications under the admin owner

This commit is contained in:
Yang Luo
2026-08-22 12:23:05 +08:00
parent 2aa8b76153
commit 3a868edd9d
2 changed files with 10 additions and 5 deletions
+9 -4
View File
@@ -177,12 +177,13 @@ func (c *ApiController) DeleteServer() {
// @Title GetMcpAccessToken
// @Tag Server API
// @Description get an access token for the current session user to use with an MCP server
// @Param owner query string true "The owner of the application"
// @Param owner query string true "The organization name of the MCP server"
// @Param applicationName query string true "The name of the application"
// @Success 200 {object} controllers.Response The Response object
// @router /get-mcp-access-token [get]
func (c *ApiController) GetMcpAccessToken() {
owner := c.Ctx.Input.Query("owner")
// the "owner" of a server is its organization name, while all applications are owned by "admin"
organizationName := c.Ctx.Input.Query("owner")
applicationName := c.Ctx.Input.Query("applicationName")
user := c.getCurrentUser()
@@ -191,13 +192,17 @@ func (c *ApiController) GetMcpAccessToken() {
return
}
application, err := object.GetApplication(fmt.Sprintf("%s/%s", owner, applicationName))
application, err := object.GetApplication(fmt.Sprintf("admin/%s", applicationName))
if err != nil {
c.ResponseError(err.Error())
return
}
if application == nil {
c.ResponseError(fmt.Sprintf("application %s/%s does not exist", owner, applicationName))
c.ResponseError(fmt.Sprintf(c.T("auth:The application: %s does not exist"), applicationName))
return
}
if organizationName != "" && !application.IsShared && application.Organization != organizationName {
c.ResponseError(fmt.Sprintf("the application: %s does not belong to the organization: %s", applicationName, organizationName))
return
}
+1 -1
View File
@@ -160,7 +160,7 @@ func (c *McpController) GetClaimsFromToken() *object.Claims {
return nil
}
application, err := object.GetApplication(token.Application)
application, err := object.GetApplication(util.GetId(token.Owner, token.Application))
if err != nil || application == nil {
return nil
}