SSE: Add support for SSE handler options (#508)

mcp/sse: add support to provide for options for SSE transport

- Add SSEOptions struct to define SSE handler options.
- Update Signature of NewSSEHandler to accept SSEOptions [braking
change]
- Update unit test
- Update example test

Fixes https://github.com/modelcontextprotocol/go-sdk/issues/507,
https://github.com/modelcontextprotocol/go-sdk/issues/503
This commit is contained in:
Suraj Bobade 2025-09-19 22:31:57 +05:30 • committed by GitHub
commit 8c42b69817
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,7 +24,7 @@ func TestSSEServer(t *testing.T) {
server := NewServer(testImpl, nil)
AddTool(server, &Tool{Name: "greet"}, sayHi)
sseHandler := NewSSEHandler(func(*http.Request) *Server { return server })
sseHandler := NewSSEHandler(func(*http.Request) *Server { return server }, nil)
serverSessions := make(chan *ServerSession, 1)
sseHandler.onConnection = func(ss *ServerSession) {