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:
Hein
2026-03-27 13:28:03 +02:00
parent 7ef9cf39d3
commit 200a03c225
3 changed files with 416 additions and 0 deletions

View File

@@ -52,6 +52,19 @@ func (h *Handler) MCPServer() *server.MCPServer {
return h.mcpServer
}
// SSEServer creates an *server.SSEServer bound to this handler.
// Use it to mount MCP on any HTTP framework that accepts http.Handler.
//
// sse := handler.SSEServer("http://localhost:8080", "/mcp")
// ginEngine.Any("/mcp/*path", gin.WrapH(sse))
func (h *Handler) SSEServer(baseURL, basePath string) *server.SSEServer {
return server.NewSSEServer(
h.mcpServer,
server.WithBaseURL(baseURL),
server.WithBasePath(basePath),
)
}
// RegisterModel registers a model and immediately exposes it as MCP tools and a resource.
func (h *Handler) RegisterModel(schema, entity string, model interface{}) error {
fullName := buildModelName(schema, entity)