moonbitstack/moonmcp/context does not have a README file

    Context

    pub struct Context {
    // private fields
    }

    The request a tool, a resource or a prompt is serving: the facts above, and the two things a handler can do with the connection while it runs, report progress and ask whether the caller has gone away.

    A Context is passed by the framework with every request; a handler called straight from a program gets Context::quiet, whose reports go nowhere.

    Context::claims

    fn Context::claims(self : Context) -> Map[String,
    Json
    ]

    Every claim the token carried, as the issuer wrote them. Empty when no token was checked.

    Context::client_capabilities

    What the client says it can do on this request. A request carries its own capabilities, so this is never inherited from an earlier one.

    Context::client_info

    Who the client says it is. Self-reported and unverified, of use for display and for logging, never for a permission decision.

    Context::debug

    async fn Context::debug(self : Context, message : String) -> Unit

    A log message at debug.

    Context::error

    async fn Context::error(self : Context, message : String) -> Unit

    A log message at error.

    Context::facts

    fn Context::facts(self : Context) -> Facts

    The facts this request was served with.

    Context::header

    fn Context::header(self : Context, name : String) -> String?

    The value of the request header name, in lower case as ASGI carries it. Over stdio there are none.

    Context::headers

    fn Context::headers(self : Context) -> Map[String, String]

    Every header the request carried, keyed in lower case.

    Context::info

    async fn Context::info(self : Context, message : String) -> Unit

    A log message at info.

    Context::input_responses

    fn Context::input_responses(self : Context) -> Map[String,
    Json
    ]

    The answers a client sent back with a retried request, keyed by the id the server gave each input request.

    Context::is_cancelled

    fn Context::is_cancelled(self : Context) -> Bool

    Whether the caller said it no longer wants this answer. A long handler should stop; the framework drops whatever it returns.

    Context::log

    async fn Context::log(self : Context, level~ :
    LoggingLevel
    , message~ : String, logger? : String, data? :
    Json
    ) -> Unit

    Report a log message to the client, at level, as notifications/message. It travels the same way progress does: on the stream of the request that caused it, and nowhere when the transport has no stream.

    Context::logger

    The server's log, scoped to this request: its id and operation are already bound, so a line says which request it came from. None when the server was given no logger, which is the default.

    Context::meta

    fn Context::meta(self : Context) -> Map[String,
    Json
    ]

    The request's params._meta object as the client sent it. Over stdio this is the only place a caller can put a trace context or its own metadata; a handler reads it here, and the tracing layer reads traceparent and tracestate from it before falling back to the headers. Empty when the request had no _meta or made one that was not an object.

    Context::new

    fn Context::new(facts~ : Facts, emit? : async (
    Json
    ) -> Unit, gone? : () -> Bool, logger? :
    Logger
    , level? : () ->
    LoggingLevel
    ?) -> Context

    Whether a message leaving a handler goes out at all, and whether the caller is still there. Both are supplied by the transport that carries the request; the defaults do nothing.

    Context::operation

    fn Context::operation(self : Context) -> String

    The method that reached this handler, for example tools/call.

    Context::progress_token

    fn Context::progress_token(self : Context) ->
    Json
    ?

    The token the client gave for progress reports, if it asked for any. A handler that reports progress without one is not answered, and the reports go nowhere.

    Context::protocol_version

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

    The protocol revision the request was sent under.

    Context::quiet

    fn Context::quiet() -> Context

    A context for a call made without a connection: reports are dropped and the caller is always there.

    Context::report_progress

    async fn Context::report_progress(self : Context, progress~ : Double, total? : Double, message? : String) -> Unit

    Report how far along the work is. Silent when the client gave no progress token, as the specification has it: a report the caller did not ask for is not sent.

    progress grows towards total; a report without total says how much is done but not how much is left.

    Context::request_id

    The JSON-RPC id of the request, which a progress notification or a subscription echoes back.

    Context::request_state

    fn Context::request_state(self : Context) -> String?

    The opaque state the server asked the client to hand back on the retry, or None on the first leg.

    Context::subject

    fn Context::subject(self : Context) -> String?

    The subject a bearer token vouched for, when the transport checked one. None over stdio, and over HTTP when the endpoint is open.

    Context::warning

    async fn Context::warning(self : Context, message : String) -> Unit

    A log message at warning.

    Facts

    pub(all) struct Facts {
    protocol_version : String
    operation : String
    request_id :
    Json

    client_info :
    Implementation
    ?
    client_capabilities :
    ClientCapabilities
    ?
    progress_token :
    Json
    ?
    headers : Map[String, String]
    meta : Map[String,
    Json
    ]
    input_responses : Map[String,
    Json
    ]
    request_state : String?
    subject : String?
    claims : Map[String,
    Json
    ]
    } derive(Eq,
    Debug
    )

    What one request says about itself: the revision it was sent under, the client's identity and capabilities, the progress token it offered, the headers that carried it, the _meta object it came with, and the answers it brings back to an earlier leg.

    Facts::equal

    fn Facts::equal(Facts, Facts) -> Bool

    Facts::new

    fn Facts::new(operation? : String, request_id? :
    Json
    , protocol_version? : String, client_info? :
    Implementation
    , client_capabilities? :
    ClientCapabilities
    , progress_token? :
    Json
    , headers? : Map[String, String], meta? : Map[String,
    Json
    ], input_responses? : Map[String,
    Json
    ], request_state? : String, subject? : String, claims? : Map[String,
    Json
    ]) -> Facts

    The facts of a request that carries nothing but its own name, which is what a handler called straight from a program sees.

    Facts::not_equal

    fn Facts::not_equal(x : Facts, y : Facts) -> Bool

    Facts::to_repr

    notification

    fn notification(operation : String, params : Map[String,
    Json
    ]) ->
    Json

    One notification message, framed as the wire carries it.

    Source Files