Add ServerSSESession as a receiver for mcp {} dsl (#190)
* Add ServerSSESession as a receiver for mcp {} dsl
* update api
---------
Co-authored-by: devcrocod <devcrocod@gmail.com>
This commit is contained in:
parent
75d63c8cb2
commit
111d31b1fb
2 changed files with 9 additions and 9 deletions
|
|
@ -3,10 +3,10 @@ public final class io/modelcontextprotocol/kotlin/sdk/LibVersionKt {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class io/modelcontextprotocol/kotlin/sdk/server/KtorServerKt {
|
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/Function1;)V
|
||||||
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/Function1;)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;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
|
||||||
public static final fun mcp (Lio/ktor/server/routing/Routing;Lkotlin/jvm/functions/Function0;)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 {
|
public final class io/modelcontextprotocol/kotlin/sdk/server/RegisteredPrompt {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import io.ktor.utils.io.KtorDsl
|
||||||
private val logger = KotlinLogging.logger {}
|
private val logger = KotlinLogging.logger {}
|
||||||
|
|
||||||
@KtorDsl
|
@KtorDsl
|
||||||
public fun Routing.mcp(path: String, block: () -> Server) {
|
public fun Routing.mcp(path: String, block: ServerSSESession.() -> Server) {
|
||||||
route(path) {
|
route(path) {
|
||||||
mcp(block)
|
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).
|
* Configures the Ktor Application to handle Model Context Protocol (MCP) over Server-Sent Events (SSE).
|
||||||
*/
|
*/
|
||||||
@KtorDsl
|
@KtorDsl
|
||||||
public fun Routing.mcp(block: () -> Server) {
|
public fun Routing.mcp(block: ServerSSESession.() -> Server) {
|
||||||
val transports = ConcurrentMap<String, SseServerTransport>()
|
val transports = ConcurrentMap<String, SseServerTransport>()
|
||||||
|
|
||||||
sse {
|
sse {
|
||||||
|
|
@ -43,12 +43,12 @@ public fun Routing.mcp(block: () -> Server) {
|
||||||
|
|
||||||
@Suppress("FunctionName")
|
@Suppress("FunctionName")
|
||||||
@Deprecated("Use mcp() instead", ReplaceWith("mcp(block)"), DeprecationLevel.WARNING)
|
@Deprecated("Use mcp() instead", ReplaceWith("mcp(block)"), DeprecationLevel.WARNING)
|
||||||
public fun Application.MCP(block: () -> Server) {
|
public fun Application.MCP(block: ServerSSESession.() -> Server) {
|
||||||
mcp(block)
|
mcp(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
@KtorDsl
|
@KtorDsl
|
||||||
public fun Application.mcp(block: () -> Server) {
|
public fun Application.mcp(block: ServerSSESession.() -> Server) {
|
||||||
val transports = ConcurrentMap<String, SseServerTransport>()
|
val transports = ConcurrentMap<String, SseServerTransport>()
|
||||||
|
|
||||||
install(SSE)
|
install(SSE)
|
||||||
|
|
@ -67,7 +67,7 @@ public fun Application.mcp(block: () -> Server) {
|
||||||
private suspend fun ServerSSESession.mcpSseEndpoint(
|
private suspend fun ServerSSESession.mcpSseEndpoint(
|
||||||
postEndpoint: String,
|
postEndpoint: String,
|
||||||
transports: ConcurrentMap<String, SseServerTransport>,
|
transports: ConcurrentMap<String, SseServerTransport>,
|
||||||
block: () -> Server,
|
block: ServerSSESession.() -> Server,
|
||||||
) {
|
) {
|
||||||
val transport = mcpSseTransport(postEndpoint, transports)
|
val transport = mcpSseTransport(postEndpoint, transports)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue