Package-level declarations

Types

Link copied to clipboard
data class RegisteredPrompt(val prompt: Prompt, val messageProvider: suspend (GetPromptRequest) -> GetPromptResult)

A wrapper class representing a registered prompt on the server.

Link copied to clipboard
data class RegisteredResource(val resource: Resource, val readHandler: suspend (ReadResourceRequest) -> ReadResourceResult)

A wrapper class representing a registered resource on the server.

Link copied to clipboard
data class RegisteredTool(val tool: Tool, val handler: suspend (CallToolRequest) -> CallToolResult)

A wrapper class representing a registered tool on the server.

Link copied to clipboard
open class Server(serverInfo: Implementation, options: ServerOptions, var onCloseCallback: () -> Unit? = null) : Protocol<ServerRequest, ServerNotification, ServerResult>

An MCP server on top of a pluggable transport.

Link copied to clipboard
class ServerOptions(val capabilities: ServerCapabilities, var enforceStrictCapabilities: Boolean = true) : ProtocolOptions

Configuration options for the MCP server.

Link copied to clipboard
class SSEServerTransport(endpoint: String, session: ServerSSESession) : Transport

Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.

Link copied to clipboard
class StdioServerTransport(inputStream: BufferedInputStream = BufferedInputStream(System.`in`), outputStream: PrintStream = System.out) : Transport

A server transport that communicates with a client via standard I/O.

Link copied to clipboard
class WebSocketMcpServerTransport(session: WebSocketServerSession) : WebSocketMcpTransport

Server-side implementation of the MCP (Model Context Protocol) transport over WebSocket.

Functions

Link copied to clipboard
fun Application.MCP(block: () -> Server)

Configures the Ktor Application to handle Model Context Protocol (MCP) over Server-Sent Events (SSE).

Link copied to clipboard
fun Route.mcpWebSocket(options: ServerOptions? = null, handler: suspend Server.() -> Unit = {})

Registers a WebSocket route that establishes an MCP (Model Context Protocol) server session.

fun Route.mcpWebSocket(path: String, options: ServerOptions? = null, handler: suspend Server.() -> Unit = {})

Registers a WebSocket route at the specified path that establishes an MCP server session.

Link copied to clipboard
fun Route.mcpWebSocketTransport(handler: suspend WebSocketMcpServerTransport.() -> Unit = {})

Registers a WebSocket route that creates an MCP server transport layer.

fun Route.mcpWebSocketTransport(path: String, handler: suspend WebSocketMcpServerTransport.() -> Unit = {})

Registers a WebSocket route at the specified path that creates an MCP server transport layer.