/ common / websocket / mcp_server.go
mcp_server.go
 1  // Copyright (c) 2024-2026 Tencent Zhuque Lab. All rights reserved.
 2  //
 3  // Licensed under the Apache License, Version 2.0 (the "License");
 4  // you may not use this file except in compliance with the License.
 5  // You may obtain a copy of the License at
 6  //
 7  //     http://www.apache.org/licenses/LICENSE-2.0
 8  //
 9  // Unless required by applicable law or agreed to in writing, software
10  // distributed under the License is distributed on an "AS IS" BASIS,
11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  // See the License for the specific language governing permissions and
13  // limitations under the License.
14  //
15  // Requirement: Any integration or derivative work must explicitly attribute
16  // Tencent Zhuque Lab (https://github.com/Tencent/AI-Infra-Guard) in its
17  // documentation or user interface, as detailed in the NOTICE file.
18  
19  package websocket
20  
21  import (
22  	"github.com/Tencent/AI-Infra-Guard/common/utils"
23  	"github.com/Tencent/AI-Infra-Guard/internal/mcp"
24  	"github.com/gin-gonic/gin"
25  )
26  
27  func GetMcpPluginList(c *gin.Context) {
28  	scanner := mcp.NewScanner(nil, nil)
29  	names, err := scanner.GetAllPluginNames()
30  	ret := make([]string, 0)
31  	notInclude := []string{"code_info_collection", "mcp_info_collection", "vuln_review"}
32  	for _, name := range names {
33  		if utils.StrInSlice(name, notInclude) {
34  			continue
35  		}
36  		ret = append(ret, name)
37  	}
38  	if err != nil {
39  		c.JSON(500, gin.H{
40  			"code": 1,
41  			"msg":  err.Error(),
42  			"data": nil,
43  		})
44  		return
45  	}
46  	c.JSON(200, gin.H{
47  		"code": 0,
48  		"msg":  "",
49  		"data": ret,
50  	})
51  }