Skip to content

Commit ecced12

Browse files
committed
Update Accept header for SSE requests to use application/json, text/event-stream
1 parent d82fc22 commit ecced12

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

kotlin-sdk-client/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/client/StreamableHttpClientTransport.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ public class StreamableHttpClientTransport(
228228
) {
229229
method = HttpMethod.Get
230230
applyCommonHeaders(this)
231-
accept(ContentType.Text.EventStream)
231+
// sseSession will add ContentType.Text.EventStream automatically
232+
accept(ContentType.Application.Json)
232233
(resumptionToken ?: lastEventId)?.let { headers.append(MCP_RESUMPTION_TOKEN_HEADER, it) }
233234
requestBuilder()
234235
}

kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/MockMcp.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ internal class MockMcp(verbose: Boolean = false) {
6767
mokksy.get(name = "MCP GETs", requestType = Any::class) {
6868
path("/mcp")
6969
containsHeader("Mcp-Session-Id", sessionId)
70-
containsHeader("Accept", "text/event-stream,text/event-stream") // todo: why 2 times?
70+
containsHeader("Accept", "application/json,text/event-stream")
7171
containsHeader("Cache-Control", "no-store")
7272
} respondsWithSseStream {
7373
headers += "Mcp-Session-Id" to sessionId

0 commit comments

Comments
 (0)