Skip to main content

Module http

Module http 

Source
Expand description

The server over MCP’s streamable HTTP transport, for an app that is already running (brep-app --mcp): an agent connects to http://127.0.0.1:<port>/mcp instead of launching a process. rmcp’s transport is a tower service; hyper serves it connection by connection on the listener the caller bound.

Every request shares one ServerState: the session slot and the tool set are the same whichever connection asks, so a client that lists tools sees the attached app’s commands from its first request. rmcp validates Host against loopback names by default, which is the DNS-rebinding guard a local server needs; the listener itself is bound by the caller (to 127.0.0.1 in the app).

Every request also carries the loopback credential (D3, Credential): Authorization: Bearer <token>, the token read from a 0600 file in the app’s config directory (mcp-token, created on first use), so another local user — or a page in a browser — cannot drive the app. A request with an Origin header must come from a loopback origin.

Structs§

Credential
The loopback HTTP credential: a bearer token kept in a file only its owner can read. The file outlives the server, so an agent configured once keeps working; delete it to mint a new one.

Constants§

MAX_BODY_BYTES
Serve until the listener fails. Each accepted connection runs on its own task; a connection error ends that connection only. The largest request body the HTTP transport reads (contract §12).

Functions§

serve_http
url
The URL agents are told to connect to for a server on port.