Repository navigation
Conversation
9dbf0d9 to
598918e
Compare
|
Hi @devcrocod — this is my first PR here, so GitHub Actions is waiting on |
There was a problem hiding this comment.
Looks great — the negotiated version is now applied at exactly the right point, so this is good to merge.
Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=679168e7-961a-4c1e-a428-c8ec11527e07
chrikrah
left a comment
There was a problem hiding this comment.
@xu-baolin approving at 598918e. With Client.kt at the merge base, your test finds transport.protocolVersion still null after connect. With the change, both it and the ping header carry the negotiated value.
$ ./gradlew :kotlin-sdk-client:jvmTest --tests "*StreamableHttpClientTransportTest" # 598918e, Temurin 21, Gradle 9.8.0
tests=18 failures=0
$ # same command, Client.kt at 32e6483 (merge base), test kept
tests=18 failures=1
FAIL connect should apply the negotiated protocol version to subsequent streamable HTTP requests
AssertionFailedError: Expected "2025-03-26" but actual was null
Client.connect sets the value before it sends notifications/initialized. The GET stream at StreamableHttpClientTransport.kt:189 opens after that notification and carries the header too.
@devcrocod your #985 makes the same assignment in settle(), so the two touch the same lines of connect. #985 is the breaking one. Would you take this now as the fix for #1090, and drop the lines from #985 on rebase?
Copy InitializeResult.protocolVersion onto StreamableHttpClientTransport before initialized so subsequent Streamable HTTP requests include the spec-required header.
598918e to
e15eac4
Compare
|
Rebased onto the latest |
There was a problem hiding this comment.
Happy to approve this one — thanks for the fix!
Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=eb5f860e-6c13-4019-87f4-ab965c2c11f1
Copy InitializeResult.protocolVersion onto StreamableHttpClientTransport before initialized so subsequent Streamable HTTP requests include the spec-required header.
After
initializesucceeds,Client.connectnow assignsInitializeResult.protocolVersiontoStreamableHttpClientTransport.protocolVersionbefore sendingnotifications/initialized. Subsequent Streamable HTTP requests then includemcp-protocol-version.Motivation and Context
The Streamable HTTP spec (2025-06-18 / 2025-11-25) requires clients to send the negotiated protocol version on HTTP requests after initialize. Servers that do not receive the header SHOULD assume
2025-03-26.StreamableHttpClientTransportalready appendsmcp-protocol-versionwhenprotocolVersionis set, butClient.connectnever copied the negotiated value, so the header was omitted unless callers set the field by hand.Fixes #1090
How Has This Been Tested?
Unit tests in
StreamableHttpClientTransportTest(JVM):should send the protocol version header once it is setconnect should apply the negotiated protocol version to subsequent streamable HTTP requests—Client.connectover a mock Streamable HTTP transport, thenping; the ping POST includesmcp-protocol-versionequal to the initialize result.Breaking Changes
None. Clients that already set
protocolVersionmanually keep working. Callers that relied on the header being absent may now seemcp-protocol-versionon post-initialize Streamable HTTP requests.Types of changes
Checklist
Additional context
Assignment is gated on
transport is StreamableHttpClientTransportbecause only that transport hasprotocolVersion. SSE is unchanged.The initialize request itself still does not send the header (the field is set only after the initialize result is accepted), which matches “after successfully initializing”.