mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-10-07 16:13:51 +08:00
feat: 新增MCP Server功能,支持文档全局检索工具 (#1010)
* feat: i18n国际化语言支持完全可配置,并新增俄语支持 * feat: 新增MCP Server功能,支持文档全局检索工具
This commit is contained in:
@@ -7,7 +7,9 @@ import (
|
||||
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/mcp"
|
||||
"github.com/mindoc-org/mindoc/models"
|
||||
)
|
||||
|
||||
@@ -38,6 +40,7 @@ func init() {
|
||||
web.InsertFilter("/book/*", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/api/*", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/manage/*", web.BeforeRouter, FilterUser)
|
||||
web.InsertFilter("/mcp/*", web.BeforeRouter, mcp.AuthMiddleware)
|
||||
|
||||
var FinishRouter = func(ctx *context.Context) {
|
||||
ctx.ResponseWriter.Header().Add("MinDoc-Version", conf.VERSION)
|
||||
|
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
// "github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/controllers"
|
||||
"github.com/mindoc-org/mindoc/mcp"
|
||||
)
|
||||
|
||||
type CorsTransport struct {
|
||||
@@ -268,4 +269,10 @@ func init() {
|
||||
web.Router("/items", &controllers.ItemsetsController{}, "get:Index")
|
||||
web.Router("/items/:key", &controllers.ItemsetsController{}, "get:List")
|
||||
|
||||
if web.AppConfig.DefaultBool("enable_mcp_server", false) {
|
||||
mcpServer := mcp.NewMCPServer()
|
||||
web.Any("/mcp/*", func(ctx *context.Context) {
|
||||
mcpServer.ServeHTTP().ServeHTTP(ctx.ResponseWriter, ctx.Request)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user