litemcp 0.1.0

The fastest, lightest MCP (Model Context Protocol) framework for Rust — Streamable HTTP only: stateless POST/SSE on a bound socket. Zero async runtime, serde only.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Serveur MCP minimal en HTTP stateless : `cargo run --example hello`
//! puis `POST http://127.0.0.1:8080/mcp`.

use litemcp::prelude::*;

fn main() -> std::io::Result<()> {
    println!(
        "litemcp {} — MCP stateless sur http://127.0.0.1:8080/mcp",
        VERSION
    );
    ServerBuilder::new("hello", "0.1.0")
        .tool("hello", "Dit bonjour à quelqu'un", |args| {
            let name = args.get("name").and_then(|v| v.as_str()).unwrap_or("monde");
            Ok(serde_json::json!({ "message": format!("Bonjour, {name} !") }))
        })
        .bind("127.0.0.1:8080")?
        .serve()
}