Files
TaskPool/internal/router/mcp.go
T
admin 066383de83
Build and Deploy / build-and-push (push) Successful in 54s
feat(mcp): integrate MCP Server into backend service as built-in endpoint
- Add MCP Controller and register /mcp route
- MCP Server now uses OpenAPI Token for authentication
- Update frontend settings to show built-in MCP endpoint config
- Update docs to reflect integrated MCP endpoint
2026-07-27 02:38:09 +08:00

21 lines
577 B
Go

package router
import (
"github.com/engigu/taskpool/internal/middleware"
"github.com/gin-gonic/gin"
)
// initMCPRoutes 初始化 MCP Server 路由
// 使用 OpenAPI Token 进行鉴权
func initMCPRoutes(root *gin.RouterGroup, c *Controllers) {
// MCP 路由组 (使用 Bearer Token 鉴权,复用 OpenAPI 中间件)
mcp := root.Group("/mcp")
mcp.Use(middleware.OpenapiRequired())
{
// 所有 MCP 请求都通过同一个 handler 处理
// StreamableHTTP 协议支持 POST 和 GET
mcp.POST("/*action", c.MCP.HandleMCP)
mcp.GET("/*action", c.MCP.HandleMCP)
}
}