mcp: do not exclude Notifications from carrying InitializeParams in Meta (#1049)
Fixes #1043
This commit is contained in:
parent
a901f97b6d
commit
224a240875
1 changed files with 8 additions and 31 deletions
|
|
@ -515,11 +515,10 @@ type validatedMeta struct {
|
|||
// the >= 2026-07-28 protocol via the `_meta` field.
|
||||
// If the request has no _meta, or no protocolVersion in _meta, it returns a non-nil
|
||||
// validatedMeta with usesNewProtocol set to false, and a nil error.
|
||||
// If the request has a protocolVersion in _meta:
|
||||
// - For notifications, it returns usesNewProtocol set to true and a nil initializeParams.
|
||||
// - For call requests, it validates the presence of clientInfo and clientCapabilities in _meta.
|
||||
// If either is missing or invalid, it returns nil and a non-nil error. Otherwise, it returns
|
||||
// usesNewProtocol set to true and the populated initializeParams.
|
||||
// If the request has a protocolVersion in _meta it validates the presence of clientInfo
|
||||
// and clientCapabilities in _meta. If either is missing or invalid, it returns nil and
|
||||
// a non-nil error. Otherwise, it returns usesNewProtocol set to true and the populated
|
||||
// initializeParams.
|
||||
func validateRequestMeta(req *jsonrpc.Request) (*validatedMeta, error) {
|
||||
meta := extractRequestMeta(req.Params)
|
||||
if meta == nil {
|
||||
|
|
@ -529,10 +528,6 @@ func validateRequestMeta(req *jsonrpc.Request) (*validatedMeta, error) {
|
|||
if !ok || protocolVersion < protocolVersion20260728 {
|
||||
return &validatedMeta{usesNewProtocol: false, initializeParams: nil}, nil
|
||||
}
|
||||
// Notifications do not carry full client identity.
|
||||
if !req.IsCall() {
|
||||
return &validatedMeta{usesNewProtocol: true, initializeParams: nil}, nil
|
||||
}
|
||||
clientInfo, ok := decodeMetaValue[*Implementation](meta, MetaKeyClientInfo)
|
||||
if !ok {
|
||||
return nil, &jsonrpc.Error{
|
||||
|
|
|
|||
Loading…
Reference in a new issue