Skip to main content

ListToolsResult

Struct ListToolsResult 

Source
#[non_exhaustive]
pub struct ListToolsResult { pub tools: Vec<ToolInfo>, pub next_cursor: Cursor, pub ttl_ms: Option<u64>, pub cache_scope: Option<CacheScope>, }
Expand description

List tools response.

§Backward Compatibility

This struct is #[non_exhaustive]. Use the constructor to remain forward-compatible:

use pmcp::types::ListToolsResult;

let result = ListToolsResult::new(vec![]);

Within the same crate, struct literal syntax with ..Default::default() also works.

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.
§tools: Vec<ToolInfo>

Available tools

§next_cursor: Cursor

Pagination cursor for next page

§ttl_ms: Option<u64>

How long (in milliseconds) a client MAY cache this response — the 2026-07-28 CacheableResult.ttlMs hint.

u64 is the MEASURED mapping: the vendored artifact declares $defs.CacheableResult.properties.ttlMs as {"type": "integer", "minimum": 0} (asserted by tests/v2_core_schema_facts.rs), so integrality and non-negativity are contract. The one residual is the absent upper bound — JSON Schema integer is unbounded while u64 is not — which at millisecond resolution is roughly 584 million years and is an ACCEPTED risk.

None means the handler expressed no preference; the v2 projection then emits the safe default DEFAULT_TTL_MS (0, “immediately stale”) — D-08.

v2 only. On a 2025-11-25 wire the key is never emitted, and a value set here is actively STRIPPED (D-11).

Why Option when the wire says REQUIRED (D-07). The field is required on the 2026-07-28 projection, but modelling it as Option plus inject-on-v2 fails CLOSED (a missed path merely omits a hint), whereas a non-Option field plus strip-on-v1 fails OPEN (a missed path leaks a v2 key onto the v1 wire).

Not to be confused with TaskV2::ttl_ms, which is a task LIFETIME rather than a cache-freshness hint (D-10).

No builder by design. ListToolsResult is built by the dispatcher from the registered tool set, with no handler seam, so a builder method here would be public API no server author can reach through normal configuration — unlike ListResourcesResult and ReadResourceResult, which a ResourceHandler returns from list and read and which therefore do carry builders. The field stays pub, so a caller constructing the struct directly can still set it.

(ListResourceTemplatesResult carries builders too, but is NOT handler-reachable — see its own note. Two of the six cacheable results are settable through a handler, not three; 115-10 corrected an earlier version of this paragraph that said three.)

Adding this field is additive rather than a major bump because this struct is #[non_exhaustive], so cargo semver-checksconstructible_struct_adds_field does not fire.

§cache_scope: Option<CacheScope>

The intended sharing scope of the cached response — the 2026-07-28 CacheableResult.cacheScope hint.

None means the handler expressed no preference; the v2 projection then emits the safe default CacheScope::Private (D-08). Read CacheScope’s # Security section before setting Public: it authorizes a shared gateway to serve this body across authorization contexts.

v2 only. On a 2025-11-25 wire the key is never emitted, and a value set here is actively STRIPPED (D-11).

Why Option when the wire says REQUIRED (D-07): see ttl_ms.

No builder by design — see ttl_ms. Additive under semver for the same #[non_exhaustive] reason.

Implementations§

Source§

impl ListToolsResult

Source

pub fn new(tools: Vec<ToolInfo>) -> Self

Create a new list tools result.

Source

pub fn with_next_cursor(self, cursor: impl Into<String>) -> Self

Set the pagination cursor for the next page.

Trait Implementations§

Source§

impl Clone for ListToolsResult

Source§

fn clone(&self) -> ListToolsResult

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 ListToolsResult

Source§

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

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

impl Default for ListToolsResult

Source§

fn default() -> ListToolsResult

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

impl<'de> Deserialize<'de> for ListToolsResult

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 ListToolsResult

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 = 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