From 9c4a2394b40e89f3d8e560d7a8ae0c4a5a3a6d5b Mon Sep 17 00:00:00 2001 From: Pavel Gorgulov Date: Wed, 1 Apr 2026 15:22:35 +0200 Subject: [PATCH] test: remove `Ignore` for SseTransportTest and refactor (#662) SseTransportTest passes on wasm after updating ktor ## How Has This Been Tested? jvm/js/wasm/macos ## Breaking Changes none ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed --- .../kotlin/sdk/client/SseTransportTest.kt | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/integration-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/SseTransportTest.kt b/integration-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/SseTransportTest.kt index d82ff47..8abf75d 100644 --- a/integration-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/SseTransportTest.kt +++ b/integration-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/SseTransportTest.kt @@ -12,9 +12,10 @@ import io.modelcontextprotocol.kotlin.sdk.server.mcp import io.modelcontextprotocol.kotlin.sdk.shared.BaseTransportTest import io.modelcontextprotocol.kotlin.sdk.types.Implementation import io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.withContext import kotlin.test.BeforeTest -import kotlin.test.Ignore import kotlin.test.Test import io.ktor.client.plugins.sse.SSE as ClientSSE import io.ktor.server.sse.SSE as ServerSSE @@ -37,7 +38,6 @@ class SseTransportTest : BaseTransportTest() { } @Test - @Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3 fun `should start then close cleanly`() = runTest { val server = embeddedServer(CIO, port = 0) { install(ServerSSE) @@ -58,13 +58,12 @@ class SseTransportTest : BaseTransportTest() { } try { - testTransportRead(transport) + testTransportOpenClose(transport) } finally { server.stopSuspend() } } - @Ignore @Test fun `should read messages`() = runTest { val server = embeddedServer(CIO, port = 0) { @@ -85,20 +84,28 @@ class SseTransportTest : BaseTransportTest() { } } + val client = Client( + clientInfo = Implementation(name = "test-client", version = "1.0"), + options = ClientOptions(), + ) + try { - testTransportRead(transport) + withContext(Dispatchers.Default) { + client.connect(transport) + client.ping() + } } finally { + client.close() server.stopSuspend() } } - @Ignore @Test fun `test sse path not root path`() = runTest { val server = embeddedServer(CIO, port = 0) { install(ServerSSE) routing { - mcp { mcpServer } + mcp("/sse") { mcpServer } } }.startSuspend(wait = false) @@ -114,9 +121,18 @@ class SseTransportTest : BaseTransportTest() { } } + val client = Client( + clientInfo = Implementation(name = "test-client", version = "1.0"), + options = ClientOptions(), + ) + try { - testTransportRead(transport) + withContext(Dispatchers.Default) { + client.connect(transport) + client.ping() + } } finally { + client.close() server.stopSuspend() } }