pub struct ProtocolVersionConfig {
pub preferred: String,
pub supported: Vec<String>,
pub allow_fallback: bool,
}Expand description
Protocol version configuration for MCP version negotiation
§Version Negotiation Behavior
When a client connects, the server negotiates protocol version as follows:
- If client requests a version in
supportedlist → use client’s version - If
allow_fallbackis true and client’s version not supported → offerpreferred - If
allow_fallbackis false → reject connection if versions don’t match
§Examples
use turbomcp_server::ProtocolVersionConfig;
// Default: Latest spec with fallback enabled
let config = ProtocolVersionConfig::default();
// Strict: Only accept latest spec, no fallback
let config = ProtocolVersionConfig::strict("2025-11-25");
// Compatible: Prefer older version for maximum compatibility
let config = ProtocolVersionConfig::compatible();Fields§
§preferred: StringPreferred protocol version (default: “2025-11-25” - latest official spec)
supported: Vec<String>Supported versions in fallback order (first = most preferred) Server will accept any of these versions from clients
allow_fallback: boolAllow fallback negotiation when client requests unsupported version
- true: Offer preferred version as fallback (client can accept or disconnect)
- false: Reject connection immediately if client version not in supported list
Implementations§
Source§impl ProtocolVersionConfig
impl ProtocolVersionConfig
Trait Implementations§
Source§impl Clone for ProtocolVersionConfig
impl Clone for ProtocolVersionConfig
Source§fn clone(&self) -> ProtocolVersionConfig
fn clone(&self) -> ProtocolVersionConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ProtocolVersionConfig
impl Debug for ProtocolVersionConfig
Source§impl Default for ProtocolVersionConfig
impl Default for ProtocolVersionConfig
Source§impl<'de> Deserialize<'de> for ProtocolVersionConfig
impl<'de> Deserialize<'de> for ProtocolVersionConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ProtocolVersionConfig
impl RefUnwindSafe for ProtocolVersionConfig
impl Send for ProtocolVersionConfig
impl Sync for ProtocolVersionConfig
impl Unpin for ProtocolVersionConfig
impl UnwindSafe for ProtocolVersionConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more