@@ -184,8 +184,7 @@ type StreamableHTTPOptions struct {
184184 // CrossOriginProtection allows to customize cross-origin protection.
185185 // The deny handler set in the CrossOriginProtection through SetDenyHandler
186186 // is ignored.
187- // If nil, no cross-origin protection is applied. Use the `enableoriginverification`
188- // MCPGODEBUG compatibility parameter to enable the default protection until v1.8.0.
187+ // If nil, no cross-origin protection is applied.
189188 //
190189 // Deprecated: wrap the handler with cross-origin protection middleware
191190 // instead. For example:
@@ -240,10 +239,6 @@ func NewStreamableHTTPHandler(getServer func(*http.Request) *Server, opts *Strea
240239
241240 h .opts .Logger = ensureLogger (h .opts .Logger )
242241
243- if h .opts .CrossOriginProtection == nil && enableoriginverification == "1" {
244- h .opts .CrossOriginProtection = & http.CrossOriginProtection {}
245- }
246-
247242 if h .opts .MaxRequestBodyBytes == 0 {
248243 h .opts .MaxRequestBodyBytes = DefaultMaxRequestBodyBytes
249244 }
@@ -274,20 +269,6 @@ func (h *StreamableHTTPHandler) closeAll() {
274269 }
275270}
276271
277- // disablelocalhostprotection is a compatibility parameter that allows to disable
278- // DNS rebinding protection, which was added in the 1.4.0 version of the SDK.
279- // See the documentation for the mcpgodebug package for instructions how to enable it.
280- // The option will be removed in the 1.8.0 version of the SDK.
281- var disablelocalhostprotection = mcpgodebug .Value ("disablelocalhostprotection" )
282-
283- // enableoriginverification is a compatibility parameter that restores the
284- // default cross-origin protection behavior from v1.4.1-v1.5.0. When set to
285- // "1", a zero-value CrossOriginProtection will be applied if none is
286- // explicitly provided in StreamableHTTPOptions.
287- // See the documentation for the mcpgodebug package for instructions how to enable it.
288- // The option will be removed in the 1.8.0 version of the SDK.
289- var enableoriginverification = mcpgodebug .Value ("enableoriginverification" )
290-
291272// allowsessionsinstateless is a compatibility parameter that restores the old
292273// behavior of reading and using Mcp-Session-Id headers in stateless mode. When
293274// set to "1", stateless servers will read the session ID from the request
@@ -308,12 +289,6 @@ var allowsessionsinstateless = mcpgodebug.Value("allowsessionsinstateless")
308289// permanently fails the connection.
309290var noprotocolerrorbody = mcpgodebug .Value ("noprotocolerrorbody" )
310291
311- // disablecontenttypecheck is a compatibility parameter that allows to disable
312- // Content-Type validation on POST requests.
313- // See the documentation for the mcpgodebug package for instructions how to enable it.
314- // The option will be removed in the 1.8.0 version of the SDK.
315- var disablecontenttypecheck = mcpgodebug .Value ("disablecontenttypecheck" )
316-
317292// plaintextstatefulrejection is a compatibility parameter that restores the
318293// previous behavior of a stateful [StreamableHTTPHandler] when it receives a
319294// request carrying SEP-2575 per-request metadata (i.e. an
@@ -341,7 +316,7 @@ func writeJSONRPCError(w http.ResponseWriter, status int, id jsonrpc.ID, jerr *j
341316func (h * StreamableHTTPHandler ) ServeHTTP (w http.ResponseWriter , req * http.Request ) {
342317 // DNS rebinding protection: auto-enabled for localhost servers.
343318 // See: https://modelcontextprotocol.io/specification/2025-11-25/basic/security_best_practices#local-mcp-server-compromise
344- if ! h .opts .DisableLocalhostProtection && disablelocalhostprotection != "1" {
319+ if ! h .opts .DisableLocalhostProtection {
345320 if localAddr , ok := req .Context ().Value (http .LocalAddrContextKey ).(net.Addr ); ok && localAddr != nil {
346321 if util .IsLoopback (localAddr .String ()) && ! util .IsLoopback (req .Host ) {
347322 http .Error (w , fmt .Sprintf ("Forbidden: invalid Host header %q" , req .Host ), http .StatusForbidden )
@@ -410,7 +385,7 @@ func (h *StreamableHTTPHandler) serveStateless(w http.ResponseWriter, req *http.
410385 return
411386 }
412387
413- if disablecontenttypecheck != "1" && baseMediaType (req .Header .Get ("Content-Type" )) != "application/json" {
388+ if baseMediaType (req .Header .Get ("Content-Type" )) != "application/json" {
414389 http .Error (w , "Content-Type must be 'application/json'" , http .StatusUnsupportedMediaType )
415390 return
416391 }
@@ -644,7 +619,7 @@ func (h *StreamableHTTPHandler) serveStatefulDELETE(w http.ResponseWriter, req *
644619// ID, a new session is created (this is the normal path for the first
645620// initialize request).
646621func (h * StreamableHTTPHandler ) serveStatefulPOST (w http.ResponseWriter , req * http.Request ) {
647- if disablecontenttypecheck != "1" && baseMediaType (req .Header .Get ("Content-Type" )) != "application/json" {
622+ if baseMediaType (req .Header .Get ("Content-Type" )) != "application/json" {
648623 http .Error (w , "Content-Type must be 'application/json'" , http .StatusUnsupportedMediaType )
649624 return
650625 }
0 commit comments