Sign in

    colmugx/mcp/server does not have a README file

    CancellationToken

    Request-local cooperative cancellation, shared with its transport and task owner.

    CompleteRequestParams

    CompletionArgument

    CompletionContext

    CompletionReference

    CompletionResult

    Complete wire result, including open completion fields and result metadata.

    ContentMetadata

    InputRequestEntry

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

    InputRequestKind

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

    JsonInteger

    A mathematical JSON integer retaining its wire literal, without an Int32 or binary64 limit. Equivalent decimal/exponent spellings have the same key.

    JsonNumber

    Exact JSON numeric identity and wire spelling, including fractional tokens. This is not an arithmetic API; conversion to Double is explicitly lossy.

    MCPError

    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

    ParamDef

    Parameter definition for tool schema

    Principal

    Identity established by a trusted server-side authenticator, never by request metadata.

    ProgressReporter

    Reports progress through the current request's transport; direct dispatch defaults to a no-op.

    RequestCancelled

    RequestContext

    Runtime data stays separate from tool/prompt business arguments, including on MRTR retry.

    RequestId

    Request ID supporting exact JSON integers and strings. Int is a convenience constructor; Number retains arbitrary-size wire integers.

    ResourceContents

    ResourceLinkData

    ResultMetadata

    Shared result fields retain wire presence; extensions are top-level fields.

    ServerCapabilities

    Tool

    Core Tool trait following MCP protocol

    ToolAnnotations

    Advisory hints, not an authorization or safety policy.

    ToolCallOutcome

    Outcome of a tool execution. Per the 2026-07-28 MRTR pattern, a tool may either complete normally (Complete) or request additional client input (InputRequired). On retry, the client resubmits with inputResponses and the echoed requestState; the tool receives responses and restored state through RequestContext, without modifying its business arguments.

    TransportError

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

    RequestStateCodec

    pub trait RequestStateCodec {
    fn seal(Self, RequestStatePayload, now~ : Int) -> String
    fn open(Self, String, RequestStateContext, now~ : Int) -> RequestStatePayload?
    }

    Seals/opens requestState blobs. Implementations MUST be authenticated (AEAD or HMAC) per spec.

    now (unix seconds) is passed in by the caller rather than read from a clock inside the codec: it keeps the codec free of a time-package dependency and makes expiry behavior deterministic in tests.

    ActiveSubscription

    pub(all) struct ActiveSubscription {
    filter : SubscriptionFilter
    reply :
    Queue
    [String]
    subscription_id : String
    cancellation_token :
    CancellationToken

    cancellation_registration :
    CancellationRegistration

    }

    One active subscriptions/listen stream. The server holds these so it can route change notifications to the right client stream. Keyed by the subscription id (the listen request's JSON-RPC id, stringified).

    AesGcmStateCodec

    pub struct AesGcmStateCodec {
    key : Bytes
    }

    AES-256-GCM codec. Holds a 32-byte key only — each seal draws a fresh 12-byte nonce from the OS CSPRNG (@env), so there is no counter state to synchronize across instances and no risk of nonce reuse.

    AesGcmStateCodec::AesGcmStateCodec

    fn AesGcmStateCodec::AesGcmStateCodec() -> AesGcmStateCodec

    Construct a codec by reading 32 bytes of OS entropy via @env. Server startup only. Aborts if the OS entropy source is unavailable.

    AesGcmStateCodec::open

    fn AesGcmStateCodec::open(self : AesGcmStateCodec, blob : String, ctx : RequestStateContext, now~ : Int) -> RequestStatePayload?

    Declare seal/open as explicit methods on AesGcmStateCodec so trait method promotion is not implicitly relied upon (implicit promotion is deprecated).

    AesGcmStateCodec::seal

    fn AesGcmStateCodec::seal(self : AesGcmStateCodec, payload : RequestStatePayload, now~ : Int) -> String

    Declare seal/open as explicit methods on AesGcmStateCodec so trait method promotion is not implicitly relied upon (implicit promotion is deprecated).

    AesGcmStateCodec::with_key

    fn AesGcmStateCodec::with_key(key : Bytes) -> AesGcmStateCodec

    Construct a codec with a caller-supplied 32-byte key (e.g. distributed to all instances sharing MRTR state). Aborts if the key is not 32 bytes.

    MCPServer

    pub struct MCPServer {
    name : String
    version : String
    title : String?
    description : String?
    instructions : String?
    auth_config :
    AuthConfig
    ?
    request_state_codec : AesGcmStateCodec?
    clock : () -> Int
    registry : ToolRegistry
    resource_registry : ResourceRegistry
    prompt_registry : PromptRegistry
    completion_registry : CompletionRegistry?
    tools_enabled : Bool?
    resources_enabled : Bool?
    prompts_enabled : Bool?
    subscriptions : Map[String, ActiveSubscription]
    active_requests : Map[String,
    CancellationToken
    ]
    next_scope_id : Int
    }

    MCPServer::MCPServer

    fn MCPServer::MCPServer(name : String, version : String) -> MCPServer

    MCPServer::capabilities

    Return only capabilities implemented and enabled by this server.

    MCPServer::close_subscription

    async fn MCPServer::close_subscription(self : MCPServer, subscription_id : String, scope? : String) -> Unit

    Gracefully close an active subscriptions/listen stream. Sends an empty complete result carrying io.modelcontextprotocol/subscriptionId and removes the subscription. The caller is responsible for any transport-level stream teardown beyond removing the subscription.

    MCPServer::handle_request

    async fn MCPServer::handle_request(self : MCPServer, request_json : String, principal? :
    Principal
    , cancellation_token? :
    CancellationToken
    , progress_reporter? :
    ProgressReporter
    ) -> String

    MCPServer::notify_prompts_list_changed

    async fn MCPServer::notify_prompts_list_changed(self : MCPServer) -> Unit

    MCPServer::notify_resource_updated

    async fn MCPServer::notify_resource_updated(self : MCPServer, uri : String) -> Unit

    Announce that a specific resource's content changed. Reaches only the subscriptions that listed uri in their resourceSubscriptions filter — this is the 2026-07-28 replacement for the legacy resources/subscribe per-URI push.

    MCPServer::notify_resources_list_changed

    async fn MCPServer::notify_resources_list_changed(self : MCPServer) -> Unit

    MCPServer::notify_tools_list_changed

    async fn MCPServer::notify_tools_list_changed(self : MCPServer) -> Unit

    Public server-side notification triggers. Each routes to matching subscriptions/listen streams.

    MCPServer::prompt_mrtr

    MRTR-aware prompt registration. The handler receives the full get params and may return InputRequired to ask the client for input before completing.

    MCPServer::resource

    fn MCPServer::resource(self : MCPServer, uri : String, name : String, description : String, mime_type : String, handler : async (
    RequestContext
    ) -> Result[
    ResourceReadResult
    ,
    MCPError
    ]) -> MCPServer

    MCPServer::resource_mrtr

    fn MCPServer::resource_mrtr(self : MCPServer, uri : String, name : String, description : String, mime_type : String, handler : async (
    RequestContext
    , Json) -> Result[
    ResourceReadOutcome
    ,
    MCPError
    ]) -> MCPServer

    MRTR-aware resource registration. The handler receives the full read params and may return InputRequired to ask the client for input before completing.

    MCPServer::resource_template

    fn MCPServer::resource_template(self : MCPServer, uri_template~ : String, name~ : String, description? : String, mime_type? : String) -> MCPServer

    Register a resource template for resources/templates/list. Templates are URI patterns the server can read; this call only advertises the template.

    MCPServer::resource_template_definition

    MCPServer::run_http

    async fn MCPServer::run_http(self : MCPServer, port? : Int, path? : String) -> Unit raise
    TransportError

    MCPServer::run_stdio

    MCPServer::tool_definition

    Register the complete wire definition without projecting its schema or metadata.

    MCPServer::with_auth

    MCPServer::with_clock

    fn MCPServer::with_clock(self : MCPServer, clock : () -> Int) -> MCPServer

    Inject a wall-clock source (unix seconds) for MRTR requestState expiry. The default uses the system clock; injection is useful for deterministic tests.

    MCPServer::with_completions

    fn MCPServer::with_completions(self : MCPServer, registry : CompletionRegistry) -> MCPServer

    MCPServer::with_description

    fn MCPServer::with_description(self : MCPServer, description : String) -> MCPServer

    MCPServer::with_instructions

    fn MCPServer::with_instructions(self : MCPServer, instructions : String) -> MCPServer

    MCPServer::with_prompt

    fn[T :
    Prompt
    ] MCPServer::with_prompt(self : MCPServer, prompt : T) -> MCPServer

    MCPServer::with_prompt_mrtr

    fn[T :
    PromptMRTR
    ] MCPServer::with_prompt_mrtr(self : MCPServer, prompt : T) -> MCPServer

    MCPServer::with_prompts

    fn MCPServer::with_prompts(self : MCPServer, enabled? : Bool) -> MCPServer

    Enable an empty prompts registry, or explicitly disable its methods.

    MCPServer::with_request_state_codec

    fn MCPServer::with_request_state_codec(self : MCPServer, codec : AesGcmStateCodec) -> MCPServer

    Enable MRTR (Multi Round-Trip Requests) by supplying a requestState codec. When set, handlers may return input_required results and verify requestState on retry. Without a codec, MRTR is disabled.

    MCPServer::with_resource

    fn[T :
    Resource
    ] MCPServer::with_resource(self : MCPServer, resource : T) -> MCPServer

    MCPServer::with_resource_mrtr

    fn[T :
    ResourceMRTR
    ] MCPServer::with_resource_mrtr(self : MCPServer, resource : T) -> MCPServer

    MCPServer::with_resources

    fn MCPServer::with_resources(self : MCPServer, enabled? : Bool) -> MCPServer

    Enable an empty resources/templates registry, or explicitly disable its methods.

    MCPServer::with_title

    fn MCPServer::with_title(self : MCPServer, title : String) -> MCPServer

    MCPServer::with_tools

    fn MCPServer::with_tools(self : MCPServer, enabled? : Bool) -> MCPServer

    Enable an empty tools registry, or explicitly disable tools even after registration. Without an override, registering a tool enables tools automatically.

    PromptRegistry

    type PromptRegistry

    RequestStateContext

    pub(all) struct RequestStateContext {
    principal : String?
    request_method : String
    params : Json
    }

    Context checked by open, computed from the incoming retry request.

    RequestStatePayload

    pub(all) struct RequestStatePayload {
    principal : String?
    expires_at : Int
    request_method : String
    params_digest : String
    state : Json
    }

    What the server seals into a requestState blob. All fields except state are integrity/replay controls; state is the server's own opaque continuation data (re-derived on retry, never trusted from the client without verification).

    ResourceRegistry

    type ResourceRegistry

    ServerRequest

    pub(all) struct ServerRequest {
    message : String
    reply :
    Queue
    [String]
    }

    SubscriptionFilter

    pub(all) struct SubscriptionFilter {
    tools_list_changed : Bool
    prompts_list_changed : Bool
    resources_list_changed : Bool
    resource_subscriptions : Array[String]
    }

    A subscriptions/listen notification filter (spec basic/patterns/subscriptions#notification-filter). Each field is optional; omitting a field means "not subscribed to that type".

    SubscriptionFilter::empty

    An empty filter (subscribe to nothing) — the default when fields are absent.

    SubscriptionFilter::matches

    Does this filter opt into the given notification kind? A ResourceUpdated(uri) matches only if the subscription listed that URI in its resourceSubscriptions filter.

    ToolRegistry

    type ToolRegistry

    get_number

    fn get_number(json : Json, key : String) -> Result[Double,
    ToolResult
    ]

    Extract number from JSON, returning error ToolResult on failure

    get_optional_number

    fn get_optional_number(json : Json, key : String) -> Result[Double?,
    ToolResult
    ]

    Extract optional number from JSON

    get_optional_string

    fn get_optional_string(json : Json, key : String) -> Result[String?,
    ToolResult
    ]

    Extract optional string from JSON

    get_string

    fn get_string(json : Json, key : String) -> Result[String,
    ToolResult
    ]

    Extract string from JSON, returning error ToolResult on failure