{"record":{"id":"a0c1a26d4fd14b5a","repo":"FoundationAgents/OpenManus","slug":"server-command-is-required","errorCode":null,"errorMessage":"Server command is required.","messagePattern":"Server command is required\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"app/tool/mcp.py","lineNumber":76,"sourceCode":"        if server_id in self.sessions:\n            await self.disconnect(server_id)\n\n        exit_stack = AsyncExitStack()\n        self.exit_stacks[server_id] = exit_stack\n\n        streams_context = sse_client(url=server_url)\n        streams = await exit_stack.enter_async_context(streams_context)\n        session = await exit_stack.enter_async_context(ClientSession(*streams))\n        self.sessions[server_id] = session\n\n        await self._initialize_and_list_tools(server_id)\n\n    async def connect_stdio(\n        self, command: str, args: List[str], server_id: str = \"\"\n    ) -> None:\n        \"\"\"Connect to an MCP server using stdio transport.\"\"\"\n        if not command:\n            raise ValueError(\"Server command is required.\")\n\n        server_id = server_id or command\n\n        # Always ensure clean disconnection before new connection\n        if server_id in self.sessions:\n            await self.disconnect(server_id)\n\n        exit_stack = AsyncExitStack()\n        self.exit_stacks[server_id] = exit_stack\n\n        server_params = StdioServerParameters(command=command, args=args)\n        stdio_transport = await exit_stack.enter_async_context(\n            stdio_client(server_params)\n        )\n        read, write = stdio_transport\n        session = await exit_stack.enter_async_context(ClientSession(read, write))\n        self.sessions[server_id] = session\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/tool/mcp.py#L58-L94","documentation":"Raised by MCPClient.connect_stdio (app/tool/mcp.py:76) when the command argument is empty/None. Pure input validation before StdioServerParameters is built and before any AsyncExitStack/stdio_client context is entered — no subprocess is spawned when this fires.","triggerScenarios":"Calling `await mcp.connect_stdio('', args)` or `connect_stdio(None, [...])`; typically the command string comes from a config entry (e.g. {'command': '', 'args': [...]}) that was defined but left empty, or a key-name mismatch (e.g. 'cmd' vs 'command') yielding None.","commonSituations":"MCP server config files where a stdio server block omits or blanks the command field; JSON schema drift between the config format the app expects and what the user wrote; env-var indirection (${{MCP_CMD}}) resolving to empty.","solutions":["Fill in the actual executable in the server config (e.g. command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem']).","Validate the config block before connecting: check that server['command'] is a non-empty string and that the binary exists (shutil.which).","Fix key-name mismatches in the config source so 'command' is populated rather than silently defaulting to empty."],"exampleFix":"// before\nawait mcp.connect_stdio(cfg.get('command', ''), cfg.get('args', []))\n\n// after\ncmd = cfg.get('command')\nif not cmd or not shutil.which(cmd):\n    raise RuntimeError(f\"stdio MCP server misconfigured: command={cmd!r}\")\nawait mcp.connect_stdio(cmd, cfg.get('args', []))","handlingStrategy":"validation","validationCode":"cmd = server_cfg.get('command')\nif not cmd or not shutil.which(cmd):\n    raise RuntimeError(f\"stdio MCP server misconfigured: command={cmd!r}\")\nawait mcp.connect_stdio(cmd, server_cfg.get('args', []), server_id=sid)","typeGuard":"def is_stdio_command(c: str | None) -> bool:\n    return isinstance(c, str) and bool(c.strip()) and shutil.which(c) is not None","tryCatchPattern":"try:\n    await mcp.connect_stdio(cmd, args, server_id)\nexcept ValueError as e:\n    if 'Server command is required' in str(e):\n        fix_server_config(sid)\n    else:\n        raise","preventionTips":["Validate config blocks (command non-empty, binary resolvable) before any connect loop.","Cover config key names ('command' not 'cmd') with a schema check at load time.","Log which server_id failed so multi-server configs pinpoint the bad entry."],"tags":["mcp","validation","configuration","stdio"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}