Package-level declarations

Types

Link copied to clipboard

Represents a connection interface between a server and a client, enabling communication through notifications, requests, and other operations. This interface defines various methods to facilitate the interaction.

Link copied to clipboard
interface EventStore

Interface for resumability support via event storage

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

A wrapper class representing a registered prompt on the server.

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

A wrapper class representing a registered resource on the server.

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

A wrapper class representing a registered tool on the server.

Link copied to clipboard
open class Server(serverInfo: Implementation, options: ServerOptions, instructionsProvider: () -> String? = null, block: Server.() -> Unit = {})

An MCP server is responsible for storing features and handling new connections.

Link copied to clipboard
class ServerOptions(val capabilities: ServerCapabilities, enforceStrictCapabilities: Boolean = true, val resourceTemplateMatcherFactory: ResourceTemplateMatcherFactory = PathSegmentTemplateMatcher.factory) : ProtocolOptions

Configuration options for the MCP server.

Link copied to clipboard
open class ServerSession(serverInfo: Implementation, options: ServerOptions, instructions: String?) : Protocol

Represents a server session.

Link copied to clipboard

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: Source, outputStream: Sink) : AbstractTransport

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

Link copied to clipboard

Server transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification. It supports both SSE streaming and direct HTTP responses.

Link copied to clipboard

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

Functions

Link copied to clipboard

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.

fun Route.mcp(block: ServerSSESession.() -> Server)

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

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

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

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

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

Link copied to clipboard
fun Application.mcpStreamableHttp(path: String = "/mcp", enableDnsRebindingProtection: Boolean = false, allowedHosts: List<String>? = null, allowedOrigins: List<String>? = null, eventStore: EventStore? = null, block: RoutingContext.() -> Server)

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

Link copied to clipboard
fun Application.mcpWebSocket(block: () -> Server)
fun Route.mcpWebSocket(block: () -> Server)
fun Route.mcpWebSocket(path: String, block: () -> Server)

Configures the Ktor Application to handle Model Context Protocol (MCP) over WebSocket.

fun Application.mcpWebSocket(path: String, block: () -> Server)

Configures the Ktor Application to handle Model Context Protocol (MCP) over WebSocket at the specified path.

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

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.