mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-09-23 21:08:09 +00:00
* feat: mcp能力调整为 streamhttp的独立服务 不再依赖gva本体 * feat: 增加MCP启动能力,增加AI工作流需求整理能力。 * feat: 增加需求梳理能力 * feat: 清理无用日志 * feat: 移除无用的Dify Chatflow文本和代码生成器按钮
53 lines
1010 B
Go
53 lines
1010 B
Go
package mcpTool
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
|
mcpServer "github.com/mark3labs/mcp-go/server"
|
|
)
|
|
|
|
func NewMCPServer() *mcpServer.MCPServer {
|
|
config := global.GVA_CONFIG.MCP
|
|
|
|
s := mcpServer.NewMCPServer(
|
|
config.Name,
|
|
config.Version,
|
|
)
|
|
|
|
global.GVA_MCP_SERVER = s
|
|
RegisterAllTools(s)
|
|
|
|
return s
|
|
}
|
|
|
|
func NewStreamableHTTPServer() *mcpServer.StreamableHTTPServer {
|
|
config := global.GVA_CONFIG.MCP
|
|
path := config.Path
|
|
if path == "" {
|
|
path = "/mcp"
|
|
}
|
|
if !strings.HasPrefix(path, "/") {
|
|
path = "/" + path
|
|
}
|
|
|
|
mux := http.NewServeMux()
|
|
httpSrv := &http.Server{
|
|
Handler: mux,
|
|
}
|
|
|
|
handler := mcpServer.NewStreamableHTTPServer(
|
|
NewMCPServer(),
|
|
mcpServer.WithHTTPContextFunc(WithHTTPRequestContext),
|
|
mcpServer.WithStreamableHTTPServer(httpSrv),
|
|
)
|
|
mux.Handle(path, handler)
|
|
mux.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) {
|
|
w.WriteHeader(http.StatusOK)
|
|
_, _ = w.Write([]byte("ok"))
|
|
})
|
|
|
|
return handler
|
|
}
|