Expand description
MCP wire types — the Model Context Protocol message surface, shared by the client and the served-MCP side.
Method/notification names are constants (typos become compile errors).
Result/param structs use camelCase to match the spec. content[] and
resource contents[] are kept as Vec<Value> with text-extraction helpers
rather than a brittle tagged enum, so an unknown content type from a newer
server is preserved, not a parse error (forward-compat).
The protocol version + era model lives in crate::version; it is re-exported
here so mcp::wire::{PROTOCOL_VERSION, negotiate_version, …} resolves.
Re-exports§
pub use crate::version::*;
Modules§
- method
- Method + notification names. Constants, so a typo is a compile error rather
than a
-32601at runtime.
Structs§
- Call
Tool Params - Call
Tool Result - Result of
tools/call.is_error: trueis a tool-domain failure (fed to the model as an observation so it can adapt), distinct from a JSON-RPC transport error, which fails the call outright. - Client
Capabilities - Capabilities a client declares. Only declare what the client can actually service: a server is entitled to call anything advertised here, and a declared-but-unanswerable capability strands it waiting on a reply.
- Complete
Params completion/completeparams: what to complete (arefto a prompt or resource template) and the argument being typed. Kept asValue— therefshape varies by target and revision (forward-compat).- Complete
Result - Completion
- Discover
Result - Result of
server/discover(modern era): the server’s supported protocol versions, capabilities, and identity in a single call — the stateless replacement for the legacyinitializecapability exchange.resultTypeand the caching fields (ttlMs/cacheScope) are carried for forward-compat. - GetPrompt
Params prompts/getparams — the template name + its argument fills (all strings).- GetPrompt
Result prompts/getresult — the rendered messages.messages[]is kept asVec<Value>(each{role, content}) for forward-compat with content types.- Implementation
- Initialize
Params - Initialize
Result - List
Prompts Result - List
Resource Templates Result - List
Resources Result - List
Tools Result - Prompt
- A prompt template a server offers via
prompts/list.argumentsdescribe the template’s fill-ins. - Prompt
Argument - Read
Resource Params - Read
Resource Result - Resource
- Resource
Template - A resource template (a parameterized
uriTemplate, RFC 6570) a server offers viaresources/templates/list— distinct from a concreteResource. - Resource
Updated Params - Payload of
notifications/resources/updated— URI only, never a diff. The notification is a wake-up, not the data: the reader re-reads the URI on wake, so a burst of updates collapses into one read of the current state and a missed notification costs freshness, not correctness. - Resources
Capability - Server
Capabilities - What a server says it can do. Every call is gated on these, and the gate is
fail-closed — an absent capability is a refusal, not a maybe: no
tools/callunlesstoolsis present; noresources/subscribeunlessresources.subscribe == Some(true). - Subscribe
Params resources/subscribe/resources/unsubscribeparams. Per-URI only: a subscription names one concrete resource, never aResourceTemplate, since a template matches an open-ended set with no item to watch.- Task
- A durable async-task handle (the tasks extension). A supported request (e.g.
tools/call) may return one (resultType: "task") instead of blocking; the client pollsmethod::TASKS_GETuntil a terminalstatus. - Tool
- Tools
Capability
Constants§
- TASKS_
EXTENSION - The tasks extension identifier — advertised in
capabilities.extensionsto opt into task-augmented (async long-running) requests.
Functions§
- as_
task_ result - If a result value is a task handle (
resultType: "task"), parse it — the polymorphic shape a task-augmented request returns instead of its normal result.