gleamunison/mcp

MCP (Model Context Protocol) server protocol layer: pure JSON-RPC 2.0.

No sockets here: requests come in as strings, responses go out as strings. Tool handlers are injected, so the protocol is testable without transport.

Types

pub type Response {
  Respond(String)
  NoReply
}

Constructors

  • Respond(String)
  • NoReply
pub type Server {
  Server(name: String, version: String, tools: List(Tool))
}

Constructors

  • Server(name: String, version: String, tools: List(Tool))
pub type Tool {
  Tool(
    name: String,
    description: String,
    handler: fn(dict.Dict(String, dynamic.Dynamic)) -> Result(
      String,
      String,
    ),
  )
}

Constructors

  • Tool(
      name: String,
      description: String,
      handler: fn(dict.Dict(String, dynamic.Dynamic)) -> Result(
        String,
        String,
      ),
    )

Values

pub fn handle_message(server: Server, body: String) -> Response

Handle one raw JSON-RPC request body. Pure: JSON in, JSON out.

✨ Search Document