Skip to content

Remove CompletableDeferred from weather-stdio-server sample #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import io.modelcontextprotocol.kotlin.sdk.*
import io.modelcontextprotocol.kotlin.sdk.server.Server
import io.modelcontextprotocol.kotlin.sdk.server.ServerOptions
import io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Job
import kotlinx.coroutines.runBlocking
import kotlinx.io.asSink
Expand All @@ -19,8 +18,6 @@ import kotlinx.serialization.json.*

// Main function to run the MCP server
fun `run mcp server`() {
val def = CompletableDeferred<Unit>()

// Base URL for the Weather API
val baseUrl = "https://api.weather.gov"

Expand Down Expand Up @@ -52,7 +49,7 @@ fun `run mcp server`() {
ServerOptions(
capabilities = ServerCapabilities(tools = ServerCapabilities.Tools(listChanged = true))
)
) { def.complete(Unit) }
)

// Register a tool to fetch weather alerts by state
server.addTool(
Expand Down