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
|
|
@ -18,7 +18,6 @@ func TestValidateRequestMeta(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
method string
|
||||
isNotification bool
|
||||
params any
|
||||
wantUsesNew bool
|
||||
wantLogLevel LoggingLevel
|
||||
|
|
@ -84,18 +83,6 @@ func TestValidateRequestMeta(t *testing.T) {
|
|||
wantUsesNew: false,
|
||||
wantErrContains: MetaKeyClientCapabilities,
|
||||
},
|
||||
{
|
||||
name: "notifications exempt from required fields",
|
||||
method: notificationCancelled,
|
||||
isNotification: true,
|
||||
params: map[string]any{
|
||||
"_meta": map[string]any{
|
||||
MetaKeyProtocolVersion: protocolVersion20260728,
|
||||
},
|
||||
"requestId": "r1",
|
||||
},
|
||||
wantUsesNew: true,
|
||||
},
|
||||
{
|
||||
name: "malformed _meta is ignored",
|
||||
method: methodCallTool,
|
||||
|
|
@ -141,16 +128,11 @@ func TestValidateRequestMeta(t *testing.T) {
|
|||
default:
|
||||
raw = mustMarshal(tc.params)
|
||||
}
|
||||
req := &jsonrpc.Request{Method: tc.method, Params: raw}
|
||||
if !tc.isNotification {
|
||||
req.ID = jsonrpc.ID{}
|
||||
// Give the request an ID by parsing one.
|
||||
id, err := jsonrpc.MakeID("test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req.ID = id
|
||||
id, err := jsonrpc.MakeID("test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req := &jsonrpc.Request{Method: tc.method, Params: raw, ID: id}
|
||||
|
||||
vmeta, err := validateRequestMeta(req)
|
||||
usesNew := vmeta != nil && vmeta.usesNewProtocol
|
||||
|
|
|
|||
Loading…
Reference in a new issue