(sigil mcp http)
Streamable HTTP transport for MCP servers.
Serves an MCP server over a single POST endpoint, stateless and dual-era. It targets protocol revision 2026-07-28 — per-request _meta, no sessions, no Mcp-Session-Id — while still answering the legacy initialize handshake for clients that have not migrated.
Stateless refers to MCP sessions only. The hosting application stays as stateful as it likes; what this transport promises is that no request depends on a previous one having arrived on the same connection.
(import (sigil mcp) (sigil mcp http))
(define server (mcp-server name: "example" version: "1.0.0"))
(mcp-server-register-tool! server "ping" "Reply with pong"
'((type . "object") (properties . ()))
(lambda (args) "pong"))
(mcp-server-run-http server port: 8765)Exports
mcp-http-cacheable-method?procedureDoes a result for method have to carry cache metadata?
Kept for existing importers; the list itself now lives in (sigil mcp server) so the stdio loop and this transport agree.
mcp-http-origin-allowed?procedureIs this Origin header value acceptable?
An absent Origin (#f) is allowed: non-browser clients do not send one, and the spec only requires rejecting an Origin that is present and invalid. A present Origin must name a loopback host.
mcp-http-handlerprocedureBuild the HTTP handler for an MCP server.
Returns a procedure suitable for http-serve. Exposed separately from mcp-server-run-http so it can be tested against constructed requests without opening a socket.
mcp-server-run-httpprocedureRun an MCP server over Streamable HTTP.
Binds loopback by default. The transport is stateless: it never issues or honours a session id, so any number of clients may attach and each may restart without disturbing the others or the hosting application.
Blocks until the server stops, exactly as mcp-server-run does.