diff --git a/api/kotlin-sdk.api b/api/kotlin-sdk.api index 8d356d5c..2f303383 100644 --- a/api/kotlin-sdk.api +++ b/api/kotlin-sdk.api @@ -2990,10 +2990,10 @@ public final class io/modelcontextprotocol/kotlin/sdk/client/WebSocketMcpKtorCli } public final class io/modelcontextprotocol/kotlin/sdk/server/KtorServerKt { - public static final fun MCP (Lio/ktor/server/application/Application;Lkotlin/jvm/functions/Function0;)V - public static final fun mcp (Lio/ktor/server/application/Application;Lkotlin/jvm/functions/Function0;)V - public static final fun mcp (Lio/ktor/server/routing/Routing;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V - public static final fun mcp (Lio/ktor/server/routing/Routing;Lkotlin/jvm/functions/Function0;)V + public static final fun MCP (Lio/ktor/server/application/Application;Lkotlin/jvm/functions/Function1;)V + public static final fun mcp (Lio/ktor/server/application/Application;Lkotlin/jvm/functions/Function1;)V + public static final fun mcp (Lio/ktor/server/routing/Routing;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V + public static final fun mcp (Lio/ktor/server/routing/Routing;Lkotlin/jvm/functions/Function1;)V } public final class io/modelcontextprotocol/kotlin/sdk/server/RegisteredPrompt { diff --git a/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/KtorServer.kt b/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/KtorServer.kt index f3683497..c48a4fe8 100644 --- a/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/KtorServer.kt +++ b/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/KtorServer.kt @@ -19,7 +19,7 @@ import io.ktor.utils.io.KtorDsl private val logger = KotlinLogging.logger {} @KtorDsl -public fun Routing.mcp(path: String, block: () -> Server) { +public fun Routing.mcp(path: String, block: ServerSSESession.() -> Server) { route(path) { mcp(block) } @@ -29,7 +29,7 @@ public fun Routing.mcp(path: String, block: () -> Server) { * Configures the Ktor Application to handle Model Context Protocol (MCP) over Server-Sent Events (SSE). */ @KtorDsl -public fun Routing.mcp(block: () -> Server) { +public fun Routing.mcp(block: ServerSSESession.() -> Server) { val transports = ConcurrentMap() sse { @@ -43,12 +43,12 @@ public fun Routing.mcp(block: () -> Server) { @Suppress("FunctionName") @Deprecated("Use mcp() instead", ReplaceWith("mcp(block)"), DeprecationLevel.WARNING) -public fun Application.MCP(block: () -> Server) { +public fun Application.MCP(block: ServerSSESession.() -> Server) { mcp(block) } @KtorDsl -public fun Application.mcp(block: () -> Server) { +public fun Application.mcp(block: ServerSSESession.() -> Server) { val transports = ConcurrentMap() install(SSE) @@ -67,7 +67,7 @@ public fun Application.mcp(block: () -> Server) { private suspend fun ServerSSESession.mcpSseEndpoint( postEndpoint: String, transports: ConcurrentMap, - block: () -> Server, + block: ServerSSESession.() -> Server, ) { val transport = mcpSseTransport(postEndpoint, transports)