DocsRuntimeagent-runtimeCreateExpressHandler
Package: @hexos/runtime

Creates an Express/Fastify-compatible middleware handler for streaming agent conversations.

Sets SSE response headers and streams RuntimeEvents as data: \{json\}\n\n lines. Initializes MCP servers on first request. Compatible with any framework that provides req.body, res.setHeader(), res.write(), and res.end().

Related: createAgentHandler is the Next.js equivalent, AgentRuntime.stream() produces the events.

function createExpressHandler(runtime: AgentRuntime): void

Parameters

runtime