{"record":{"id":"71d39d62ba3ddebc","repo":"langchain-ai/deepagents","slug":"mcpserverinfo-self-name-r-pending-reconnect-req","errorCode":null,"errorMessage":"MCPServerInfo {self.name!r}: pending_reconnect requires status='disabled' (got {self.status!r})","messagePattern":"MCPServerInfo (.+?): pending_reconnect requires status='disabled' \\(got (.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/mcp_tools.py","lineNumber":197,"sourceCode":"        else:\n            if self.error is None:\n                msg = (\n                    f\"MCPServerInfo {self.name!r}: status={self.status!r} \"\n                    \"requires an error message\"\n                )\n                raise ValueError(msg)\n            if self.tools:\n                msg = (\n                    f\"MCPServerInfo {self.name!r}: status={self.status!r} \"\n                    \"cannot carry tools\"\n                )\n                raise ValueError(msg)\n        if self.pending_reconnect and self.status != \"disabled\":\n            msg = (\n                f\"MCPServerInfo {self.name!r}: pending_reconnect requires \"\n                f\"status='disabled' (got {self.status!r})\"\n            )\n            raise ValueError(msg)\n\n    def needs_attention(self) -> bool:\n        \"\"\"Return whether this server is blocked on user login.\"\"\"\n        return self.status == \"unauthenticated\"\n\n\n_SUPPORTED_REMOTE_TYPES = {\"sse\", \"http\"}\n\"\"\"Supported transport types for remote MCP servers (SSE and HTTP).\"\"\"\n\n_TRANSPORT_ALIASES = {\"streamable_http\": \"http\", \"streamable-http\": \"http\"}\n\"\"\"Aliases that normalize to canonical transport names.\n\nThe MCP spec and `langchain_mcp_adapters` use `streamable_http` for what the\napp calls `http`. Accept both so users copy-pasting from upstream docs don't\nhit a validation error.\n\"\"\"\n\n","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/mcp_tools.py#L179-L215","documentation":"MCPServerInfo.__post_init__ requires that a server flagged pending_reconnect has status exactly 'disabled'. pending_reconnect marks a server awaiting user action; any other status is an inconsistent state the library refuses to construct.","triggerScenarios":"Creating MCPServerInfo with pending_reconnect=True and status other than 'disabled' (e.g. 'connected', 'unauthenticated', 'error').","commonSituations":"State machine code that toggles pending_reconnect after updating status; deserializing persisted server state where status and the reconnect flag drifted apart.","solutions":["Set status='disabled' whenever pending_reconnect=True","Clear pending_reconnect (False) if the server should stay in another status","Reconstruct the object from current live state instead of patching one field"],"exampleFix":"// before\nMCPServerInfo(name='gh', status='connected', pending_reconnect=True)\n// after\nMCPServerInfo(name='gh', status='disabled', pending_reconnect=True)","handlingStrategy":"validation","validationCode":"assert not (pending_reconnect and status != 'disabled'), 'pending_reconnect requires status=disabled'","typeGuard":"def is_reconnect_pending(info: MCPServerInfo) -> bool:\n    return info.pending_reconnect and info.status == 'disabled'","tryCatchPattern":"try:\n    info = MCPServerInfo(name=name, status=status, pending_reconnect=pending)\nexcept ValueError as e:\n    log.error('inconsistent MCPServerInfo: %s', e)\n    raise","preventionTips":["Update status and pending_reconnect together via a single state-transition helper","Rebuild MCPServerInfo from source-of-truth state instead of mutating fields","Test state transitions (connected -> disabled+pending) explicitly"],"tags":["mcp","validation","state-management"],"backgroundTag":"invalid-state-construction","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}