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
This commit is contained in:
Pavel Gorgulov 2026-04-01 15:22:35 +02:00 • committed by GitHub
commit 9c4a2394b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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()
}
}