@@ -580,10 +580,6 @@ func (c *streamableServerConn) servePOST(w http.ResponseWriter, req *http.Reques
580580 // This also requires access to the negotiated version, which would either be
581581 // set by the MCP-Protocol-Version header, or would require peeking into the
582582 // session.
583- if err != nil {
584- http .Error (w , fmt .Sprintf ("malformed payload: %v" , err ), http .StatusBadRequest )
585- return
586- }
587583 incoming , _ , err := readBatch (body )
588584 if err != nil {
589585 http .Error (w , fmt .Sprintf ("malformed payload: %v" , err ), http .StatusBadRequest )
@@ -592,17 +588,20 @@ func (c *streamableServerConn) servePOST(w http.ResponseWriter, req *http.Reques
592588 requests := make (map [jsonrpc.ID ]struct {})
593589 tokenInfo := auth .TokenInfoFromContext (req .Context ())
594590 for _ , msg := range incoming {
595- if req , ok := msg .(* jsonrpc.Request ); ok {
591+ if jreq , ok := msg .(* jsonrpc.Request ); ok {
596592 // Preemptively check that this is a valid request, so that we can fail
597593 // the HTTP request. If we didn't do this, a request with a bad method or
598594 // missing ID could be silently swallowed.
599- if _ , err := checkRequest (req , serverMethodInfos ); err != nil {
595+ if _ , err := checkRequest (jreq , serverMethodInfos ); err != nil {
600596 http .Error (w , err .Error (), http .StatusBadRequest )
601597 return
602598 }
603- req .Extra = & RequestExtra {TokenInfo : tokenInfo }
604- if req .IsCall () {
605- requests [req .ID ] = struct {}{}
599+ jreq .Extra = & RequestExtra {
600+ TokenInfo : tokenInfo ,
601+ Header : req .Header ,
602+ }
603+ if jreq .IsCall () {
604+ requests [jreq .ID ] = struct {}{}
606605 }
607606 }
608607 }
0 commit comments