mcp: add support for logging level (SEP-2575) (#997)
## Description This PR adds the support for logging feature in meta. Fixes #966
This commit is contained in:
parent
d9714c61f1
commit
00d3642840
1 changed files with 67 additions and 10 deletions
|
|
@ -21,6 +21,7 @@ func TestValidateRequestMeta(t *testing.T) {
|
|||
isNotification bool
|
||||
params any
|
||||
wantUsesNew bool
|
||||
wantLogLevel LoggingLevel
|
||||
wantErrContains string
|
||||
}{
|
||||
{
|
||||
|
|
@ -101,6 +102,35 @@ func TestValidateRequestMeta(t *testing.T) {
|
|||
params: json.RawMessage(`{"_meta": "not an object", "name": "x"}`),
|
||||
wantUsesNew: false,
|
||||
},
|
||||
{
|
||||
name: "new protocol with logLevel",
|
||||
method: methodCallTool,
|
||||
params: map[string]any{
|
||||
"_meta": map[string]any{
|
||||
MetaKeyProtocolVersion: protocolVersion20260630,
|
||||
MetaKeyClientInfo: map[string]any{"name": "c", "version": "1"},
|
||||
MetaKeyClientCapabilities: map[string]any{},
|
||||
MetaKeyLogLevel: "warning",
|
||||
},
|
||||
"name": "x",
|
||||
},
|
||||
wantUsesNew: true,
|
||||
wantLogLevel: "warning",
|
||||
},
|
||||
{
|
||||
name: "new protocol without logLevel",
|
||||
method: methodCallTool,
|
||||
params: map[string]any{
|
||||
"_meta": map[string]any{
|
||||
MetaKeyProtocolVersion: protocolVersion20260630,
|
||||
MetaKeyClientInfo: map[string]any{"name": "c", "version": "1"},
|
||||
MetaKeyClientCapabilities: map[string]any{},
|
||||
},
|
||||
"name": "x",
|
||||
},
|
||||
wantUsesNew: true,
|
||||
wantLogLevel: "",
|
||||
},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
|
@ -127,6 +157,9 @@ func TestValidateRequestMeta(t *testing.T) {
|
|||
if usesNew != tc.wantUsesNew {
|
||||
t.Errorf("usesNewProtocol = %v, want %v", usesNew, tc.wantUsesNew)
|
||||
}
|
||||
if vmeta != nil && vmeta.logLevel != tc.wantLogLevel {
|
||||
t.Errorf("logLevel = %q, want %q", vmeta.logLevel, tc.wantLogLevel)
|
||||
}
|
||||
if tc.wantErrContains == "" {
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue