Skip to main content

RequestMetaObject

Struct RequestMetaObject 

Source
pub struct RequestMetaObject {
    pub progress_token: Option<ProgressToken>,
    pub protocol_version: String,
    pub client_info: Option<Implementation>,
    pub client_capabilities: ClientCapabilities,
    pub log_level: Option<LoggingLevel>,
    pub extra: HashMap<String, Value>,
}
Expand description

Core MCP protocol types and error handling Strictly-typed request _meta carrying the per-request capability negotiation. See also MetaObject for key naming rules and reserved prefixes, and General fields: _meta for the full spec section.

Replaces the 2025-11-25 initialize handshake: every 2026-07-28 request’s params._meta is REQUIRED and carries the per-request protocol version, client info, and client capabilities. The server cannot infer these from prior requests in the stateless model (SEP-2567, SEP-2575).

Required fields (schema: not marked ?):

  • io.modelcontextprotocol/protocolVersion: string
  • io.modelcontextprotocol/clientCapabilities: ClientCapabilities

Optional fields:

  • progressToken?: ProgressToken — caller opts in to notifications/progress
  • io.modelcontextprotocol/clientInfo?: Implementation — clients SHOULD send it unless configured otherwise. It is self-reported and unverified: servers MUST NOT key behavior on it and MUST NOT treat it as a security identity. A request that omits it is well-formed and MUST be served.
  • io.modelcontextprotocol/logLevel?: LoggingLevel — replaces the removed logging/setLevel RPC; client opts in to log notifications per-request

Extra keys per MetaObject rules are preserved in Self::extra.

Implementation and ClientCapabilities are imported from crate::initialize.

Serialize is hand-written rather than #[derive] + #[serde(flatten)]: extra is public and caller-writable, so a caller could otherwise insert one of the reserved typed keys (progressToken or any io.modelcontextprotocol/* field) into it and produce the same key twice on the wire. The typed field always wins; a colliding extra entry is dropped rather than emitted. Mirrors the same guard on crate::subscriptions::SubscriptionsListenResultMetaObject.

Fields§

§progress_token: Option<ProgressToken>

Caller-supplied progress token. Optional.

§protocol_version: String

Protocol version this request is encoded against. Required.

For HTTP transport, MUST match the MCP-Protocol-Version header. If unsupported by the server, the server returns McpError::UnsupportedProtocolVersion.

§client_info: Option<Implementation>

Identifies the client. Optional — absent is well-formed. Present but not a valid Implementation is still a parse failure.

§client_capabilities: ClientCapabilities

Client capabilities for this specific request. Required.

Per spec: “Capabilities are declared per-request rather than once at initialization; an empty object means the client supports no optional capabilities. Servers MUST NOT infer capabilities from prior requests.”

§log_level: Option<LoggingLevel>
👎Deprecated since 0.4.0:

Deprecated per SEP-2577 (2026-07-28) along with the whole Logging surface. Earliest removal: first release on/after 2027-07-28.

Per-request log level opt-in. Optional.

Replaces the former logging/setLevel RPC. If absent, the server MUST NOT send notifications/message for this request. Deprecated per SEP-2577 along with the whole Logging surface; functional through the migration window.

§extra: HashMap<String, Value>

Additional caller-supplied meta keys per the MetaObject extension rules.

Implementations§

Source§

impl RequestMetaObject

Source

pub fn new( protocol_version: impl Into<String>, client_info: Implementation, client_capabilities: ClientCapabilities, ) -> RequestMetaObject

Construct with the two required fields plus client_info, which clients SHOULD send. Use Self::without_client_info for the configured-off case. All other optionals start None, extra empty.

Source

pub fn without_client_info(self) -> RequestMetaObject

Drop clientInfo, modelling a client configured not to report itself.

Source

pub fn with_progress_token( self, token: impl Into<ProgressToken>, ) -> RequestMetaObject

Attach a progress token.

Source

pub fn with_log_level(self, level: LoggingLevel) -> RequestMetaObject

👎Deprecated since 0.4.0:

Deprecated per SEP-2577 (2026-07-28) along with the whole Logging surface.

Opt in to log notifications at this level for this request. Deprecated per SEP-2577 along with the whole Logging surface.

Source

pub fn with_extra( self, key: impl Into<String>, value: impl Into<Value>, ) -> RequestMetaObject

Add an extra meta key. Key must follow MetaObject naming rules (no validation performed here; keep keys spec-conformant).

Trait Implementations§

Source§

impl Clone for RequestMetaObject

Source§

fn clone(&self) -> RequestMetaObject

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RequestMetaObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RequestMetaObject

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<RequestMetaObject, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RequestMetaObject

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more