Skip to content

Commit e5b1503

Browse files
Solve issue #52 by improving url handling in SseClientTransport
1 parent 27622da commit e5b1503

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/client/SSEClientTransport.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class SseClientTransport(
3939
private var job: Job? = null
4040

4141
private val baseUrl by lazy {
42-
session.call.request.url.toString().removeSuffix("/")
42+
session.call.request.url.toString().removeSuffix("/sse")
4343
}
4444

4545
override suspend fun start() {
@@ -52,7 +52,7 @@ public class SseClientTransport(
5252

5353
session = urlString?.let {
5454
client.sseSession(
55-
urlString = it,
55+
urlString = "$it/sse",
5656
reconnectionTime = reconnectionTime,
5757
block = requestBuilder,
5858
)
@@ -76,7 +76,7 @@ public class SseClientTransport(
7676

7777
"endpoint" -> {
7878
try {
79-
val eventData = event.data ?: ""
79+
val eventData = event.data?.removePrefix("/") ?: ""
8080

8181
// check url correctness
8282
val maybeEndpoint = Url("$baseUrl/$eventData")

0 commit comments

Comments
 (0)