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
|
|
@ -498,6 +498,7 @@ func extractRequestMeta(rawParams json.RawMessage) Meta {
|
|||
type validatedMeta struct {
|
||||
usesNewProtocol bool
|
||||
initializeParams *InitializeParams
|
||||
logLevel LoggingLevel
|
||||
}
|
||||
|
||||
// validateRequestMeta inspects a JSON-RPC request to detect whether it follows
|
||||
|
|
@ -518,8 +519,7 @@ func validateRequestMeta(req *jsonrpc.Request) (*validatedMeta, error) {
|
|||
if !ok {
|
||||
return &validatedMeta{usesNewProtocol: false, initializeParams: nil}, nil
|
||||
}
|
||||
// Notifications do not carry full client identity. In new protocol, only cancel notification
|
||||
// is allowed in STDIO.
|
||||
// Notifications do not carry full client identity.
|
||||
if !req.IsCall() {
|
||||
return &validatedMeta{usesNewProtocol: true, initializeParams: nil}, nil
|
||||
}
|
||||
|
|
@ -537,11 +537,12 @@ func validateRequestMeta(req *jsonrpc.Request) (*validatedMeta, error) {
|
|||
Message: fmt.Sprintf("missing or invalid _meta field %q", MetaKeyClientCapabilities),
|
||||
}
|
||||
}
|
||||
logLevel, _ := decodeMetaValue[LoggingLevel](meta, MetaKeyLogLevel)
|
||||
return &validatedMeta{usesNewProtocol: true, initializeParams: &InitializeParams{
|
||||
ProtocolVersion: protocolVersion,
|
||||
Capabilities: capabilities,
|
||||
ClientInfo: clientInfo,
|
||||
}}, nil
|
||||
}, logLevel: logLevel}, nil
|
||||
}
|
||||
|
||||
// A Request is a method request with parameters and additional information, such as the session.
|
||||
|
|
|
|||
Loading…
Reference in a new issue