feat(transport): add streamable HTTP transport for MCP

This commit is contained in:
2026-04-07 19:52:38 +02:00
parent 4adf94fe37
commit c2e2c9b873
3 changed files with 91 additions and 21 deletions
+8
View File
@@ -69,6 +69,14 @@ func (h *Handler) SSEServer() http.Handler {
return &dynamicSSEHandler{h: h}
}
// StreamableHTTPServer returns an http.Handler that serves MCP over the streamable HTTP transport.
// Unlike SSE (which requires two endpoints), streamable HTTP uses a single endpoint for all
// client-server communication (POST for requests, GET for server-initiated messages).
// Mount the returned handler at the desired path; the path itself becomes the MCP endpoint.
func (h *Handler) StreamableHTTPServer() http.Handler {
return server.NewStreamableHTTPServer(h.mcpServer)
}
// newSSEServer creates a concrete *server.SSEServer for known baseURL and basePath values.
func (h *Handler) newSSEServer(baseURL, basePath string) *server.SSEServer {
return server.NewSSEServer(