Skip to content

Conversation

@findleyr
Copy link
Contributor

@findleyr findleyr commented Aug 7, 2025

First, make the simplifications described in #222. I don't know why we originally had such fine granularity of locking: perhaps we were going to execute 'oninitialized' callbacks.

Then actually fix the 'initialized' condition, by not setting the session as initialized until 'notifications/initialized' is actually received

Fixes #222
Fixes #225

Make the simplifications described in modelcontextprotocol#222. I don't know why we
originally had such fine granularity of locking: perhaps we were going
to execute 'oninitialized' callbacks.

Also update the TODO with a bit more information about jsonrpc2
behavior.

Fixes modelcontextprotocol#222
@findleyr findleyr requested a review from jba August 7, 2025 16:24
Update ServerSession so that the session is not marked as initialized
until 'notifications/initialized' is actually received from the client.

Include a new test of this lifecycle strictness.

Fixes modelcontextprotocol#225
@findleyr
Copy link
Contributor Author

findleyr commented Aug 7, 2025

PTAL, I included a second CL to actually fix the initialization condition.

@jba jba self-requested a review August 7, 2025 18:54
@findleyr findleyr merged commit 5ab63fe into modelcontextprotocol:main Aug 7, 2025
5 checks passed
@jba
Copy link
Contributor

jba commented Aug 7, 2025

So _initialized catches double initialization.
Does that need to be included in SessionState? I think so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp lifecycle: initialization phase is not completely followed Simplify ServerSession.initialize

2 participants