feat(client): store InitializeResult as initialize_result (#2300)
This commit is contained in:
parent
67201a9bbd
commit
20dd94632e
1 changed files with 64 additions and 37 deletions
|
|
@ -131,7 +131,7 @@ class ClientSession(
|
|||
self._logging_callback = logging_callback or _default_logging_callback
|
||||
self._message_handler = message_handler or _default_message_handler
|
||||
self._tool_output_schemas: dict[str, dict[str, Any] | None] = {}
|
||||
self._server_capabilities: types.ServerCapabilities | None = None
|
||||
self._initialize_result: types.InitializeResult | None = None
|
||||
self._experimental_features: ExperimentalClientFeatures | None = None
|
||||
|
||||
# Experimental: Task handlers (use defaults if not provided)
|
||||
|
|
@ -185,18 +185,19 @@ class ClientSession(
|
|||
if result.protocol_version not in SUPPORTED_PROTOCOL_VERSIONS:
|
||||
raise RuntimeError(f"Unsupported protocol version from the server: {result.protocol_version}")
|
||||
|
||||
self._server_capabilities = result.capabilities
|
||||
self._initialize_result = result
|
||||
|
||||
await self.send_notification(types.InitializedNotification())
|
||||
|
||||
return result
|
||||
|
||||
def get_server_capabilities(self) -> types.ServerCapabilities | None:
|
||||
"""Return the server capabilities received during initialization.
|
||||
@property
|
||||
def initialize_result(self) -> types.InitializeResult | None:
|
||||
"""The server's InitializeResult. None until initialize() has been called.
|
||||
|
||||
Returns None if the session has not been initialized yet.
|
||||
Contains server_info, capabilities, instructions, and the negotiated protocol_version.
|
||||
"""
|
||||
return self._server_capabilities
|
||||
return self._initialize_result
|
||||
|
||||
@property
|
||||
def experimental(self) -> ExperimentalClientFeatures:
|
||||
|
|
|
|||
Loading…
Reference in a new issue