Skip to content

Commit 1c20560

Browse files
CCpro10ccpro10
andauthored
mcp: export jsonResponse field
Exporting StreamableHTTPOptions.JSONResponse is helpful for some users behind proxies that don't work well with text/event-stream. For #211 Co-authored-by: ccpro10 <[email protected]>
1 parent c76d991 commit 1c20560

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

mcp/streamable.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ type StreamableHTTPOptions struct {
7272

7373
// TODO: support session retention (?)
7474

75-
// jsonResponse is forwarded to StreamableServerTransport.jsonResponse.
76-
jsonResponse bool
75+
// JSONResponse is forwarded to StreamableServerTransport.jsonResponse.
76+
JSONResponse bool
7777
}
7878

7979
// NewStreamableHTTPHandler returns a new [StreamableHTTPHandler].
@@ -233,7 +233,7 @@ func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
233233
transport = &StreamableServerTransport{
234234
SessionID: sessionID,
235235
Stateless: h.opts.Stateless,
236-
jsonResponse: h.opts.jsonResponse,
236+
jsonResponse: h.opts.JSONResponse,
237237
}
238238

239239
// To support stateless mode, we initialize the session with a default
@@ -487,7 +487,7 @@ type stream struct {
487487
// jsonResponse records whether this stream should respond with application/json
488488
// instead of text/event-stream.
489489
//
490-
// See [StreamableServerTransportOptions.jsonResponse].
490+
// See [StreamableServerTransportOptions.JSONResponse].
491491
jsonResponse bool
492492

493493
// signal is a 1-buffered channel, owned by an incoming HTTP request, that signals

mcp/streamable_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestStreamableTransports(t *testing.T) {
8484
// Start an httptest.Server with the StreamableHTTPHandler, wrapped in a
8585
// cookie-checking middleware.
8686
handler := NewStreamableHTTPHandler(func(req *http.Request) *Server { return server }, &StreamableHTTPOptions{
87-
jsonResponse: useJSON,
87+
JSONResponse: useJSON,
8888
})
8989

9090
var (

0 commit comments

Comments
 (0)