Skip to content

Commit 519b6b3

Browse files
committed
Replace http.Server by a generic ListenAndServer
Signed-off-by: Alvaro Saurin <[email protected]>
1 parent 781b732 commit 519b6b3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/sse.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ func (s *sseSession) Initialized() bool {
5151

5252
var _ ClientSession = (*sseSession)(nil)
5353

54+
// ListenAndServer is a type that implements ListenAndServe and Shutdown
55+
type ListenAndServer interface {
56+
ListenAndServe() error
57+
Shutdown(ctx context.Context) error
58+
}
59+
5460
// SSEServer implements a Server-Sent Events (SSE) based MCP server.
5561
// It provides real-time communication capabilities over HTTP using the SSE protocol.
5662
type SSEServer struct {
@@ -61,7 +67,7 @@ type SSEServer struct {
6167
messageEndpoint string
6268
sseEndpoint string
6369
sessions sync.Map
64-
srv *http.Server
70+
srv ListenAndServer
6571
contextFunc SSEContextFunc
6672

6773
keepAlive bool
@@ -131,7 +137,7 @@ func WithSSEEndpoint(endpoint string) SSEOption {
131137
}
132138

133139
// WithHTTPServer sets the HTTP server instance
134-
func WithHTTPServer(srv *http.Server) SSEOption {
140+
func WithHTTPServer(srv ListenAndServer) SSEOption {
135141
return func(s *SSEServer) {
136142
s.srv = srv
137143
}

0 commit comments

Comments
 (0)