{"record":{"id":"6ee156fa4ae658ea","repo":"crewAIInc/crewAI","slug":"mcp-server-not-started-run-mcp-server-start-f","errorCode":null,"errorMessage":"MCP server not started, run `mcp_server.start()` first before accessing `tools`","messagePattern":"MCP server not started, run `mcp_server\\.start\\(\\)` first before accessing `tools`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/adapters/mcp_adapter.py","lineNumber":211,"sourceCode":"        \"\"\"Start the MCP server and initialize the tools.\"\"\"\n        self._tools = self._adapter.__enter__()  # type: ignore[union-attr]\n\n    def stop(self) -> None:\n        \"\"\"Stop the MCP server.\"\"\"\n        self._adapter.__exit__(None, None, None)  # type: ignore[union-attr]\n\n    @property\n    def tools(self) -> ToolCollection[BaseTool]:\n        \"\"\"The CrewAI tools available from the MCP server.\n\n        Raises:\n            ValueError: If the MCP server is not started.\n\n        Returns:\n            The CrewAI tools available from the MCP server.\n        \"\"\"\n        if self._tools is None:\n            raise ValueError(\n                \"MCP server not started, run `mcp_server.start()` first before accessing `tools`\"\n            )\n\n        tools_collection = ToolCollection(self._tools)\n        if self._tool_names:\n            return tools_collection.filter_by_names(self._tool_names)\n        return tools_collection\n\n    def __enter__(self) -> ToolCollection[BaseTool]:\n        \"\"\"Enter the context manager.\n\n        Note that `__init__()` already starts the MCP server,\n        so tools should already be available.\n        \"\"\"\n        return self.tools\n\n    def __exit__(\n        self,","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/adapters/mcp_adapter.py#L193-L229","documentation":"Raised by the `tools` property of MCPServerAdapt when the internal `self._tools` is still None, meaning `start()` was never called or did not complete. The constructor normally starts the server automatically, so this mainly surfaces after a failed init path or when the object was constructed in a state where start did not run.","triggerScenarios":"Accessing `mcp_server.tools` before the server started — e.g. an object created when __init__ caught an exception path left _tools None, or a manually crafted/half-initialized instance where start() was skipped. The property checks `if self._tools is None` and raises ValueError.","commonSituations":"Using the adapter as a context manager but accessing `.tools` after an exception was swallowed, or subclassing/reconstructing MCPServerAdapt without calling start(). Also seen when init partially failed and the caller ignores the error then reads .tools.","solutions":["Call `mcp_server.start()` before reading `mcp_server.tools`.","Prefer the context-manager form (`with MCPServerAdapt(...) as tools:`) so __enter__ guarantees a started server.","If init previously failed, fix the underlying init error first (see 'Failed to initialize MCP Adapter') — a stopped server has no tools."],"exampleFix":"# before\nserver = MCPServerAdapt(params)\nprint(server.tools)  # ValueError if not started\n\n# after\nserver = MCPServerAdapt(params)\nserver.start()\nprint(server.tools)","handlingStrategy":"validation","validationCode":"def get_tools(server):\n    if getattr(server, \"_tools\", None) is None:\n        server.start()  # idempotent enough via __enter__\n    return server.tools","typeGuard":"def is_started(server) -> bool:\n    return server._tools is not None","tryCatchPattern":"try:\n    tools = server.tools\nexcept ValueError:\n    server.start()\n    tools = server.tools","preventionTips":["Prefer `with MCPServerAdapt(...) as tools:` so .tools is always populated.","Never swallow exceptions from the MCPServerAdapt constructor — a half-initialized server has no tools.","Check `server._tools is not None` (or call start()) before reading .tools."],"tags":["mcp","lifecycle","state","crewai-tools"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}