{"record":{"id":"226a29b1d3c15ea9","repo":"FoundationAgents/OpenManus","slug":"server-url-is-required-for-sse-connection","errorCode":null,"errorMessage":"Server URL is required for SSE connection","messagePattern":"Server URL is required for SSE connection","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"app/agent/mcp.py","lineNumber":61,"sourceCode":"        server_url: Optional[str] = None,\n        command: Optional[str] = None,\n        args: Optional[List[str]] = None,\n    ) -> None:\n        \"\"\"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","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/agent/mcp.py#L43-L79","documentation":"Raised by MCPSelfCorruptAgent.initialize() when the agent's connection_type is 'sse' but the server_url argument is empty/None. The SSE transport requires an explicit http(s) endpoint to connect to, unlike stdio which launches a local command. The check is a plain falsy test, so empty strings also trigger it.","triggerScenarios":"Calling agent.initialize(connection_type=\"sse\") or initialize(connection_type=\"sse\", server_url=\"\") or omitting server_url while the agent was previously constructed with connection_type=\"sse\". The stored self.connection_type wins whenever the passed connection_type is falsy.","commonSituations":"Copying a stdio MCP config and switching type to \"sse\" without adding a url; reading config from config.toml mcpServers where url key is missing; passing server_url=None as a default argument.","solutions":["Pass a valid server_url, e.g. await agent.initialize(connection_type=\"sse\", server_url=\"http://localhost:8080/sse\")","If loading from config, verify the mcpServers.<id>.url key exists and is non-empty before calling initialize","Confirm connection_type matches the transport you actually have parameters for (use \"stdio\" with command/args instead)"],"exampleFix":"// before\nawait agent.initialize(connection_type=\"sse\")  # ValueError\n\n// after\nawait agent.initialize(connection_type=\"sse\", server_url=\"http://localhost:8080/sse\")","handlingStrategy":"validation","validationCode":"def valid_sse_params(connection_type: str, server_url: str | None) -> bool:\n    return connection_type == \"sse\" and bool(server_url and server_url.strip())","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build a small config validator that checks type/url/command consistency for every mcpServers entry before agent startup","Treat empty string and None identically when validating url fields","Log the resolved connection_type and server_url (redacted) right before initialize()"],"tags":["mcp","configuration","validation"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}