README

colmugx/mcp/protocol/types does not have a README file

#
MCPError

pub(all) suberror MCPError {
ParseError(String)
InvalidRequest(String)
MethodNotFound(String)
InvalidParams(String)
InternalError(String)
TransportError(TransportError)
ToolError(String)
HeaderMismatch(String)
MissingRequiredClientCapability(String, required~ : Array[String])
UnsupportedProtocolVersion(String, supported~ : Array[String], requested~ : String)
} derive(Eq,
Debug
)

MCP protocol-level errors These follow the JSON-RPC 2.0 error code conventions.

Error code allocation (per 2026-07-28 spec):
  • -32700, -32600..-32603: standard JSON-RPC 2.0
  • -32000..-32019: legacy/implementation-defined (no new allocations)
  • -32020..-32099: reserved for the MCP specification

#
MCPError::message

fn MCPError::message(self : MCPError) -> String

Get error message from MCPError

#
MCPError::to_error_code

fn MCPError::to_error_code(self : MCPError) -> Int

Convert MCPError to JSON-RPC error code

#
MCPError::to_error_data

fn MCPError::to_error_data(self : MCPError) -> Json?

Serialize the structured data member of a JSON-RPC error response. Returns None for errors that carry no data per the spec. The -3202x MCP-spec-defined errors populate data with fields clients use for recovery (e.g. supported versions to retry with).

#
TransportError

pub(all) suberror TransportError {
ConnectionClosed
ReadError(String)
WriteError(String)
Timeout
InvalidState(String)
Unauthorized(String)
Forbidden(String)
HttpError(Int, String)
} derive(Eq,
Debug
)

Transport-level errors These occur at the communication layer (network, IO, etc.)

#
CancelledNotification

pub(all) struct CancelledNotification {
request_id : RequestId
reason : String?
} derive(Eq,
Debug
)

CancelledNotification — params for notifications/cancelled

#
ClientCapabilities

pub(all) struct ClientCapabilities {
roots : RootCapabilities?
sampling : SamplingCapabilities?
elicitation : ElicitationCapabilities?
extensions : Map[String, Json]?
} derive(Eq,
Debug
)

Client Capabilities — declared during initialization

#
ClientInfo

pub(all) struct ClientInfo {
name : String
title : String?
version : String
} derive(Eq,
Debug
)

Client Info — sent during initialization

#
ContentItem

pub(all) enum ContentItem {
Text(String)
Image(String, mime_type~ : String)
ResourceLink(String)
EmbeddedResource(EmbeddedResourceContent)
} derive(Eq,
Debug
)

Content item for MCP tool results

#
CreateMessageRequest

pub(all) struct CreateMessageRequest {
messages : Array[SamplingMessage]
max_tokens : Int
system_prompt : String?
include_context : String?
temperature : Double?
stop_sequences : Array[String]?
metadata : Json?
} derive(Eq,
Debug
)

CreateMessageRequest — server asks client to sample an LLM

#
CreateMessageResult

pub(all) struct CreateMessageResult {
role : String
model : String
content : ContentItem
stop_reason : String?
} derive(Eq,
Debug
)

CreateMessageResult — client's response to a sampling request

#
ElicitationCapabilities

pub(all) struct ElicitationCapabilities {
form : Bool
} derive(Eq,
Debug
)

Elicitation Capabilities — client supports user interaction requests

#
ElicitationRequest

pub(all) struct ElicitationRequest {
message : String
requested_schema : Json
} derive(Eq,
Debug
)

ElicitationRequest — server asks client to interact with the user

#
ElicitationResult

pub(all) struct ElicitationResult {
action : String
content : Json?
} derive(Eq,
Debug
)

ElicitationResult — client's response to an elicitation request

#
EmbeddedResourceContent

pub(all) enum EmbeddedResourceContent {
Text(String, uri~ : String, mime_type~ : String?)
Blob(String, uri~ : String, mime_type~ : String)
} derive(Eq,
Debug
)

#
GetPromptResult

pub(all) struct GetPromptResult {
description : String?
messages : Array[PromptMessage]
} derive(Eq,
Debug
)

#
InputRequestEntry

pub(all) struct InputRequestEntry {
method_name : InputRequestKind
params : Json
} derive(Eq,
Debug
)

One entry in an inputRequests map: a server-assigned key plus the request method and params the client must fulfill.

#
InputRequestKind

pub(all) enum InputRequestKind {
ElicitationCreate
SamplingCreateMessage
RootsList
} derive(Eq,
Debug
)

The three server→client input request methods. Servers MUST NOT send an input request the client did not declare support for in its capabilities.

#
InputRequestKind::to_method

fn InputRequestKind::to_method(self : InputRequestKind) -> String

Convert an InputRequestKind to its JSON-RPC method string.

#
JsonRpcError

pub(all) struct JsonRpcError {
code : Int
message : String
data : Json?
} derive(Eq,
Debug
)

#
JsonRpcRequest

pub(all) struct JsonRpcRequest {
jsonrpc : String
id : RequestId
method_name : String
params : Json
} derive(Eq,
Debug
)

