{"record":{"id":"de5b399b60aedffd","repo":"PrefectHQ/fastmcp","slug":"the-client-negotiated-a-modern-protocol-era-serve","errorCode":null,"errorMessage":"The client negotiated a modern protocol era (server/discover), which has no InitializeResult. Inspect client.protocol_version, client.server_info, client.server_capabilities, and client.instructions for the metadata available in this mode, or construct the client with mode='legacy'.","messagePattern":"The client negotiated a modern protocol era \\(server/discover\\), which has no InitializeResult\\. Inspect client\\.protocol_version, client\\.server_info, client\\.server_capabilities, and client\\.instructions for the metadata available in this mode, or construct the client with mode='legacy'\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/client/client.py","lineNumber":940,"sourceCode":"\n        Example:\n            ```python\n            # With auto-initialization disabled\n            client = Client(server, auto_initialize=False)\n            async with client:\n                result = await client.initialize()\n                print(f\"Server: {result.server_info.name}\")\n                print(f\"Instructions: {result.instructions}\")\n            ```\n        \"\"\"\n\n        if self.initialize_result is not None:\n            return self.initialize_result\n\n        await self._negotiate(timeout=timeout)\n\n        if self.initialize_result is None:\n            raise RuntimeError(\n                \"The client negotiated a modern protocol era (server/discover), which has \"\n                \"no InitializeResult. Inspect client.protocol_version, client.server_info, \"\n                \"client.server_capabilities, and client.instructions for the metadata \"\n                \"available in this mode, or construct the client with mode='legacy'.\"\n            )\n        return self.initialize_result\n\n    async def __aenter__(self):\n        return await self._connect()\n\n    async def __aexit__(self, exc_type, exc_val, exc_tb):\n        await self._disconnect()\n\n    async def _connect(self):\n        \"\"\"\n        Establish or reuse a session connection.\n\n        This method implements the reentrant context manager pattern:","sourceCodeStart":922,"sourceCodeEnd":958,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/client/client.py#L922-L958","documentation":"In the modern protocol era ('server/discover' mode) there is no MCP InitializeResult; connection metadata lives in client.protocol_version, client.server_info, client.server_capabilities, and client.instructions instead. Calling `client.initialize()` after such a negotiation raises this RuntimeError, pointing you at those attributes or to legacy mode.","triggerScenarios":"Creating `Client(..., mode='server')` (modern mode) and then awaiting `client.initialize()`; calling initialize() on a client whose auto-negotiation selected a modern protocol version (MCP 2026-07-28).","commonSituations":"Legacy initialize-flow code reused with a modern-mode client; reading initialize_result for server capabilities in a codebase migrated to the new protocol era.","solutions":["Use client.protocol_version / client.server_info / client.server_capabilities / client.instructions instead of initialize_result","Construct the client with mode='legacy' if you need the classic InitializeResult","Branch on protocol_version and handle the modern-mode metadata path"],"exampleFix":"// before\nasync with client:\n    info = await client.initialize()  # RuntimeError in modern mode\n\n// after\nasync with client:\n    info = client.server_info  # or: Client(transport, mode='legacy') then initialize()","handlingStrategy":"fallback","validationCode":"def uses_legacy_initialize(client) -> bool:\n    return client.protocol_version not in MODERN_PROTOCOL_VERSIONS","typeGuard":"def has_initialize_result(client) -> bool:\n    return client.initialize_result is not None","tryCatchPattern":"try:\n    info = await client.initialize()\nexcept RuntimeError as e:\n    if \"modern protocol era\" in str(e):\n        info = client.server_info\n    else:\n        raise","preventionTips":["Read metadata from client.server_info/capabilities/instructions in modern mode","Pin mode='legacy' when porting legacy initialize-based code","Branch on client.protocol_version before calling initialize()"],"tags":["python","protocol","mcp","api-migration"],"backgroundTag":"api-not-available-in-protocol-mode","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}