Skip to main content

Method

Enum Method 

Source
pub enum Method {
Show 13 variants ToolsCall, ToolsList, ResourcesRead, ResourcesList, ResourcesTemplatesList, PromptsGet, PromptsList, ServerDiscover, TasksGet, TasksUpdate, TasksCancel, SubscriptionsListen, Other(String),
}
Expand description

A method named in the Mcp-Method header.

Other carries anything outside the core protocol so that an unrecognized method is classified conservatively rather than rejected: extensions define their own methods, and a meter that 400s on every extension it has not been taught about is worse than useless in front of a real server.

Variants§

§

ToolsCall

Invoke a server tool.

§

ToolsList

List the tools exposed by the server.

§

ResourcesRead

Read a resource by URI.

§

ResourcesList

List resources exposed by the server.

§

ResourcesTemplatesList

List URI templates exposed by the server.

§

PromptsGet

Render a named prompt.

§

PromptsList

List prompts exposed by the server.

§

ServerDiscover

Discover server capabilities without an initialization handshake.

§

TasksGet

Poll a durable task.

§

TasksUpdate

Supply input requested by a durable task.

§

TasksCancel

Request cancellation of a durable task.

§

SubscriptionsListen

Open the long-lived change-notification stream.

§

Other(String)

An extension method not known to this build.

Implementations§

Source§

impl Method

Source

pub fn parse(raw: &str) -> Method

Parse a Mcp-Method header value.

Header values are case-sensitive (only field names are not), so this does not fold case: Tools/Call is not tools/call, and treating it as such would let a client dodge a per-method price rule by changing capitalization.

Source

pub fn as_str(&self) -> &str

The canonical wire string.

Source

pub const fn carries_name(&self) -> bool

Whether this method carries Mcp-Name (from params.name or params.uri).

The spec requires the header only for tools/call, resources/read, and prompts/get. A meter pricing per tool can therefore only expect a name on these three, and must not treat its absence elsewhere as malformed.

Source

pub const fn supports_mrtr(&self) -> bool

Whether the server is permitted to answer with an InputRequiredResult.

The spec is exhaustive and closed here: servers MAY return one on prompts/get, resources/read, and tools/call, and “MUST NOT send InputRequiredResult responses on any other client requests.”

This is what bounds the body peek. Only these three can be a continuation, so only these three ever need their body inspected, and the other nine method values are decided from the header alone.

Source

pub const fn is_cacheable(&self) -> bool

Whether results for this method carry caching hints (ttlMs, cacheScope).

Note that resources/read appears in both this set and Self::supports_mrtr. That overlap is exactly where the “MRTR results MUST NOT be cached” rule bites, and it is the reason the cache and the meter share one body peek.

Source

pub const fn is_discovery(&self) -> bool

Discovery traffic: the client finding out what the server offers.

Never billable. It is overhead the protocol imposes on the client, it is cacheable so it stops reaching the origin, and charging for it would price the act of connecting.

Source

pub const fn is_task_drive(&self) -> bool

Task lifecycle driving: polling, supplying input, cancelling.

Never billable on its own. The work was commissioned by the originating tools/call; these are the client asking whether it is done yet. A meter that counts requests charges a 10-minute job polled every 2s roughly 300 times for one unit of delivered work.

Source

pub const fn delivers_priced_work(&self) -> bool

Whether this method can deliver work that is worth charging for.

Three methods do. Everything else is lifecycle (initialize, ping), discovery, task plumbing, or a vendor extension, and none of those deliver a priced result no matter what they answer with.

Deliberately its own predicate rather than a reuse of Self::carries_name, which happens to match the same three today: they answer different questions, and a future method that carries a name without delivering priced work must not silently start billing.

Trait Implementations§

Source§

impl Clone for Method

Source§

fn clone(&self) -> Method

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 Method

Source§

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

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

impl Display for Method

Source§

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

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

impl Eq for Method

Source§

impl Hash for Method

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Method

Source§

fn eq(&self, other: &Method) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Method

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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