mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-04-05 15:36:15 +00:00
feat(resolvemcp): add SSE server and bunrouter setup functions
* Introduce SSEServer method for creating an SSE server bound to the handler. * Add SetupBunRouterRoutes function to mount MCP HTTP/SSE endpoints on bunrouter. * Update README with usage examples for new features.
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mark3labs/mcp-go/server"
|
||||
"github.com/uptrace/bun"
|
||||
bunrouter "github.com/uptrace/bunrouter"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/bitechdev/ResolveSpec/pkg/common"
|
||||
@@ -81,3 +82,19 @@ func NewSSEServer(handler *Handler, baseURL, basePath string) *server.SSEServer
|
||||
server.WithBasePath(basePath),
|
||||
)
|
||||
}
|
||||
|
||||
// SetupBunRouterRoutes mounts the MCP HTTP/SSE endpoints on a bunrouter router.
|
||||
//
|
||||
// Two routes are registered under the given basePath prefix:
|
||||
// - GET {basePath}/sse — SSE connection endpoint
|
||||
// - POST {basePath}/message — JSON-RPC message endpoint
|
||||
func SetupBunRouterRoutes(router *bunrouter.Router, handler *Handler, baseURL, basePath string) {
|
||||
sseServer := server.NewSSEServer(
|
||||
handler.mcpServer,
|
||||
server.WithBaseURL(baseURL),
|
||||
server.WithBasePath(basePath),
|
||||
)
|
||||
|
||||
router.GET(basePath+"/sse", bunrouter.HTTPHandler(sseServer.SSEHandler()))
|
||||
router.POST(basePath+"/message", bunrouter.HTTPHandler(sseServer.MessageHandler()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user