Skip to content

basalt / mcp-core/src / serveHttp

Function: serveHttp() ​

> serveHttp(server, options?): Promise<HttpHandle>

Defined in: mcp-core/src/http.ts:169

Serve MCP over a minimal Node http server — POST JSON-RPC to /mcp, one request/response per call (the Streamable-HTTP JSON path, no SSE). Intended as an opt-in remote/CI transport; stdio stays the primary local-dev transport.

Deliberately minimal: it uses only node:http, never @basaltkit/http, so a dev-only server keeps the framework runtime out of its dependency graph. Server→client notifications (progress) are not delivered over this transport — use stdio when you need live progress.

With sessions on (opt-in), Mcp-Session-Id scopes cancellation: a notifications/cancelled POSTed in a later request of the same session aborts the call it names; no other session can. Stateless (the default), each request is its own session. A call is always aborted when its client disconnects before the response is written. JSON-RPC batches are accepted. Bodies over maxBodyBytes get 413 without being buffered.

Parameters ​

server ​

StdioServerLike

options? ​

ServeHttpOptions = {}

Returns ​

Promise<HttpHandle>

Released under the MIT License.