mcp

fun Route.mcp(path: String, block: ServerSSESession.() -> Server)(source)

Registers MCP over Server-Sent Events (SSE) Transport at the specified path on this Route.

Precondition: the SSE plugin must be installed on the application before calling this function. Use Application.mcp if you want SSE to be installed automatically.

Parameters

path

the URL path to register the SSE endpoint.

block

factory block with access to the ServerSSESession that creates and returns the Server to handle the connection.

Throws

if the SSE plugin is not installed.


Registers MCP over Server-Sent Events (SSE) Transport endpoints on this Route.

Precondition: the SSE plugin must be installed on the application before calling this function. Use Application.mcp if you want SSE to be installed automatically.

Parameters

block

factory block with access to the ServerSSESession that creates and returns the Server to handle the connection.

Throws

if the SSE plugin is not installed.


Configures the Ktor Application to handle Model Context Protocol (MCP) over Server-Sent Events (SSE) Transport and sets up routing with the provided configuration block.

Automatically installs ContentNegotiation with McpJson and SSE.

Parameters

block

factory block with access to the ServerSSESession that creates and returns the Server to handle the connection.