fix: reject changed duplicate initialize#2606
Conversation
This comment was marked as abuse.
This comment was marked as abuse.
|
Rebased this PR onto the current runner/connection architecture instead of keeping the old Validation:
|
f77411a to
f96c27e
Compare
f96c27e to
74ae395
Compare
|
Rebased onto current |
|
Bumping this. A second initialize with changed params can still shift session state after the handshake, so rejecting the changed duplicate keeps initialization once-only per the spec. Rebases cleanly on main if there is interest. |
Summary
initializerequest if it tries to change the session's client parametersclient_paramsintact so later capability checks cannot be spoofed by a duplicate handshakeTo verify
uv run pytest tests/server/test_session.py -q -k "duplicate_initialize or server_session_initialize"uv run ruff check src/mcp/server/session.py tests/server/test_session.pyuv run pyright src/mcp/server/session.py tests/server/test_session.pyuv run python -m py_compile src/mcp/server/session.py tests/server/test_session.pygit diff --checkCloses #2605