Skip to main content

Module mock_http

Module mock_http 

Source
Expand description

A minimal built-in Streamable HTTP MCP server, for tests and for operators kicking the tyres on reactive setups. Hidden mode: agentd --internal-mock-mcp-http <addr-file> <uri> [--no-emit].

Binds a loopback TCP listener on 127.0.0.1:0 and writes the bound host:port into <addr-file> (atomically: tmp + rename; crate::announce_addr) so the launching harness discovers the endpoint by waiting for the file, then hands agentd --mcp name=http://<addr>.

It serves one resource at <uri>initialize (advertising resources.subscribe), resources/list, resources/read, resources/subscribe — over the Streamable HTTP transport (thread-per-connection, blocking, no dep). After a subscribe it pushes one notifications/resources/updated on the long-lived GET SSE stream (unless emit is off), so a reactive agent reached over HTTP has something to react to.

Functions§

run
Serve the mock on loopback TCP until the process is killed, announcing the bound address through addr_file. Returns the process exit code.