Skip to content

Commit 67f91a1

Browse files
committed
Simplify server functions by removing redundant coroutines support and cleanup unused imports
1 parent cd8b31e commit 67f91a1

File tree

2 files changed

+4
-6
lines changed
  • samples
    • kotlin-mcp-server/src/main/kotlin/io/modelcontextprotocol/sample/server
    • weather-stdio-server/src/main/kotlin/io/modelcontextprotocol/sample/server

2 files changed

+4
-6
lines changed

samples/kotlin-mcp-server/src/main/kotlin/io/modelcontextprotocol/sample/server/server.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fun configureServer(): Server {
100100
return server
101101
}
102102

103-
suspend fun runSseMcpServerWithPlainConfiguration(port: Int) {
103+
fun runSseMcpServerWithPlainConfiguration(port: Int) {
104104
val serverSessions = ConcurrentMap<String, ServerSession>()
105105
println("Starting SSE server on port $port")
106106
println("Use inspector to connect to http://localhost:$port/sse")
@@ -136,7 +136,7 @@ suspend fun runSseMcpServerWithPlainConfiguration(port: Int) {
136136
transport.handlePostMessage(call)
137137
}
138138
}
139-
}.startSuspend(wait = true)
139+
}.start(wait = true)
140140
}
141141

142142
/**
@@ -147,15 +147,15 @@ suspend fun runSseMcpServerWithPlainConfiguration(port: Int) {
147147
*
148148
* @param port The port number on which the SSE MCP server will listen for client connections.
149149
*/
150-
suspend fun runSseMcpServerUsingKtorPlugin(port: Int) {
150+
fun runSseMcpServerUsingKtorPlugin(port: Int) {
151151
println("Starting SSE server on port $port")
152152
println("Use inspector to connect to http://localhost:$port/sse")
153153

154154
embeddedServer(CIO, host = "127.0.0.1", port = port) {
155155
mcp {
156156
return@mcp configureServer()
157157
}
158-
}.startSuspend(wait = true)
158+
}.start(wait = true)
159159
}
160160

161161
/**

samples/weather-stdio-server/src/main/kotlin/io/modelcontextprotocol/sample/server/McpWeatherServer.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import io.ktor.http.ContentType
77
import io.ktor.http.contentType
88
import io.ktor.http.headers
99
import io.ktor.serialization.kotlinx.json.json
10-
import io.ktor.utils.io.core.Input
1110
import io.ktor.utils.io.streams.asInput
1211
import io.modelcontextprotocol.kotlin.sdk.CallToolResult
1312
import io.modelcontextprotocol.kotlin.sdk.Implementation
@@ -19,7 +18,6 @@ import io.modelcontextprotocol.kotlin.sdk.server.ServerOptions
1918
import io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport
2019
import kotlinx.coroutines.Job
2120
import kotlinx.coroutines.runBlocking
22-
import kotlinx.io.Sink
2321
import kotlinx.io.asSink
2422
import kotlinx.io.buffered
2523
import kotlinx.serialization.json.Json

0 commit comments

Comments
 (0)