Remove fixed suffix /sse (#108)

* Simplify URL handling in SSE client transport.

* fix the sse integration test

---------

Co-authored-by: devcrocod <devcrocod@gmail.com>
This commit is contained in:
adamglin0 2025-07-04 18:40:00 +08:00 • committed by GitHub
commit aa00fc3d5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -68,7 +68,7 @@ public class SseClientTransport(
session = urlString?.let {
client.sseSession(
urlString = "$it/sse",
urlString = it,
reconnectionTime = reconnectionTime,
block = requestBuilder,
)

View file

@ -2,9 +2,11 @@ package io.modelcontextprotocol.kotlin.sdk.integration
import io.ktor.client.HttpClient
import io.ktor.client.plugins.sse.SSE
import io.ktor.server.application.install
import io.ktor.server.cio.CIOApplicationEngine
import io.ktor.server.engine.EmbeddedServer
import io.ktor.server.engine.embeddedServer
import io.ktor.server.routing.routing
import io.modelcontextprotocol.kotlin.sdk.Implementation
import io.modelcontextprotocol.kotlin.sdk.ServerCapabilities
import io.modelcontextprotocol.kotlin.sdk.client.Client
@ -52,7 +54,12 @@ class SseIntegrationTest {
ServerOptions(capabilities = ServerCapabilities()),
)
return embeddedServer(ServerCIO, host = URL, port = PORT) { mcp { server } }.startSuspend(wait = false)
return embeddedServer(ServerCIO, host = URL, port = PORT) {
install(io.ktor.server.sse.SSE)
routing {
mcp { server }
}
}.startSuspend(wait = false)
}
companion object {