mcp: do not check metatada on notifications (#1215)

Fixes #1212
This commit is contained in:
Guglielmo Colombo 2026-09-01 15:30:20 +02:00 • committed by GitHub
commit 2fdabde139
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1530,12 +1530,15 @@ func (c *streamableServerConn) servePOST(w http.ResponseWriter, req *http.Reques
// The new (>= 2026-07-28) protocol is supported on the HTTP transport
// only when [StreamableHTTPOptions.Stateless] is true.
//
// The `_meta` triple is defined for calls only, notifications are
// excluded.
//
// TODO: this validation can be moved within validateMcpHeaders.
var metaVersion string
if meta := extractRequestMeta(jreq.Params); meta != nil {
metaVersion, _ = meta[MetaKeyProtocolVersion].(string)
}
if protocolVersion >= protocolVersion20260728 || metaVersion != "" {
if (jreq.IsCall() && protocolVersion >= protocolVersion20260728) || metaVersion != "" {
// Extract again the protocol version from the context to see what the client
// is advertising in the Mcp-Protocol-Version HTTP header.
headerVersion := protocolVersionFromContext(req.Context())