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 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.
pub fn json_string(s: String) -> String
Thin delegate to the JSON boundary’s single escaper (json.json_quote). The former encode-based body degraded to “""” on encode failure; json_quote is total, so there is no failure left to degrade — an invalid JSON string can no longer be built here at all.