ciallo-mcp

    Zero-extra-code Model Context Protocol (MCP) Server and LLM Function Calling JSON Schema adapter over unmbt/ciallo routes

    mcp
    ai
    llm
    tool-calling
    json-rpc
    ciallo
    Download zip
    Author
    Version
    0.3.0
    License
    MIT
    Last updated
    5 hours ago
    Downloads
    23

    #unmbt/ciallo-mcp

    Full Model Context Protocol (MCP 2026-07-28 + 2025-11-25 dual-era) Server & LLM Function Calling exporter for unmbt/ciallo.

    Supports both zero-extra-code App wrapping (McpServer::from_app — reusing the 9-stage pipeline, Schema validation, RBAC guards, and RFC 9457 error contracts) and standalone programmatic MCP Servers (McpServer::McpServer).

    #Protocol Coverage (ADR-014, ADR-015 & ADR-016)

    • Dual-Era Lifecycle & Discovery: Full 2026-07-28 stateless server/discover + _meta envelope validation, SEP-2243 standard & Mcp-Param-* headers, SEP-1865 subscriptions/listen, SEP-2106 non-object outputSchema/structuredContent, SEP-2322 InputRequired multi-round-trip + RequestStateCodec (HMAC-SHA256), SEP-2549 CacheHint, plus full 2025-11-25 backwards compatibility (initialize negotiation, bidirectional Server→Client RPC, and transparent legacy input_required shim).
    • Tools: Auto-exported App routes (inferred ToolAnnotations, outputSchema, image/*/audio/* Base64 ContentBlock, SSE/NDJSON notifications/progress, max_response_bytes cap) + programmatic register_tool / set_tool_enabled / remove_tool, overflow-safe pagination, and SEP-986 validate_tool_name.
    • Resources & Templates: Static resources, pure MoonBit RFC 6570 UriTemplate, dynamic list_callback, resources/read, resources/subscribe / unsubscribe, and notify_resource_updated.
    • Prompts, Completions & Logging: prompts/list, prompts/get, completion/complete (100-item cap), RFC-5424 8-level logging, and McpRequestContext::{require_input, list_roots, create_message, elicit_form, elicit_url}.

    #4-Package Layering & Multi-Target Matrix (native / js / wasm / wasm-gc)

    • unmbt/ciallo-mcp/protocol (all 4 targets including wasm-gc, zero core/async, zero ciallo/core/runtime): Pure synchronous protocol DTOs, #non_exhaustive enums/errors, UriTemplate, LLM Schema exporters (export_mcp_tools / export_openai_tools / export_anthropic_tools), RequestStateCodec, SubscriptionFilter, and 2026-07-28 validation / Origin / Host DNS rebinding protection.
    • unmbt/ciallo-mcp (root package, 3 targets -all+native+js+wasm, zero production core/async/aqueue/stdio/signal/ciallo-log deps): McpServer dispatch engine, McpRequestContext, mcp_transport_key, and full pub using re-exports of protocol.
    • unmbt/ciallo-mcp/http (symmetric Streamable HTTP + SSE transport subpackage, 3 targets): @mcp_http.mount_http(server, app, path="/mcp", options?) — real-time concurrent SSE upgrade (deferred response header commit preserving 404/400 status codes), subscriptions/listen SSE streams with : keepalive heartbeats, client-disconnect cancellation, and bounded queues. Pair with @ciallo_native.serve (Native), @ciallo_js.serve (Node.js & Bun), or @ciallo_js.to_fetch_handler (Cloudflare Workers).
    • unmbt/ciallo-mcp/stdio (symmetric Stdio transport subpackage, 3 targets): @mcp_stdio.serve_io & @mcp_stdio.serve_stdio across Native, Wasm (with native core/async/signal), Node.js 18+, and Bun 1.x, featuring 3-stage concurrency, bounded line framing, notifications/cancelled, reliable terminal frame delivery, and ADR-012 signal-safe graceful draining.

    [!CAUTION] MCP Stdio stdout zero-pollution rule: When running an MCP Stdio Server, stdout (fd 1) MUST ONLY emit newline-delimited JSON-RPC 2.0 messages. NEVER mount @ciallo_log.ConsoleSink (which writes via println to stdout); always use @ciallo_log.StderrSink (Logger::stderr()) or @mcp_stdio.McpLogSink.

    CacheHint

    SEP-2549 cache hint (ttlMs and cacheScope) for 2026-07-28 cacheable results.

    CacheScope

    SEP-2549 cache scope for 2026-07-28 cacheable results.

    CallToolResult

    Result of executing a tool (tools/call).

    CompiledXMcpHeaders

    Pre-scanned SEP-2243 x-mcp-header declarations cached once per tool at registration time.

    CompleteContext

    CompleteResult

    ContentBlock

    Multimodal MCP 2025-11-25 ContentBlock union (text, image, audio, resource_link, resource).

    CreateMessageParams

    CreateMessageResult

    ElicitFormParams

    ElicitUrlParams

    GetPromptResult

    HttpResponseMode

    How mount_http shapes HTTP responses for modern (2026-07-28) request exchanges (matches @modelcontextprotocol/server PerRequestResponseMode).

    InputRequest

    Embedded client input request for MCP 2026-07-28 multi-round-trip requests (SEP-2322). Works seamlessly across both eras: emitted as resultType: "input_required" on 2026-07-28, and automatically shimmed over bidirectional Server鈫扖lient JSON-RPC requests on 2025-11-25.

    InputRequired

    Raised by a tools/call, prompts/get, or resources/read handler to pause execution and request client input (SEP-2322 multi-round-trip).

    LegacyHttpMode

    How mount_http handles legacy (pre-2026-07-28, envelope-less) HTTP requests.

    McpAnnotations

    MCP content / resource annotations (audience, priority, lastModified).

    McpEra

    Protocol era: Legacy (2025-11-25 and earlier via initialize) or Modern (2026-07-28 and later via server/discover & per-request _meta envelope).

    McpHttpOptions

    Configuration for McpServer::mount_http (Streamable HTTP + dual-era 2026-07-28/2025-11-25).

    McpImplementation

    Rich MCP server / client Implementation descriptor (2025-11-25).

    McpLogLevel

    RFC-5424 8-level MCP Logging severity.

    McpProtocolError

    Structured MCP JSON-RPC protocol error raised by handlers or client RPCs.

    McpResourceInfo

    Static or listed MCP Resource metadata descriptor.

    McpResourceTemplateInfo

    RFC 6570 Resource Template metadata descriptor.

    McpRoot

    Client filesystem / workspace root returned by roots/list.

    McpTransport

    Identifies the active MCP transport executing a request.

    ModelPreferences

    PromptArgument

    PromptMessage

    ReadResourceResult

    RequestStateCodec

    Opt-in HMAC-SHA256 integrity codec for MCP 2026-07-28 multi-round-trip requestState (exact wire format parity with @modelcontextprotocol/server createRequestStateCodec):

    "v1." b64url({"p":<payload>,"exp":<unixSeconds>,"b":<bindTag>?}) "." b64url(mac)

    where bindTag = b64url(HMAC-SHA256(key, "mcp.requestState.bind:" + bind_value)[:16]). Signed, not encrypted; verification is fail-closed and constant-time.

    RequestStateError

    Opaque error raised by RequestStateCodec::verify (never leaks decoded payload or binding values).

    ResourceContents

    Text or Base64-encoded binary resource contents.

    SamplingMessage

    ServerEvent

    Change event published onto McpServer's internal event bus for subscriptions/listen delivery (SEP-1865).

    SubscriptionFilter

    MCP 2026-07-28 SEP-1865 subscriptions/listen filter and event-bus helpers.

    ToolAnnotations

    MCP 2025-11-25 ToolAnnotations behavioral hints for LLM hosts.

    UriTemplate

    Pure MoonBit RFC 6570 URI Template engine (zero regex, ReDoS-safe). Supports operators "", +, #, ., /, ;, ?, & and explode modifier *.

    McpDispatchResult

    pub struct McpDispatchResult {
    response :
    Json
    ?
    http_status : Int
    protocol_version : String
    era :
    McpEra

    }

    Detailed outcome of dispatching a single MCP JSON-RPC message.

    McpRequestContext

    pub struct McpRequestContext {
    env :
    Env

    exec_ctx :
    ExecutionContext

    headers :
    Headers

    transport :
    McpTransport

    progress_token :
    Json
    ?
    meta : Map[String,
    Json
    ]?
    protocol_version : String
    era :
    McpEra

    client_info :
    Json
    ?
    client_capabilities :
    Json
    ?
    input_responses : Map[String,
    Json
    ]?
    request_state : String?
    // private fields
    }

    Per-request execution context passed to custom Tool, Resource, and Prompt handlers. Supports progress notifications, log notifications, bidirectional server->client RPC, and 2026-07-28 multi-round-trip (input_required / inputResponses / requestState).

    McpRequestContext::create_message

    Request LLM completion from the MCP client (sampling/createMessage).

    McpRequestContext::elicit_form

    Request structured user input via client form UI (elicitation/create mode="form").

    McpRequestContext::elicit_url

    Request out-of-band URL confirmation via client (elicitation/create mode="url").

    McpRequestContext::input_response_elicit

    Reads a form/url elicitation response for key from ctx.input_responses.

    McpRequestContext::input_response_roots

    fn McpRequestContext::input_response_roots(self : McpRequestContext, key : String) -> Array[
    McpRoot
    ]?

    Reads a roots/list response for key from ctx.input_responses.

    McpRequestContext::input_response_sampling

    Reads a sampling/createMessage response for key from ctx.input_responses.

    McpRequestContext::list_roots

    Request filesystem / workspace roots from the MCP client (roots/list).

    McpRequestContext::notify

    fn McpRequestContext::notify(self : McpRequestContext, meth : String, params? :
    Json
    ) -> Unit

    McpRequestContext::require_input

    fn[T] McpRequestContext::require_input(_self : McpRequestContext, input_requests? : Map[String,
    InputRequest
    ], request_state? : String, meta? : Map[String,
    Json
    ]) -> T raise
    InputRequired

    Pause this tools/call, prompts/get, or resources/read handler to request client input (input_required on 2026-07-28; automatically shimmed on 2025-11-25).

    McpRequestContext::send_client_request

    Send a raw server->client JSON-RPC request over a bidirectional transport (2025-11-25). On 2026-07-28, direct server->client requests are removed; use ctx.require_input(...) instead.

    McpRequestContext::send_log

    Emit notifications/message respecting the active log level threshold:
    • On 2026-07-28 (Modern), obeys per-request _meta["io.modelcontextprotocol/logLevel"] (and suppresses log notifications when the client did not opt in per spec).
    • On 2025-11-25 (Legacy), obeys the server's logging/setLevel threshold.

    McpRequestContext::send_progress

    fn McpRequestContext::send_progress(self : McpRequestContext, progress : Double, total? : Double, message? : String) -> Unit

    Emit notifications/progress if the client supplied params._meta.progressToken.

    McpServer

    pub struct McpServer {
    info :
    OpenApiInfo

    protocol_version : String
    tools : Array[
    McpTool
    ]
    tool_index : Map[String,
    McpTool
    ]
    // private fields
    }

    Model Context Protocol (MCP 2025-11-25 & 2026-07-28 dual-era) Server. Supports both standalone registration (McpServer::McpServer) and zero-extra-code wrapping of a @core.App (McpServer::from_app), reusing the full 9-stage pipeline, Schema validation, RBAC guards, and RFC 9457 error contracts.

    McpServer::McpServer

    fn McpServer::McpServer(info~ :
    McpImplementation
    , protocol_version? : String, instructions? : String, max_response_bytes? : Int64, page_size? : Int) -> McpServer

    Creates a standalone MCP Server without wrapping an HTTP @core.App.

    McpServer::app

    McpServer::capabilities_json

    fn McpServer::capabilities_json(self : McpServer) ->
    Json

    Returns the server's advertised capabilities JSON object.

    McpServer::clear_notification_sink

    fn McpServer::clear_notification_sink(self : McpServer) -> Unit

    McpServer::close_subscriptions

    fn McpServer::close_subscriptions(self : McpServer) -> Unit

    Gracefully closes every active HTTP subscriptions/listen SSE stream, emitting the terminal SubscriptionsListenResult frame before closing.

    McpServer::enable_logging

    McpServer::enable_resource_subscriptions

    fn McpServer::enable_resource_subscriptions(self : McpServer) -> McpServer

    McpServer::exclude_path

    fn McpServer::exclude_path(self : McpServer, path : String) -> McpServer

    Removes any exported App tool matching path (used automatically by mount_http to prevent self-recursive MCP endpoint export on custom mount paths).

    McpServer::from_app

    fn McpServer::from_app(app :
    App
    , info~ :
    OpenApiInfo
    , filter? :
    McpFilter
    , protocol_version? : String, instructions? : String, max_response_bytes? : Int64, page_size? : Int) -> McpServer raise
    AppBuildError

    Wraps a @core.App, automatically exporting matching routes as MCP Tools.

    McpServer::handle_jsonrpc

    Handles a single MCP JSON-RPC 2.0 message across both MCP 2025-11-25 and 2026-07-28 eras, returning None for notifications.

    McpServer::handle_jsonrpc_detailed

    Dispatches a single MCP JSON-RPC 2.0 message and returns the JSON-RPC response, spec-mandated HTTP status code, resolved protocol version, and protocol era.

    McpServer::is_subscribed

    fn McpServer::is_subscribed(self : McpServer, uri : String) -> Bool

    McpServer::max_subscriptions

    fn McpServer::max_subscriptions(self : McpServer) -> Int

    Returns the configured maximum number of concurrent subscriptions/listen streams.

    McpServer::min_log_level

    McpServer::negotiated_protocol_version

    fn McpServer::negotiated_protocol_version(self : McpServer) -> String

    McpServer::new_session

    fn McpServer::new_session(self : McpServer) -> McpSessionState

    Creates an isolated per-connection McpSessionState initialized from this server's default protocol version and minimum log level.

    McpServer::notify_resource_updated

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

    Emits notifications/resources/updated to subscribed legacy clients AND publishes ServerEvent::ResourceUpdated(uri) to 2026 subscriptions/listen streams.

    McpServer::on_initialized

    fn McpServer::on_initialized(self : McpServer, cb : () -> Unit) -> McpServer

    McpServer::open_subscription_count

    fn McpServer::open_subscription_count(self : McpServer) -> Int

    Returns the number of currently open HTTP subscriptions/listen streams.

    McpServer::protocol_version

    fn McpServer::protocol_version(self : McpServer) -> String

    Returns the server's configured default protocol revision string.

    McpServer::publish_event

    fn McpServer::publish_event(self : McpServer, event :
    ServerEvent
    ) -> Unit

    Publishes a ServerEvent to all active subscriptions/listen subscribers.

    McpServer::register_prompt

    Registers an MCP Prompt (prompts/list, prompts/get) with optional argument completers.

    McpServer::register_resource

    Registers a static MCP Resource (resources/list, resources/read).

    McpServer::register_resource_template

    Registers an RFC 6570 Resource Template with optional dynamic list_callback and argument completers.

    McpServer::register_session

    fn McpServer::register_session(self : McpServer, session : McpSessionState) -> Int

    Registers an active session so notify_resource_updated and send_log fan out to it according to its isolated subscriptions and log level. Returns an unregister token.

    McpServer::register_tool

    Registers a custom programmatic MCP Tool (overrides an existing custom tool with the same name).

    McpServer::remove_prompt

    fn McpServer::remove_prompt(self : McpServer, name : String) -> Bool

    McpServer::remove_resource

    fn McpServer::remove_resource(self : McpServer, uri : String) -> Bool

    McpServer::remove_resource_template

    fn McpServer::remove_resource_template(self : McpServer, uri_template : String) -> Bool

    McpServer::remove_tool

    fn McpServer::remove_tool(self : McpServer, name : String) -> Bool

    McpServer::send_log

    fn McpServer::send_log(self : McpServer, level :
    McpLogLevel
    , data :
    Json
    , logger? : String) -> Unit

    Emits notifications/message via the active transport notification sink if level >= min_log_level.

    McpServer::set_cache_hint

    fn McpServer::set_cache_hint(self : McpServer, operation : String, hint :
    CacheHint
    ) -> McpServer

    Configures an SEP-2549 cache hint for one of the 6 cacheable 2026-07-28 operations (tools/list, prompts/list, resources/list, resources/templates/list, resources/read, server/discover).

    McpServer::set_experimental_capability

    fn McpServer::set_experimental_capability(self : McpServer, key : String, value :
    Json
    ) -> McpServer

    Advertises an entry under capabilities.experimental.

    McpServer::set_extension_capability

    fn McpServer::set_extension_capability(self : McpServer, key : String, value :
    Json
    ) -> McpServer

    Advertises an entry under capabilities.extensions.

    McpServer::set_max_subscriptions

    fn McpServer::set_max_subscriptions(self : McpServer, max : Int) -> McpServer

    Configures the maximum number of concurrent subscriptions/listen streams (default 1024).

    McpServer::set_notification_sink

    fn McpServer::set_notification_sink(self : McpServer, sink : (
    Json
    ) -> Unit) -> Unit

    McpServer::set_prompt_enabled

    fn McpServer::set_prompt_enabled(self : McpServer, name : String, enabled : Bool) -> Bool

    McpServer::set_request_state_verifier

    fn McpServer::set_request_state_verifier(self : McpServer, verifier : (String, McpRequestContext) -> Bool) -> McpServer

    Registers an optional verifier for echoed 2026-07-28 multi-round-trip params.requestState values (e.g. wrapping RequestStateCodec::verify). When verification returns false, the request is rejected with -32602 Invalid params before entering the handler.

    McpServer::set_resource_cache_hint

    fn McpServer::set_resource_cache_hint(self : McpServer, uri : String, hint :
    CacheHint
    ) -> McpServer

    Configures an SEP-2549 cache hint for a specific resource URI (resources/read), taking precedence over the operation-level resources/read hint.

    McpServer::set_resource_enabled

    fn McpServer::set_resource_enabled(self : McpServer, uri : String, enabled : Bool) -> Bool

    McpServer::set_resource_template_enabled

    fn McpServer::set_resource_template_enabled(self : McpServer, uri_template : String, enabled : Bool) -> Bool

    McpServer::set_tool_enabled

    fn McpServer::set_tool_enabled(self : McpServer, name : String, enabled : Bool) -> Bool

    McpServer::set_validate_tool_inputs

    fn McpServer::set_validate_tool_inputs(self : McpServer, enabled : Bool) -> McpServer

    Enables or disables runtime JSON Schema validation for programmatic register_tool arguments (enabled by default).

    McpServer::set_validate_tool_outputs

    fn McpServer::set_validate_tool_outputs(self : McpServer, enabled : Bool) -> McpServer

    Enables or disables runtime JSON Schema validation of structuredContent against outputSchema (enabled by default).

    McpServer::subscribe_events

    fn McpServer::subscribe_events(self : McpServer, listener : (
    ServerEvent
    ) -> Unit) -> Int

    Registers an internal event-bus listener (used by subscriptions/listen routers). Returns an integer subscription token that can be passed to unsubscribe_events.

    McpServer::tool_compiled_x_mcp_headers

    fn McpServer::tool_compiled_x_mcp_headers(self : McpServer, name : String) ->
    CompiledXMcpHeaders
    ?

    Returns the pre-scanned CompiledXMcpHeaders of an active registered tool in O(1), avoiding per-request JSON Schema traversal during POST /mcp tools/call.

    McpServer::tool_input_schema_json

    fn McpServer::tool_input_schema_json(self : McpServer, name : String) ->
    Json
    ?

    Returns the JSON inputSchema of a registered tool by name (custom tools take precedence).

    McpServer::try_register_subscription_closer

    fn McpServer::try_register_subscription_closer(self : McpServer, key : Int, closer : () -> Unit) -> Bool

    Registers a transport subscription closer up to max_subscriptions. Returns false if the subscription capacity limit has been reached.

    McpServer::unregister_session

    fn McpServer::unregister_session(self : McpServer, token : Int) -> Unit

    Unregisters a previously registered session token.

    McpServer::unregister_subscription_closer

    fn McpServer::unregister_subscription_closer(self : McpServer, key : Int) -> Unit

    Unregisters a transport subscription closer by key.

    McpServer::unsubscribe_events

    fn McpServer::unsubscribe_events(self : McpServer, id : Int) -> Unit

    Removes a previously registered event-bus listener.

    McpSessionState

    pub struct McpSessionState {
    // private fields
    }

    Per-connection / per-session mutable state for McpServer (isolating concurrent Stdio and Streamable HTTP sessions from mutating shared server state).

    McpSessionState::McpSessionState

    fn McpSessionState::McpSessionState(protocol_version? : String, min_log_level? :
    McpLogLevel
    , notification_sink? : (
    Json
    ) -> Unit) -> McpSessionState

    McpSessionState::clear_notification_sink

    fn McpSessionState::clear_notification_sink(self : McpSessionState) -> Unit

    McpSessionState::is_subscribed

    fn McpSessionState::is_subscribed(self : McpSessionState, uri : String) -> Bool

    McpSessionState::min_log_level

    McpSessionState::negotiated_protocol_version

    fn McpSessionState::negotiated_protocol_version(self : McpSessionState) -> String

    McpSessionState::set_notification_sink

    fn McpSessionState::set_notification_sink(self : McpSessionState, sink : (
    Json
    ) -> Unit) -> Unit

    carries_valid_modern_envelope_claim

    fn carries_valid_modern_envelope_claim(params_opt : Map[String,
    Json
    ]?) -> Bool

    Returns true if params carries a valid modern (>= 2026-07-28) per-request _meta envelope claim.

    compile_x_mcp_headers

    Scans input_schema once and returns reusable compiled x-mcp-header metadata.

    decode_mcp_param_value

    fn decode_mcp_param_value(value : String) -> String?

    Decodes an SEP-2243 Mcp-Name / Mcp-Param-* HTTP header value. Handles the =?base64?{b64}?= sentinel (canonical padded RFC 4648 Base64 + valid UTF-8). Returns None if the sentinel is present but malformed.

    encode_mcp_param_value

    fn encode_mcp_param_value(value : String) -> String

    Encodes a string value for SEP-2243 Mcp-Name / Mcp-Param-* headers. Safe plain-ASCII RFC 9110 field values pass through unchanged; all other values (empty, leading/trailing whitespace, non-ASCII, control chars, or values already matching the sentinel pattern) are wrapped as =?base64?{b64-of-utf8}?=.

    envelope_claim_version

    fn envelope_claim_version(params_opt : Map[String,
    Json
    ]?) -> String?

    Returns the string value of params._meta["io.modelcontextprotocol/protocolVersion"] if present and a string.

    err_header_mismatch

    let err_header_mismatch : Int

    SEP-2243 HTTP header/body mismatch error code (protocol revision 2026-07-28).

    err_internal_error

    let err_internal_error : Int

    err_invalid_params

    let err_invalid_params : Int

    err_invalid_request

    let err_invalid_request : Int

    err_method_not_found

    let err_method_not_found : Int

    err_missing_required_client_capability

    let err_missing_required_client_capability : Int

    Missing required client capability error code (protocol revision 2026-07-28).

    err_parse_error

    let err_parse_error : Int

    Standard JSON-RPC 2.0 & MCP protocol error codes.

    err_resource_not_found

    let err_resource_not_found : Int

    Receive-tolerated legacy resource-not-found code (-32002). Per 2026-07-28 spec, servers MUST emit -32602 for resources/read misses (see McpProtocolError::resource_not_found); kept as a constant for client interop.

    err_server_overloaded

    let err_server_overloaded : Int

    err_unsupported_protocol_version

    let err_unsupported_protocol_version : Int

    Unsupported protocol version error code (protocol revision 2026-07-28).

    err_url_elicitation_required

    let err_url_elicitation_required : Int

    export_anthropic_tools

    Exports Anthropic-compatible Tool Calling JSON Schema array.

    export_mcp_tools

    Exports MCP tools directly from a ciallo OpenApiDocument.

    export_openai_tools

    Exports OpenAI-compatible Function Calling JSON Schema array.

    extract_mime_base

    fn extract_mime_base(content_type : String) -> String

    extract_params_meta

    fn extract_params_meta(params_opt : Map[String,
    Json
    ]?) -> Map[String,
    Json
    ]?

    Extracts params._meta object when present.

    first_modern_protocol_version

    let first_modern_protocol_version : String

    First protocol revision of the modern (2026-07-28+) era.

    has_envelope_claim

    fn has_envelope_claim(params_opt : Map[String,
    Json
    ]?) -> Bool

    Returns true if params._meta carries the 2026 per-request envelope claim key (io.modelcontextprotocol/protocolVersion).

    honored_subscription_filter

    Narrows a requested SubscriptionFilter against the server's advertised capabilities.

    http_status_for_modern_error

    fn http_status_for_modern_error(code : Int, is_ladder : Bool) -> Int

    Maps a JSON-RPC error code to the spec-mandated HTTP status code on the modern (2026-07-28) path.

    is_modern_protocol_version

    fn is_modern_protocol_version(ver : String) -> Bool

    Returns true if ver belongs to the modern (2026-07-28+) protocol era.

    is_non_object_json_schema_root

    fn is_non_object_json_schema_root(schema :
    Json
    ) -> Bool

    Returns true if schema is a JSON Schema object whose root does NOT declare "type": "object" (matching SEP-2106 isNonObjectJsonSchemaRoot).

    is_rev2026_notification_method

    fn is_rev2026_notification_method(meth : String) -> Bool

    Exact 8 notification methods defined in the 2026-07-28 protocol revision.

    is_rev2026_request_method

    fn is_rev2026_request_method(meth : String) -> Bool

    Exact 10 request methods defined in the 2026-07-28 protocol revision.

    is_supported_legacy_version

    fn is_supported_legacy_version(ver : String) -> Bool

    Returns true if ver is in supported_protocol_versions (legacy revisions).

    is_supported_modern_version

    fn is_supported_modern_version(ver : String) -> Bool

    Returns true if ver is in modern_protocol_versions (supported modern revisions).

    json_scalar_to_string

    fn json_scalar_to_string(v :
    Json
    ) -> String

    latest_protocol_version

    let latest_protocol_version : String

    Latest standard MCP protocol version supported by unmbt/ciallo-mcp.

    localhost_allowed_hostnames

    fn localhost_allowed_hostnames() -> Array[String]

    Convenience allowlist for localhost DNS rebinding protection (validate_host_header).

    localhost_allowed_origins

    fn localhost_allowed_origins() -> Array[String]

    Convenience allowlist for localhost browser Origin protection (validate_origin_header).

    make_subscription_ack

    Builds the leading notifications/subscriptions/acknowledged notification stamped with subscriptionId.

    make_subscription_close_result

    Builds the graceful-close SubscriptionsListenResult response frame.

    make_subscription_event_notification

    Builds a subscription-stamped change notification for event.

    mcp_transport_key

    ContextKey bound into @runtime.Env so route handlers can distinguish McpTransport::Stdio vs McpTransport::StreamableHttp.

    meta_key_baggage

    let meta_key_baggage : String

    meta_key_client_capabilities

    let meta_key_client_capabilities : String

    meta_key_client_info

    let meta_key_client_info : String

    meta_key_log_level

    let meta_key_log_level : String

    meta_key_protocol_version

    let meta_key_protocol_version : String

    Reserved _meta key constants for MCP 2026-07-28 per-request envelopes and results.

    meta_key_server_info

    let meta_key_server_info : String

    meta_key_subscription_id

    let meta_key_subscription_id : String

    meta_key_traceparent

    let meta_key_traceparent : String

    Reserved _meta keys for W3C Trace Context / Baggage propagation (SEP-414).

    meta_key_tracestate

    let meta_key_tracestate : String

    missing_capabilities_for_input_requests

    fn missing_capabilities_for_input_requests(input_requests : Map[String,
    InputRequest
    ], declared_opt :
    Json
    ?) ->
    Json
    ?

    Computes the missing subset of required client capabilities for embedded InputRequests (2026-07-28 SEP-2322 + -32021 MissingRequiredClientCapability). A bare elicitation: {} declaration satisfies elicitation.form per spec.

    modern_protocol_versions

    let modern_protocol_versions : Array[String]

    Modern stateless discovery protocol versions (server/discover).

    parse_subscription_filter

    Parses params.notifications from a subscriptions/listen request.

    subscription_filter_accepts

    Returns true if filter opted in to event.

    supported_protocol_versions

    let supported_protocol_versions : Array[String]

    Protocol versions accepted during initialize negotiation (newest first).

    validate_envelope_meta

    fn validate_envelope_meta(meta : Map[String,
    Json
    ]) -> (String, String)?

    Validates a 2026-07-28 per-request _meta envelope object. Returns Some((key, problem)) on the first violation, or None when valid.

    validate_host_header

    fn validate_host_header(host_header : String?, allowed_hostnames : Array[String]) -> String?

    Validates an HTTP Host header against a port-agnostic hostname allowlist (matches @modelcontextprotocol/server validateHostHeader). Returns None when allowed, or Some(message) on failure.

    validate_mcp_param_headers_compiled

    Validates SEP-2243 Mcp-Param-* headers using pre-scanned CompiledXMcpHeaders (eliminates per-request JSON Schema tree traversal on tools/call).

    validate_origin_header

    fn validate_origin_header(origin_header : String?, allowed_origin_hostnames : Array[String]) -> String?

    Validates an HTTP Origin header against a port-agnostic hostname allowlist (matches @modelcontextprotocol/server validateOriginHeader). Missing/empty Origin passes (non-browser clients); opaque "null" or unparseable origins fail closed; <scheme>://* (non-http/https) supports browser extensions. Returns None when allowed, or Some(message) on failure.

    validate_tool_arguments

    fn validate_tool_arguments(args : Map[String,
    Json
    ], input_schema :
    Json
    ) -> String?

    validate_tool_name

    fn validate_tool_name(name : String) -> Array[String]

    Validates an MCP tool name against SEP-986 (^[A-Za-z0-9._-]{1,128}$). Returns a list of human-readable issues (empty means strictly compliant).

    validate_value_against_schema

    fn validate_value_against_schema(path : String, value :
    Json
    , schema :
    Json
    ) -> String?

    Lightweight runtime JSON Schema validator for programmatic register_tool input_schema. Checks required, property type (string, number, integer, boolean, array, object, null), enum, local #/$defs/<id> $ref, and additionalProperties: false. Returns Some(reason) on first violation.

    validate_x_mcp_headers

    fn validate_x_mcp_headers(input_schema :
    Json
    ) -> String?

    Validates a tool's inputSchema against SEP-2243 x-mcp-header constraints. Returns None when compliant, or Some(reason) on the first violation.

    wrap_output_schema_for_legacy

    fn wrap_output_schema_for_legacy(schema :
    Json
    ) ->
    Json

    SEP-2106 legacy outputSchema projection for 2025-era (2025-11-25) clients: object-rooted schemas (type: "object") pass through unchanged; non-object roots are wrapped in { "type": "object", "properties": { "result": <rewritten> }, "required": ["result"] } with $schema hoisted and same-document $ref/$dynamicRef/$recursiveRef pointers rewritten.