Skip to main content

ClientCapabilities

Struct ClientCapabilities 

Source
#[non_exhaustive]
pub struct ClientCapabilities { pub sampling: Option<SamplingCapabilities>, pub elicitation: Option<ElicitationCapabilities>, pub roots: Option<RootsCapabilities>, pub tasks: Option<ClientTasksCapability>, pub experimental: Option<HashMap<String, Value>>, pub extensions: Option<HashMap<String, Value>>, }
Expand description

Client capabilities advertised during initialization.

§Examples

use pmcp::types::ClientCapabilities;

let mut capabilities = ClientCapabilities::default();
capabilities.experimental = Some([("custom-feature".to_string(), serde_json::json!(true))]
    .into_iter()
    .collect());

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§sampling: Option<SamplingCapabilities>

Sampling capabilities (for LLM providers)

§elicitation: Option<ElicitationCapabilities>

Elicitation capabilities (for user input)

§roots: Option<RootsCapabilities>

Roots capabilities

§tasks: Option<ClientTasksCapability>

Task capabilities (MCP 2025-11-25)

§experimental: Option<HashMap<String, Value>>

Experimental capabilities

§extensions: Option<HashMap<String, Value>>

Extension capabilities — reverse-domain-keyed protocol extensions.

This is the wire-correct home for declarations from the Extensions Track of MCP (SEPs that ship as extensions rather than as core protocol changes), and is the client-side twin of ServerCapabilities::extensions.

Use experimental only for pre-SEP, pre-namespaced flags. New extensions belong here.

§On MCP 2026-07-28 this travels PER REQUEST, not in a handshake

MCP 2026-07-28 is stateless and has no initialize handshake, so a v2 client’s declaration rides inside every request’s _meta["io.modelcontextprotocol/clientCapabilities"] rather than being exchanged once at connection setup. This field is therefore both:

  • the typed source that a client’s per-request _meta emission serializes FROM, and
  • the type that the server’s already-resolved ProtocolContext::client_capabilities (resolved once at ingress) deserializes INTO.

On MCP 2025-11-25 the same field travels once, inside the initialize request’s capabilities.

§This is a DECLARATION, never an authorization

The map is client-supplied, self-reported and trivially forgeable. It says only what the client SUPPORTS — never who the caller IS. It may be read to decide whether a capability may be served; it must never be read as identity. Owner binding and every access decision read the authenticated context (OAuth sub / the resolved principal), never this map.

§Examples

use pmcp::types::ClientCapabilities;
use std::collections::HashMap;

let mut caps = ClientCapabilities::default();
let mut ext = HashMap::new();
ext.insert(
    "io.modelcontextprotocol/tasks".to_string(),
    serde_json::json!({}),
);
caps.extensions = Some(ext);

Implementations§

Source§

impl ClientCapabilities

Source

pub fn minimal() -> Self

Create a minimal set of client capabilities.

§Examples
use pmcp::ClientCapabilities;

// Create minimal capabilities (no features advertised)
let capabilities = ClientCapabilities::minimal();
assert!(!capabilities.supports_sampling());
assert!(!capabilities.supports_elicitation());

// Use in client initialization
let transport = StdioTransport::new();
let mut client = Client::new(transport);
let server_info = client.initialize(ClientCapabilities::minimal()).await?;
Source

pub fn full() -> Self

Create a full set of client capabilities.

Advertises all standard client capabilities defined in the MCP specification. Note: Client capabilities indicate what the CLIENT can do (e.g., handle sampling requests, provide user input). Server capabilities (tools, prompts, resources) are advertised by servers, not clients.

§Examples
use pmcp::ClientCapabilities;

// Create full capabilities (all client features supported)
let capabilities = ClientCapabilities::full();
assert!(capabilities.supports_sampling());
assert!(capabilities.supports_elicitation());

// Inspect specific capabilities
assert!(capabilities.roots.unwrap().list_changed);

// Use in client that supports all MCP client features
let transport = StdioTransport::new();
let mut client = Client::new(transport);
let server_info = client.initialize(ClientCapabilities::full()).await?;
Source

pub fn supports_elicitation(&self) -> bool

Check if the client supports elicitation (user input requests).

§Examples
use pmcp::{ClientCapabilities, types::capabilities::ElicitationCapabilities};

// Check elicitation support
let caps = ClientCapabilities::full();
assert!(caps.supports_elicitation());

// Build capabilities with elicitation
let mut interactive_client = ClientCapabilities::default();
interactive_client.elicitation = Some(ElicitationCapabilities::default());
assert!(interactive_client.supports_elicitation());

// Use for interactive tools
let caps = ClientCapabilities::full();
if caps.supports_elicitation() {
    println!("Client can handle user input requests");
}
Source

pub fn supports_sampling(&self) -> bool

Check if the client supports sampling.

§Examples
use pmcp::{ClientCapabilities, types::capabilities::SamplingCapabilities};

// Check sampling support for LLM operations
let caps = ClientCapabilities::full();
assert!(caps.supports_sampling());

// Build LLM client capabilities
let mut llm_client = ClientCapabilities::default();
llm_client.sampling = Some(SamplingCapabilities {
    models: Some(vec![
        "gpt-4".to_string(),
        "claude-3".to_string(),
        "llama-2".to_string(),
    ]),
    ..SamplingCapabilities::default()
});
assert!(llm_client.supports_sampling());

// List supported models
if let Some(sampling) = &llm_client.sampling {
    if let Some(models) = &sampling.models {
        println!("Supported models: {:?}", models);
    }
}

Trait Implementations§

Source§

impl Clone for ClientCapabilities

Source§

fn clone(&self) -> Self

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 ClientCapabilities

Source§

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

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

impl Default for ClientCapabilities

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ClientCapabilities

Source§

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

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

impl Serialize for ClientCapabilities

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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