[fix] when mcp server not give mcp session id ,mcp session store null…#554
Closed
caojiaqi123 wants to merge 3 commits intomodelcontextprotocol:mainfrom
Closed
[fix] when mcp server not give mcp session id ,mcp session store null…#554caojiaqi123 wants to merge 3 commits intomodelcontextprotocol:mainfrom
caojiaqi123 wants to merge 3 commits intomodelcontextprotocol:mainfrom
Conversation
Contributor
Yes, the |
quaff
reviewed
Sep 17, 2025
| import reactor.util.function.Tuple2; | ||
| import reactor.util.function.Tuples; | ||
|
|
||
| import java.io.IOException; |
Contributor
There was a problem hiding this comment.
You should revert unrelated parts, keep null check changes only.
Author
There was a problem hiding this comment.
ok, reverted unrelated parts. Submit MR first time, thx reminder. @quaff
quaff
reviewed
Sep 17, 2025
| if (transportSession.markInitialized( | ||
| responseEvent.responseInfo().headers().firstValue("mcp-session-id").orElseGet(() -> null))) { | ||
| String mcpSessionId = responseEvent.responseInfo().headers().firstValue("mcp-session-id").orElseGet(() -> null); | ||
| if (Objects.nonNull(mcpSessionId) && transportSession.markInitialized(mcpSessionId)) { |
Contributor
There was a problem hiding this comment.
API Note:
This method exists to be used as a java.util.function.Predicate, filter(Objects::nonNull)
I think mcpSessionId != null should be used here.
Author
There was a problem hiding this comment.
Oh, I see. It is used to listen for notifications. thx!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… as session id
Before do reconnect, we should check the session id is null or not
Motivation and Context
Mcp session id is optional, if mcp server did not return mcp session id, we will get a null value. it will throw a MCP Session id missing exception.
How Has This Been Tested?
Build a mcp server, which not return mcp session id in response header.
Breaking Changes
No
Types of changes
Checklist
Additional context