#
JsonRpcRequest::from_json

fn JsonRpcRequest::from_json(json : Json) -> Result[JsonRpcRequest, MCPError]

#
JsonRpcResponse

pub(all) struct JsonRpcResponse {
jsonrpc : String
id : RequestId
result : Result[Json, JsonRpcError]
} derive(Eq,
Debug
)

#
Notification

pub(all) struct Notification {
method_name : String
params : Json?
} derive(Eq,
Debug
)

Server notification sent to clients Follows MCP spec notification format

#
Notification::to_jsonrpc_string

fn Notification::to_jsonrpc_string(self : Notification) -> String

Serialize notification to JSON-RPC string

#
NotificationCapabilities

pub(all) struct NotificationCapabilities {
tools_list_changed : Bool
resources_list_changed : Bool
resources_updated : Bool
prompts_list_changed : Bool
} derive(Eq,
Debug
)

Server notification capabilities

#
ProgressNotification

pub(all) struct ProgressNotification {
progress_token : String
progress : Double
total : Double?
message : String?
} derive(Eq,
Debug
)

ProgressNotification — params for notifications/progress

#
Prompt

pub(all) struct Prompt {
name : String
description : String?
arguments : Array[PromptArgument]?
} derive(Eq,
Debug
)

#
PromptArgument

pub(all) struct PromptArgument {
name : String
description : String?
required : Bool?
} derive(Eq,
Debug
)

#
PromptCapabilities

pub(all) struct PromptCapabilities {
list_changed : Bool
} derive(Eq,
Debug
)

#
PromptMessage

pub(all) struct PromptMessage {
role : String
content : ContentItem
} derive(Eq,
Debug
)

#
RequestId

pub(all) enum RequestId {
Int(Int)
Str(String)
} derive(Eq,
Debug
)

Request ID supporting both Int and String per JSON-RPC 2.0 / MCP spec

#
RequestId::to_json_string

fn RequestId::to_json_string(self : RequestId) -> String

Convert RequestId to its JSON string representation

#
ResourceCapabilities

pub(all) struct ResourceCapabilities {
subscribe : Bool
list_changed : Bool
} derive(Eq,
Debug
)

#
ResourceUpdatedNotification

pub(all) struct ResourceUpdatedNotification {
uri : String
} derive(Eq,
Debug
)

ResourceUpdatedNotification — params for notifications/resources/updated

#
Root

pub(all) struct Root {
uri : String
name : String?
} derive(Eq,
Debug
)

Root — a filesystem root exposed by the client for roots/list

#
RootCapabilities

pub(all) struct RootCapabilities {
list_changed : Bool
} derive(Eq,
Debug
)

Root Capabilities — client can provide filesystem roots

#
SamplingCapabilities

pub(all) struct SamplingCapabilities {
} derive(Eq,
Debug
)

Sampling Capabilities — client supports LLM sampling requests

#
SamplingMessage

pub(all) struct SamplingMessage {
role : String
content : ContentItem
} derive(Eq,
Debug
)

SamplingMessage — a message within a sampling/createMessage request

#
ServerCapabilities

pub(all) struct ServerCapabilities {
tools : ToolCapabilities?
resources : ResourceCapabilities?
prompts : PromptCapabilities?
extensions : Map[String, Json]?
} derive(Eq,
Debug
)

#
ServerInfo

pub(all) struct ServerInfo {
name : String
title : String?
version : String
description : String?
} derive(Eq,
Debug
)

#
SubscriptionNotificationKind

pub(all) enum SubscriptionNotificationKind {
ToolsListChanged
PromptsListChanged
ResourcesListChanged
ResourceUpdated(uri~ : String)
} derive(Eq,
Debug
)

Which kind of change notification a subscription filter should match. Used internally by the server to route notifications to the right streams.

#
ToolCapabilities

pub(all) struct ToolCapabilities {
list_changed : Bool
} derive(Eq,
Debug
)

#
ToolDefinition

pub(all) struct ToolDefinition {
name : String
description : String
input_schema : Json
cached_schema_json : String
icon : String?
} derive(Eq,
Debug
)

#
ProtocolVersion

let ProtocolVersion : String

MCP protocol version implemented by this SDK.

Single source of truth for the MCP-Protocol-Version header and the _meta.io.modelcontextprotocol/protocolVersion field. Per the 2026-07-28 revision, every request carries its own version; there is no handshake.

#
cancelled_notification

fn cancelled_notification(request_id : String, reason? : String) -> Notification

Create cancelled notification

#
progress_notification

fn progress_notification(token : String, progress : Double, total? : Double) -> Notification

Create progress notification

#
prompts_list_changed_notification

fn prompts_list_changed_notification() -> Notification

Create prompts list changed notification

#
resources_list_changed_notification

fn resources_list_changed_notification() -> Notification

Create resources list changed notification

#
resources_updated_notification

fn resources_updated_notification(uri : String) -> Notification

Create resources updated notification with URI parameter

#
tools_list_changed_notification

fn tools_list_changed_notification() -> Notification

Create tools list changed notification