{"record":{"id":"fbf5e4acfa49eb5c","repo":"langchain-ai/deepagents","slug":"mcpserverinfo-self-name-r-status-self-status-r-fbf5e4","errorCode":null,"errorMessage":"MCPServerInfo {self.name!r}: status={self.status!r} cannot carry tools","messagePattern":"MCPServerInfo (.+?): status=(.+?) cannot carry tools","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/mcp_tools.py","lineNumber":191,"sourceCode":"            if self.error is not None:\n                msg = (\n                    f\"MCPServerInfo {self.name!r}: status='ok' cannot carry \"\n                    f\"an error (got {self.error!r})\"\n                )\n                raise ValueError(msg)\n        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","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/mcp_tools.py#L173-L209","documentation":"MCPServerInfo is a dataclass whose __post_init__ enforces state invariants. A server whose status is not a live/connectable state (e.g. 'disabled' or 'unauthenticated') must not be constructed with a non-empty tools list, because tools from a non-functional server are meaningless or misleading.","triggerScenarios":"Constructing or rebuilding MCPServerInfo (directly or via from-config/load paths) with status set to 'disabled'/'unauthenticated'/similar while passing a non-empty tools list.","commonSituations":"Persisting a server snapshot to disk and restoring it with stale tools attached; UI code caching tools across a status change to disabled; merging config state with previously loaded tool lists.","solutions":["Clear the tools list when the server status is not live (set tools=[])","Set status to a live state only after tools have actually been loaded","Check status before constructing MCPServerInfo and drop stale tools"],"exampleFix":"// before\nMCPServerInfo(name='fs', status='disabled', tools=[tool_a])\n// after\nMCPServerInfo(name='fs', status='disabled', tools=[])","handlingStrategy":"validation","validationCode":"def can_carry_tools(info) -> bool:\n    return info.status not in ('disabled', 'unauthenticated')\n# before constructing: tools=tools if can_live else []","typeGuard":"def is_live_server(info: MCPServerInfo) -> bool:\n    return info.status == 'connected'","tryCatchPattern":"try:\n    info = MCPServerInfo(name=name, status=status, tools=tools)\nexcept ValueError as e:\n    log.warning('dropping tools for non-live server: %s', e)\n    info = MCPServerInfo(name=name, status=status, tools=[])","preventionTips":["Derive tools from live connections only; never persist tools alongside status snapshots","Add a helper constructor that clears tools for non-live statuses","Assert status/tools invariants in serialization round-trip tests"],"tags":["mcp","validation","configuration"],"backgroundTag":"invalid-state-construction","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}