Skip to main content

Module wire

Module wire 

Source
Expand description

MCP wire types — the Model Context Protocol message surface. RFC 0004 (client), RFC 0005 (server).

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 (RFC 0004 §wire).

Structs§

CallToolParams
CallToolResult
Result of tools/call. is_error: true is a tool-domain failure (fed to the model as an observation), distinct from a JSON-RPC transport error (RFC 0004 §isError).
ClientCapabilities
Capabilities a client declares. agentd declares none in v1 (no roots / sampling / elicitation / tasks) — RFC 0004 §declare-no-client-caps.
CompleteParams
completion/complete params: what to complete (a ref to a prompt or resource template) and the argument being typed. Kept as Value — the ref shape varies by target and revision (forward-compat).
CompleteResult
Completion
DiscoverResult
Result of server/discover (modern era): the server’s supported protocol versions, capabilities, and identity in a single call — the stateless replacement for the legacy initialize capability exchange. resultType and the caching fields (ttlMs/cacheScope) are carried for forward-compat.
GetPromptParams
prompts/get params — the template name + its argument fills (all strings).
GetPromptResult
prompts/get result — the rendered messages. messages[] is kept as Vec<Value> (each {role, content}) for forward-compat with content types.
Implementation
InitializeParams
InitializeResult
ListPromptsResult
ListResourceTemplatesResult
ListResourcesResult
ListToolsResult
Prompt
A prompt template a server offers (RFC 0004 §prompts). arguments describe the template’s fill-ins.
PromptArgument
ReadResourceParams
ReadResourceResult
Resource
ResourceTemplate
A resource template (a parameterized uriTemplate, RFC 6570) a server offers via resources/templates/list — distinct from a concrete Resource.
ResourceUpdatedParams
Payload of notifications/resources/updatedURI only (no diff). The reactive core re-reads on wake: notify-then-read (RFC 0004 §1.3, RFC 0008).
ResourcesCapability
ServerCapabilities
What a server says it can do. We gate every call on these (RFC 0004 §capability-gating): no tools/call unless tools is present; no resources/subscribe unless resources.subscribe == Some(true).
SubscribeParams
resources/subscribe / resources/unsubscribe params (per-URI only — templates are NOT subscribable, RFC 0004 §item-vs-list).
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 polls method::TASKS_GET until a terminal status.
Tool
ToolsCapability

Constants§

TASKS_EXTENSION
The tasks extension identifier — advertised in capabilities.extensions to 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.