moonbitstack/moonmcp/client does not have a README file

    Transport

    pub(open) trait Transport {
    async fn ask(Self, message : Json, on_notification : async (Json) -> Unit) -> Json
    async fn tell(Self, message : Json) -> Unit
    async fn listen(Self, message : Json, on_notification : async (Json) -> Unit) -> Unit
    async fn close(Self) -> Unit
    }

    A connection that carries JSON-RPC messages. Implement it to reach a server this library does not speak to itself; the three that ship here are Memory, Lines and Http.

    The trait is open: a transport only has to move messages and say which reply belongs to which request. Everything a client does with them — versioning, capabilities, the shape of a call — stays in Client.

    Refused

    pub suberror Refused {
    Refused(code~ : Int, message~ : String, data~ : Json?)
    }

    A server said no. The code and data are the JSON-RPC error as it arrived.

    Client

    A connection to a server, with the handshake behind it (← FastMCP's Client).

    On the 2026-07-28 revision there is no handshake: every request carries the version, the client's identity and its capabilities in _meta, and the server answers on its own. On the revisions before it, connect runs initialize and notifications/initialized once.

    Client::call_tool

    async fn Client::call_tool(self : Client, name : String, arguments? : Map[String, Json], on_notification? : async (Json) -> Unit, progress_token? : Json) ->
    CallToolResult

    Call name with arguments; notifications sent before the answer go to on_notification.

    Client::close

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

    Stop asking for anything on this connection.

    Client::connect

    async fn Client::connect(transport : &Transport, name? : String, version? : String, protocol_version? : String, capabilities? :
    ClientCapabilities
    ) -> Client

    Connect over transport. protocol_version picks the dialect: 2026-07-28 speaks the stateless revision, anything the server lists as older runs the handshake. The default follows the server's own latest_protocol_version.

    Client::discover

    async fn Client::discover(self : Client) -> Map[String, Json]

    What the server supports and which revisions it speaks.

    Client::exchange

    async fn Client::exchange(self : Client, operation : String, params? : Map[String, Json], on_notification? : async (Json) -> Unit, progress_token? : Json) -> Map[String, Json]

    The same, with somewhere to put the notifications the server sends while the answer is being worked out: progress, log messages.

    Client::get_prompt

    async fn Client::get_prompt(self : Client, name : String, arguments? : Map[String, Json]) ->
    GetPromptResult

    Render the prompt name with arguments.

    Client::list_prompts

    async fn Client::list_prompts(self : Client) -> Array[
    Prompt
    ]

    The prompts the server offers.

    Client::list_resources

    The resources the server offers.

    Client::list_tools

    async fn Client::list_tools(self : Client) -> Array[
    Tool
    ]

    The tools the server offers.

    Client::listen

    async fn Client::listen(self : Client, filter~ :
    SubscriptionFilter
    , on_notification~ : async (Json) -> Unit) -> Unit

    Open a subscription and hand every notification on it to on_notification until the server ends it.

    Client::notify

    async fn Client::notify(self : Client, operation : String, params? : Map[String, Json]) -> Unit

    Send a message that gets no reply.

    Client::ping

    async fn Client::ping(self : Client) -> Unit

    A bare result with no payload.

    Client::protocol_version

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

    The revision in force on this connection.

    Client::read_resource

    async fn Client::read_resource(self : Client, uri : String) ->
    ReadResourceResult

    Read the resource at uri.

    Client::request

    async fn Client::request(self : Client, operation : String, params? : Map[String, Json]) -> Map[String, Json]

    Ask operation with params and hand back the result, raising Refused when the server answers with an error.

    Client::server_capabilities

    What the server says it can do.

    Client::server_info

    Who the server says it is, once it has said.

    Lines

    pub struct Lines {
    read : async () -> String?
    write : async (String) -> Unit
    lock :
    Mutex

    }

    A transport over a pair of line streams: standard input and output of a child process, a socket, a pipe. The same reader and writer a server is served on, seen from the other end.

    One question is in flight at a time: a reply carries only an id, so a second question would have to read past the first one's answer. The lock holds the whole exchange for that reason.
    impl Transport for Lines

    Lines::ask

    async fn Lines::ask(self : Lines, message : Json, on_notification : async (Json) -> Unit) -> Json

    Lines::close

    async fn Lines::close(_self : Lines) -> Unit

    Lines::listen

    async fn Lines::listen(self : Lines, message : Json, on_notification : async (Json) -> Unit) -> Unit

    Lines::new

    fn Lines::new(read~ : async () -> String?, write~ : async (String) -> Unit) -> Lines

    Speak newline-delimited JSON-RPC over read and write.

    Lines::tell

    async fn Lines::tell(self : Lines, message : Json) -> Unit

    Memory

    pub struct Memory {
    server :
    Server

    }

    A transport that reaches a server in the same program, with no wire between them: what an editor, a test or an embedded agent uses.
    impl Transport for Memory

    Memory::ask

    async fn Memory::ask(self : Memory, message : Json, on_notification : async (Json) -> Unit) -> Json

    Memory::close

    async fn Memory::close(_self : Memory) -> Unit

    Memory::listen

    async fn Memory::listen(self : Memory, message : Json, on_notification : async (Json) -> Unit) -> Unit

    Memory::new

    Reach server directly. Its handlers see no headers and no client identity, since nothing carried the message.

    Memory::tell

    async fn Memory::tell(self : Memory, message : Json) -> Unit

    Powered by MoonBit

    Site sourceReport issueModulesSkillsBuild queueStatistics

    © 2026 mooncakes.io