{"record":{"id":"077ad296436bbc40","repo":"FoundationAgents/OpenManus","slug":"unsupported-connection-type-self-connection-type","errorCode":null,"errorMessage":"Unsupported connection type: {self.connection_type}","messagePattern":"Unsupported connection type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"app/agent/mcp.py","lineNumber":68,"sourceCode":"            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}\"\n            )\n        )\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/agent/mcp.py#L50-L86","documentation":"Raised by MCPSelfCorruptAgent.initialize() when self.connection_type is neither \"sse\" nor \"stdio\". Because initialize() only overwrites self.connection_type when the argument is truthy, a stale or misspelled stored value (e.g. \"SSE\", \"http\", \"\") also lands here. The message interpolates the offending value so you can see exactly what was rejected.","triggerScenarios":"initialize(connection_type=\"websocket\"), connection_type=\"SSE\" (case-sensitive), or calling initialize() with no arguments after constructing the agent with a default/invalid connection_type. Any leftover self.connection_type set to something other than the two literals triggers it.","commonSituations":"Newer MCP transports (streamable-http, websocket) not supported by this version; config type field typo like \"Stdio\" or \"sse2\"; case mismatch between config value and the literals compared in code.","solutions":["Set connection_type to exactly \"sse\" or \"stdio\" (lowercase)","Normalize/validate the value in your config loader before passing it in (strip whitespace, lower())","If you need another transport, upgrade the library or extend this initialize() branch to handle it"],"exampleFix":"// before\nawait agent.initialize(connection_type=\"SSE\", server_url=url)  # Unsupported connection type: SSE\n\n// after\nawait agent.initialize(connection_type=\"sse\", server_url=url)","handlingStrategy":"type-guard","validationCode":"SUPPORTED_CONNECTION_TYPES = {\"sse\", \"stdio\"}\n\ndef is_supported_connection_type(t: str | None) -> bool:\n    return isinstance(t, str) and t.strip().lower() in SUPPORTED_CONNECTION_TYPES","typeGuard":"from typing import TypeGuard\n\nSUPPORTED = {\"sse\", \"stdio\"}\n\ndef is_connection_type(value: object) -> TypeGuard[str]:\n    return isinstance(value, str) and value in SUPPORTED","tryCatchPattern":"try:\n    await agent.initialize(connection_type=ctype, server_url=url, command=cmd)\nexcept ValueError as e:\n    if \"Unsupported connection type\" in str(e):\n        logger.error(\"Bad MCP transport %r; supported: sse, stdio\", ctype)\n        raise SystemExit(2) from e\n    raise","preventionTips":["Normalize config values with .strip().lower() before passing connection_type","Keep the accepted set ({\"sse\", \"stdio\"}) in one shared constant used by both loader and caller","Add a startup assert on config-derived enums so bad values fail fast at boot, not mid-run"],"tags":["mcp","configuration","enum","validation"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}