{"record":{"id":"b5f7b5ccfd0f9aed","repo":"FoundationAgents/OpenManus","slug":"command-is-required-for-stdio-connection","errorCode":null,"errorMessage":"Command is required for stdio connection","messagePattern":"Command is required for stdio connection","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"app/agent/mcp.py","lineNumber":65,"sourceCode":"        \"\"\"Initialize the MCP connection.\n\n        Args:\n            connection_type: Type of connection to use (\"stdio\" or \"sse\")\n            server_url: URL of the MCP server (for SSE connection)\n            command: Command to run (for stdio connection)\n            args: Arguments for the command (for stdio connection)\n        \"\"\"\n        if connection_type:\n            self.connection_type = connection_type\n\n        # Connect to the MCP server based on connection type\n        if self.connection_type == \"sse\":\n            if not server_url:\n                raise ValueError(\"Server URL is required for SSE connection\")\n            await self.mcp_clients.connect_sse(server_url=server_url)\n        elif self.connection_type == \"stdio\":\n            if not command:\n                raise ValueError(\"Command is required for stdio connection\")\n            await self.mcp_clients.connect_stdio(command=command, args=args or [])\n        else:\n            raise ValueError(f\"Unsupported connection type: {self.connection_type}\")\n\n        # Set available_tools to our MCP instance\n        self.available_tools = self.mcp_clients\n\n        # Store initial tool schemas\n        await self._refresh_tools()\n\n        # Add system message about available tools\n        tool_names = list(self.mcp_clients.tool_map.keys())\n        tools_info = \", \".join(tool_names)\n\n        # Add system prompt and available tools information\n        self.memory.add_message(\n            Message.system_message(\n                f\"{self.system_prompt}\\n\\nAvailable MCP tools: {tools_info}\"","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/agent/mcp.py#L47-L83","documentation":"Raised by MCPSelfCorruptAgent.initialize() when connection_type is \"stdio\" but the command argument is empty/None. The stdio transport needs an executable to spawn the MCP server locally; without it there is nothing to run. Note args defaults to [] so only command is mandatory.","triggerScenarios":"Calling initialize(connection_type=\"stdio\") with no command, or initialize(connection_type=\"stdio\", command=\"\") or command=None. Also happens when a stored connection_type of \"stdio\" persists and a later initialize() call omits command.","commonSituations":"Config entry mcpServers.<id> has type=\"stdio\" but command key missing; typo like \"cmd\" or \"executable\" instead of \"command\"; assuming the agent remembers the command from a prior call.","solutions":["Pass a valid command, e.g. await agent.initialize(connection_type=\"stdio\", command=\"npx\", args=[\"-y\", \"@modelcontextprotocol/server-filesystem\", \"/tmp\"])","Validate config: ensure server_config[\"command\"] is present when type == \"stdio\" before constructing the agent","Switch to connection_type=\"sse\" with server_url if the server is remote"],"exampleFix":"// before\nawait agent.initialize(connection_type=\"stdio\", args=[\"-y\", \"server-pkg\"])\n\n// after\nawait agent.initialize(connection_type=\"stdio\", command=\"npx\", args=[\"-y\", \"server-pkg\"])","handlingStrategy":"validation","validationCode":"def valid_stdio_params(connection_type: str, command: str | None) -> bool:\n    return connection_type == \"stdio\" and bool(command and command.strip())","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Schema-check MCP config files: stdio entries require command, sse entries require url","Prefer defining a pydantic model for server config so missing keys fail with precise messages at load time","Do not rely on prior initialize() calls — pass the full parameter set each time"],"tags":["mcp","configuration","validation","stdio"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}