README

colmugx/mcp/client does not have a README file

#
CallToolResult

pub(all) struct CallToolResult {
content : Array[
ContentItem
]
is_error : Bool
} derive(Eq,
Debug
)

#
ClientBackend

pub enum ClientBackend {
Modern
Legacy(
LegacyClient
)
}

Backend selected after era probing. Modern clients speak the stateless 2026-07-28 protocol; Legacy clients wrap the 2025-11-25 session client.

#
CompletionResult

pub(all) struct CompletionResult {
values : Array[String]
total : Int?
has_more : Bool?
} derive(Eq,
Debug
)

#
ListPromptsResult

pub(all) struct ListPromptsResult {
prompts : Array[
PromptDefinition
]
next_cursor : String?
} derive(Eq,
Debug
)

#
ListResourceTemplatesResult

pub(all) struct ListResourceTemplatesResult {
resource_templates : Array[ResourceTemplate]
next_cursor : String?
} derive(Eq,
Debug
)

#
ListResourcesResult

pub(all) struct ListResourcesResult {
resources : Array[
ResourceDefinition
]
next_cursor : String?
} derive(Eq,
Debug
)

#
ListToolsResult

pub(all) struct ListToolsResult {
tools : Array[
ToolDefinition
]
next_cursor : String?
} derive(Eq,
Debug
)

#
ListenFilter

pub(all) struct ListenFilter {
tools_list_changed : Bool
prompts_list_changed : Bool
resources_list_changed : Bool
resource_subscriptions : Array[String]
} derive(Eq,
Debug
)

Filter for a subscriptions/listen request. Controls which server notification channels the client wants multiplexed onto this single long-lived request.

#
ListenFilter::default

fn ListenFilter::default() -> ListenFilter

Default filter: subscribe only to list-change notifications, with no per-resource subscriptions.

#
MCPClient

pub struct MCPClient {
client_name : String
client_version : String
capabilities :
ClientCapabilities

transport :
AnyTransport

id_counter : RequestIdCounter
server_capabilities :
ServerCapabilities
?
server_info :
ServerInfo
?
notification_handlers : NotificationHandlers
subscription_handlers : Map[String, (Json) -> Unit]
sampling_handler : (Json) -> Result[
CreateMessageResult
,
MCPError
]?
roots_handler : () -> Result[Array[
Root
],
MCPError
]?
elicitation_handler : (Json) -> Result[
ElicitationResult
,
MCPError
]?
response_map : Map[Int,
Queue
[String]]
event_loop_started : Bool
legacy_mode : Bool
backend : ClientBackend
}

#
MCPClient::call_tool

async fn MCPClient::call_tool(self : MCPClient, name : String, arguments? : String) -> Result[CallToolResult,
MCPError
]

#
MCPClient::cancel_listen

async fn MCPClient::cancel_listen(self : MCPClient, subscription_id : String) -> Result[Unit,
MCPError
]

Cancel a running subscriptions/listen subscription. For stdio transports this sends a notifications/cancelled notification. HTTP transports do not currently support per-stream cancellation in this SDK, so this returns an error explaining that limitation.

#
MCPClient::cancel_request

async fn MCPClient::cancel_request(self : MCPClient, request_id : String, reason? : String) -> Result[Unit,
MCPError
]

#
MCPClient::close

async fn MCPClient::close(self : MCPClient) -> Unit

#
MCPClient::complete

async fn MCPClient::complete(self : MCPClient, ref_type~ : String, ref_name~ : String, argument_name~ : String, argument_value~ : String) -> Result[CompletionResult,
MCPError
]

#
MCPClient::connect_http

async fn MCPClient::connect_http(url~ : String, name~ : String, version~ : String, auth_token? : String) -> Result[MCPClient,
MCPError
]

#
MCPClient::connect_stdio

async fn MCPClient::connect_stdio(cmd~ : String, args? : Array[String], name~ : String, version~ : String, extra_env? : Map[String, String], group~ :
TaskGroup
[Unit]) -> Result[MCPClient,
MCPError
]

#
MCPClient::discover

