pub fn read_offer(params: &JsonObject) -> Result<Offer, InitializeError>Expand description
Reads an initialize request body.
§Errors
InitializeError::Malformed when the body is not an object, when
protocolVersion is absent, is not a string, or does not parse as a
protocol version; when capabilities is absent or is not an object; or
when clientInfo is absent, is not an object, or has no name.
clientInfo.version is the one required field not enforced. It is
free-form, nothing in this crate’s answer depends on it, and refusing a
handshake over a missing version string would buy a stricter reading of one
schema at the cost of every client that omits it.
§Examples
use protocol_droid::application::mcp::initialize::read_offer;
use protocol_droid::domain::ir::JsonObject;
let params = JsonObject::new(
r#"{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe"}}"#,
)?;
let offer = read_offer(¶ms)?;
assert_eq!(offer.name, "probe");