mcpStatelessStreamableHttp

fun Application.mcpStatelessStreamableHttp(path: String = "/mcp", enableDnsRebindingProtection: Boolean = true, allowedHosts: List<String>? = null, allowedOrigins: List<String>? = null, block: RoutingContext.() -> Server)(source)

Configures the Ktor Application to handle Model Context Protocol (MCP) over stateless Streamable HTTP Transport

Sets up an HTTP POST endpoint at path. GET and DELETE requests return 405 Method Not Allowed. Every request/response pair is returned as JSON, so this endpoint opens no SSE stream and offers no resumability. Use mcpStreamableHttp when either is required.

Automatically installs ContentNegotiation with McpJson.

Parameters

path

The URL path where the server listens for incoming JSON-RPC requests. Defaults to "/mcp".

enableDnsRebindingProtection

Determines whether DNS rebinding protection is enabled. Defaults to true.

allowedHosts

A list of allowed hostnames. If null and DNS rebinding protection is enabled, defaults to localhost, 127.0.0.1, [::1].

allowedOrigins

A list of allowed Origin header values, compared by hostname only (scheme and port are ignored). Requests without an Origin header are allowed. If null, origin validation is disabled.

block

factory block with access to the RoutingContext (for reading request headers) that creates and returns the Server to handle the connection.


fun Application.mcpStatelessStreamableHttp(path: String = "/mcp", enableDnsRebindingProtection: Boolean = true, allowedHosts: List<String>? = null, allowedOrigins: List<String>? = null, eventStore: EventStore?, block: RoutingContext.() -> Server)(source)

Deprecated (with error)

Use mcpStatelessStreamableHttp without eventStore.

Replace with

mcpStatelessStreamableHttp(path, enableDnsRebindingProtection, allowedHosts, allowedOrigins, block)

Retained only so that existing call sites get a migration hint instead of an unresolved parameter name.

Parameters

eventStore

never consulted by a stateless endpoint. Resumption is driven by a GET carrying Last-Event-ID, and this endpoint answers GET with 405 Method Not Allowed, so no stream exists to store events on or replay them to. Use mcpStreamableHttp when you need resumability.