feat(client): store full InitializeResult as server_params#2300
Draft
feat(client): store full InitializeResult as server_params#2300
Conversation
ClientSession now stores the complete InitializeResult via a server_params property, mirroring ServerSession.client_params. This provides access to server_info, capabilities, instructions, and the negotiated protocol_version through a single, future-proof property. Previously, only capabilities were stored (via _server_capabilities) and users had no access to server_info, instructions, or protocol_version after initialize() returned — they had to manually capture the return value. get_server_capabilities() and Client.server_capabilities have been removed. Github-Issue: #1018
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.
ClientSessionnow stores the fullInitializeResultvia aserver_paramsproperty, mirroringServerSession.client_params. This provides access toserver_info,capabilities,instructions, and the negotiatedprotocol_versionthrough a single property.Closes #1018. Supersedes #1565 and #2211.
Motivation and Context
Previously,
ClientSessiondestructured onlyresult.capabilitiesinto_server_capabilitiesand exposed it viaget_server_capabilities(). The other threeInitializeResultfields (server_info,instructions,protocol_version) were discarded — users had to manually capture the return value ofinitialize(), which the high-levelClient.__aenter__throws away.This PR aligns the client side with the pattern
ServerSessionalready uses: store the whole params object, expose via a single property.ServerSession(existing)ClientSession(this PR)InitializeRequestParamsInitializeResultclient_paramsserver_paramssession.client_params.capabilitiessession.server_params.capabilitiesThe Go SDK, Rust SDK, and FastMCP all store the full init result; TS/C# destructure into per-field getters. This PR follows the same-codebase server-side precedent rather than cross-SDK mimicry.
How Has This Been Tested?
test_server_paramsassertsNonebefore init and all four fields (server_info,capabilities,instructions,protocol_version) aftertest_client_is_initializedupdated to useclient.server_params.capabilities./scripts/test— 100% coverage, all passpyright— 0 errorsBreaking Changes
ClientSession.get_server_capabilities()removed → usesession.server_params.capabilitiesClient.server_capabilitiesremoved → useclient.server_params.capabilitiesMigration entry added to
docs/migration.mdunder Breaking Changes, grouped with the otherClientSessionchanges.Types of changes
Checklist
Additional context
Why
server_paramsand notinitialize_result? The server side saysclient_params, notinitialize_request_params— the name describes what the data is (the server's params), not which RPC produced it. FastMCP usesinitialize_result, but FastMCP is an external wrapper; it doesn't need to match our internal server↔client naming.Why remove rather than deprecate? v2 rework —
mainis the clean-break branch. Carrying@deprecatedshims into v2 means shipping with already-deprecated APIs.AI Disclaimer