(self)
| 351 | return types.ClientCapabilities(sampling=sampling, elicitation=elicitation, experimental=None, roots=roots) |
| 352 | |
| 353 | async def initialize(self) -> types.InitializeResult: |
| 354 | if self._initialize_result is not None: |
| 355 | return self._initialize_result |
| 356 | result = await self.send_request( |
| 357 | types.InitializeRequest( |
| 358 | params=types.InitializeRequestParams( |
| 359 | protocol_version=LATEST_HANDSHAKE_VERSION, |
| 360 | capabilities=self._build_capabilities(), |
| 361 | client_info=self._client_info, |
| 362 | ), |
| 363 | ), |
| 364 | types.InitializeResult, |
| 365 | ) |
| 366 | |
| 367 | if result.protocol_version not in HANDSHAKE_PROTOCOL_VERSIONS: |
| 368 | raise RuntimeError(f"Unsupported protocol version from the server: {result.protocol_version}") |
| 369 | |
| 370 | self.adopt(result) |
| 371 | |
| 372 | await self.send_notification(types.InitializedNotification()) |
| 373 | |
| 374 | return result |
| 375 | |
| 376 | def adopt(self, result: types.InitializeResult | types.DiscoverResult) -> None: |
| 377 | """Install negotiated state from a result the caller already holds (no wire traffic). |
no test coverage detected