#[non_exhaustive]pub struct LogMessageParams {
pub level: LoggingLevel,
pub logger: Option<String>,
pub message: String,
pub data: Option<Value>,
}Expand description
Log message notification.
§The wire contract pmcp emits
The MCP schema declares LoggingMessageNotificationParams as
{ level, logger?, data } — data is REQUIRED and there is no message
member at all (schema/vendored/core-2026-07-28/schema.ts). This Rust type
is the reverse shape: a required message and an optional data. The two are
reconciled at the EMITTER, not here:
RequestHandlerExtra::log defaults data
to the message string when the caller supplied none, so every frame pmcp
emits carries data, and message rides alongside it as a pmcp extension.
When the caller used
log_with_data, their value is
passed through verbatim.
The reason, so this is not “simplified” back: the official reference client’s
LoggingMessageNotificationParamsSchema uses z.unknown(), which is
non-optional under the bundled zod v4. A frame with no data fails to
parse (invalid_type at params.data: expected nonoptional, received undefined) and the client drops it silently — measured against the pinned
conformance suite, where it cost 2025-11-25:tools-call-with-logging its
score and tripped the suite’s WireSchemaValid check with
LoggingMessageNotification/params: must have required property 'data'.
Keeping message is legal: the schema does not close
additionalProperties, and the reference client strips unknown members rather
than rejecting them. It is also what keeps this a non-breaking fix — removing
message would be a breaking change to a public type, and was rejected in
favour of defaulting data.
Constructing this type directly (rather than through the emitter) does NOT get
the default: new leaves data as None, so a caller building
the params by hand should call with_data.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.level: LoggingLevelLog level
logger: Option<String>Logger name/category
message: StringLog message
data: Option<Value>Additional data
Implementations§
Source§impl LogMessageParams
impl LogMessageParams
Sourcepub fn new(level: LoggingLevel, message: impl Into<String>) -> Self
pub fn new(level: LoggingLevel, message: impl Into<String>) -> Self
Create a log message with level and message.
logger and data default to None.
Sourcepub fn with_logger(self, logger: impl Into<String>) -> Self
pub fn with_logger(self, logger: impl Into<String>) -> Self
Set the logger name/category.