Send a single ``server/discover`` at ``version`` and return the raw result dict. No retry, no ``adopt()``. The ``_meta`` envelope and the ``Mcp-Protocol-Version`` header are stamped at ``version`` so the server-side era router sees a coherent probe. Used by ``discover()`` an
(self, version: str)
| 404 | self._negotiated_version = result.protocol_version |
| 405 | |
| 406 | async def send_discover(self, version: str) -> dict[str, Any]: |
| 407 | """Send a single ``server/discover`` at ``version`` and return the raw result dict. |
| 408 | |
| 409 | No retry, no ``adopt()``. The ``_meta`` envelope and the |
| 410 | ``Mcp-Protocol-Version`` header are stamped at ``version`` so the |
| 411 | server-side era router sees a coherent probe. Used by ``discover()`` and |
| 412 | the connect-time auto-negotiation policy. |
| 413 | |
| 414 | Raises: |
| 415 | MCPError: The server returned a JSON-RPC error, or the transport |
| 416 | bounced the request at its own layer (a bare HTTP 4xx is |
| 417 | synthesized into a JSON-RPC error by the transport). |
| 418 | """ |
| 419 | client_info = self._client_info.model_dump(by_alias=True, mode="json", exclude_none=True) |
| 420 | capabilities = self._build_capabilities().model_dump(by_alias=True, mode="json", exclude_none=True) |
| 421 | request = types.DiscoverRequest( |
| 422 | params=types.RequestParams( |
| 423 | _meta={ |
| 424 | PROTOCOL_VERSION_META_KEY: version, |
| 425 | CLIENT_INFO_META_KEY: client_info, |
| 426 | CLIENT_CAPABILITIES_META_KEY: capabilities, |
| 427 | } |
| 428 | ) |
| 429 | ) |
| 430 | data = request.model_dump(by_alias=True, mode="json", exclude_none=True) |
| 431 | opts: CallOptions = { |
| 432 | "timeout": DISCOVER_TIMEOUT_SECONDS, |
| 433 | "cancel_on_abandon": False, |
| 434 | "headers": {MCP_PROTOCOL_VERSION_HEADER: version, MCP_METHOD_HEADER: data["method"]}, |
| 435 | } |
| 436 | return await self._dispatcher.send_raw_request(data["method"], data.get("params"), opts) |
| 437 | |
| 438 | async def discover(self) -> types.DiscoverResult: |
| 439 | """Probe `server/discover` and adopt the result. |
no test coverage detected