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
impl Method
Sourcepub fn parse(raw: &str) -> Self
pub fn parse(raw: &str) -> Self
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.
Sourcepub const fn carries_name(&self) -> bool
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.
Sourcepub const fn supports_mrtr(&self) -> bool
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.
Sourcepub const fn is_cacheable(&self) -> bool
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.
Sourcepub const fn is_discovery(&self) -> bool
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.
Sourcepub const fn is_task_drive(&self) -> bool
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.
Sourcepub const fn delivers_priced_work(&self) -> bool
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.