Query the server's supported versions, capabilities, and identity via server/discover (required by the 2026-07-28 spec). Stores the results in server_capabilities and server_info for later use. Optional for clients per spec, but recommended — and the primary era probe for legacy fallback.

#
MCPClient::get_prompt

async fn MCPClient::get_prompt(self : MCPClient, name : String, arguments? : String) -> Result[
GetPromptResult
,
MCPError
]

#
MCPClient::list_prompts

async fn MCPClient::list_prompts(self : MCPClient, cursor? : String) -> Result[ListPromptsResult,
MCPError
]

#
MCPClient::list_resource_templates

async fn MCPClient::list_resource_templates(self : MCPClient, cursor? : String) -> Result[ListResourceTemplatesResult,
MCPError
]

#
MCPClient::list_resources

async fn MCPClient::list_resources(self : MCPClient, cursor? : String) -> Result[ListResourcesResult,
MCPError
]

#
MCPClient::list_tools

async fn MCPClient::list_tools(self : MCPClient, cursor? : String) -> Result[ListToolsResult,
MCPError
]

#
MCPClient::listen

fn MCPClient::listen(self : MCPClient, filter? : ListenFilter, handler~ : (Json) -> Unit, group~ :
TaskGroup
[Unit]) -> Result[String,
MCPError
]

Start a subscriptions/listen request. Returns the subscription id string on success. The caller must already have started the event loop via run; otherwise a clear error is returned. Notifications carrying the subscription id in params._meta are routed to handler until the server closes the subscription (the final JSON-RPC response causes a background cleanup task to unregister the handler).

#
MCPClient::next_request_id

fn MCPClient::next_request_id(self : MCPClient) -> Int

#
MCPClient::on_notification

fn MCPClient::on_notification(self : MCPClient, handlers : NotificationHandlers) -> MCPClient

#
MCPClient::read_resource

async fn MCPClient::read_resource(self : MCPClient, uri : String) -> Result[ReadResourceResult,
MCPError
]

#
MCPClient::run

async fn MCPClient::run(self : MCPClient, group :
TaskGroup
[Unit]) -> Unit

#
MCPClient::set_legacy_mode

fn MCPClient::set_legacy_mode(self : MCPClient, enabled : Bool) -> MCPClient

Enable or disable legacy mode. When enabled, the event loop accepts server-initiated requests (2025-11-25 behavior); when disabled (the default), such requests are rejected with -32601 per the 2026-07-28 spec.

#
MCPHost

pub struct MCPHost {
name : String
version : String
connections : Map[String, MCPClient]
}

#
MCPHost::MCPHost

fn MCPHost::MCPHost(name~ : String, version~ : String) -> MCPHost

#
MCPHost::call_tool

async fn MCPHost::call_tool(self : MCPHost, qualified_name : String, arguments? : String) -> Result[CallToolResult,
MCPError
]

#
MCPHost::close_all

async fn MCPHost::close_all(self : MCPHost) -> Unit

#
MCPHost::connect_http

async fn MCPHost::connect_http(self : MCPHost, name~ : String, url~ : String, auth_token? : String) -> Result[Unit,
MCPError
]

#
MCPHost::connect_stdio

async fn MCPHost::connect_stdio(self : MCPHost, name~ : String, cmd~ : String, args? : Array[String], extra_env? : Map[String, String], group~ :
TaskGroup
[Unit]) -> Result[Unit,
MCPError
]

#
MCPHost::list_tools

#
NotificationHandlers

pub(all) struct NotificationHandlers {
on_tools_changed : () -> Unit?
on_resources_changed : () -> Unit?
on_prompts_changed : () -> Unit?
on_progress : (
ProgressNotification
) -> Unit?
on_cancelled : (
CancelledNotification
) -> Unit?
on_resource_updated : (
ResourceUpdatedNotification
) -> Unit?
on_message : (String, Json?) -> Unit?
}

#
NotificationHandlers::empty

#
ReadResourceResult

#
RequestIdCounter

type RequestIdCounter

#
ResourceTemplate

pub(all) struct ResourceTemplate {
uri_template : String
name : String
description : String?
mime_type : String?
} derive(Eq,
Debug
)