pub struct RequestMeta {
pub version: ProtocolVersion,
pub capabilities: CapabilitySet,
pub client_name: Option<String>,
pub log_level: Option<LogLevel>,
}Expand description
What one request said about itself.
capabilities and version are not optional because the schema does not
make them so: both are in RequestMetaObject’s required. A request that
omits either is refused by RequestMeta::read rather than served with a
default, because a default here would be the server inventing a
capability the client never claimed.
Fields§
§version: ProtocolVersionThe revision this request is written against.
capabilities: CapabilitySetWhat the client supports, read through the shared capability tables.
client_name: Option<String>The client’s self-reported name, when it sent one.
A SHOULD in the SEP and self-reported by the definition: nothing in this crate’s answers depends on it, and a server that trusted it would be trusting a string the schema calls unverified.
log_level: Option<LogLevel>The level this request opted in to log records at, or None for none.
Implementations§
Source§impl RequestMeta
impl RequestMeta
Sourcepub fn read(params: &JsonObject) -> Result<Self, RequestMetaError>
pub fn read(params: &JsonObject) -> Result<Self, RequestMetaError>
Reads the block off a request’s params.
§Errors
RequestMetaError for each of the faults above, distinguished as
documented on the type.
§Examples
use protocol_droid::application::mcp::request_meta::{RequestMeta, RequestMetaError};
use protocol_droid::domain::ir::JsonObject;
use protocol_droid::domain::{Capability, ProtocolVersion};
// One line, because the keys are long and rustfmt would otherwise
// break the literal across lines — and `JsonObject` validates on
// construction, so a newline inside the JSON is a parse error.
let params = JsonObject::new(
r#"{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{"roots":{}},"io.modelcontextprotocol/clientInfo":{"name":"probe","version":"1"}}}"#,
)?;
let meta = RequestMeta::read(¶ms)?;
assert_eq!(meta.version, ProtocolVersion::V2026_07_28);
assert!(meta.capabilities.contains(Capability::Roots));
assert_eq!(meta.client_name.as_deref(), Some("probe"));
// A request with no `_meta` is an older revision, not a fault.
let older = JsonObject::new(r#"{"method":"tools/list"}"#)?;
assert_eq!(RequestMeta::read(&older).err(), Some(RequestMetaError::Absent));