FoundationAgents/OpenManus · warning · ValueError

Server command is required.

Error message

Server command is required.

What it means

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.

Source

Thrown at app/tool/mcp.py:76

        if server_id in self.sessions:
            await self.disconnect(server_id)

        exit_stack = AsyncExitStack()
        self.exit_stacks[server_id] = exit_stack

        streams_context = sse_client(url=server_url)
        streams = await exit_stack.enter_async_context(streams_context)
        session = await exit_stack.enter_async_context(ClientSession(*streams))
        self.sessions[server_id] = session

        await self._initialize_and_list_tools(server_id)

    async def connect_stdio(
        self, command: str, args: List[str], server_id: str = ""
    ) -> None:
        """Connect to an MCP server using stdio transport."""
        if not command:
            raise ValueError("Server command is required.")

        server_id = server_id or command

        # Always ensure clean disconnection before new connection
        if server_id in self.sessions:
            await self.disconnect(server_id)

        exit_stack = AsyncExitStack()
        self.exit_stacks[server_id] = exit_stack

        server_params = StdioServerParameters(command=command, args=args)
        stdio_transport = await exit_stack.enter_async_context(
            stdio_client(server_params)
        )
        read, write = stdio_transport
        session = await exit_stack.enter_async_context(ClientSession(read, write))
        self.sessions[server_id] = session

View on GitHub (pinned to 52a13f2a57)

Solutions

  1. Fill in the actual executable in the server config (e.g. command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem']).
  2. Validate the config block before connecting: check that server['command'] is a non-empty string and that the binary exists (shutil.which).
  3. Fix key-name mismatches in the config source so 'command' is populated rather than silently defaulting to empty.

Example fix

// before
await mcp.connect_stdio(cfg.get('command', ''), cfg.get('args', []))

// after
cmd = cfg.get('command')
if not cmd or not shutil.which(cmd):
    raise RuntimeError(f"stdio MCP server misconfigured: command={cmd!r}")
await mcp.connect_stdio(cmd, cfg.get('args', []))
Defensive patterns

Strategy: validation

Validate before calling

cmd = server_cfg.get('command')
if not cmd or not shutil.which(cmd):
    raise RuntimeError(f"stdio MCP server misconfigured: command={cmd!r}")
await mcp.connect_stdio(cmd, server_cfg.get('args', []), server_id=sid)

Type guard

def is_stdio_command(c: str | None) -> bool:
    return isinstance(c, str) and bool(c.strip()) and shutil.which(c) is not None

Try / catch

try:
    await mcp.connect_stdio(cmd, args, server_id)
except ValueError as e:
    if 'Server command is required' in str(e):
        fix_server_config(sid)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15). Data as JSON: /api/errors/a0c1a26d4fd14b5a. Report an issue: GitHub.