mcp: add MCPGPDEBUG for opt-in Content-Type check (#1012)

Copy of existing
[PR](https://github.com/modelcontextprotocol/go-sdk/pull/972) patching
1.6.0 version
This commit is contained in:
Guglielmo Colombo 2026-06-17 11:41:35 +02:00 • committed by GitHub
commit 71ffcb412a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -202,7 +202,7 @@ func (h *SSEHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
// Validate 'Content-Type' header.
if req.Method == http.MethodPost {
if disablecontenttypecheck != "1" && req.Method == http.MethodPost {
mediaType, _, err := mime.ParseMediaType(req.Header.Get("Content-Type"))
if err != nil || mediaType != "application/json" {
http.Error(w, "Content-Type must be 'application/json'", http.StatusUnsupportedMediaType)