langchain-ai/deepagents · error · RuntimeError

MCP server '{server_name}': missing 'command' in config.

Error message

MCP server '{server_name}': missing 'command' in config.

What it means

Stdio-based MCP servers are launched by executing the `command` from their config. `_check_stdio_server` raises this RuntimeError when the server config dict has no `command` key at all (value None), before any process is spawned. It's part of the connectivity/pre-flight check for stdio servers.

Source

Thrown at libs/code/deepagents_code/mcp_tools.py:1854

    except (json.JSONDecodeError, ValueError, TypeError) as exc:
        logger.warning("Skipping invalid MCP config %s: %s", config_path, exc)
        return None, str(exc)


def _check_stdio_server(server_name: str, server_config: dict[str, Any]) -> None:
    """Verify that a stdio server's command exists on PATH.

    Args:
        server_name: Server name for error messages.
        server_config: Validated server config.

    Raises:
        RuntimeError: If the command is missing or not found on PATH.
    """
    command = server_config.get("command")
    if command is None:
        msg = f"MCP server '{server_name}': missing 'command' in config."
        raise RuntimeError(msg)
    if shutil.which(command) is None:
        msg = (
            f"MCP server '{server_name}': configured command not found on PATH. "
            "Install it or check your MCP config."
        )
        raise RuntimeError(msg)


async def _check_remote_server(server_name: str, server_config: dict[str, Any]) -> None:
    """Check network connectivity to a remote MCP server URL.

    Args:
        server_name: Server name for error messages.
        server_config: Validated remote server config.

    Raises:
        RuntimeError: If the URL is missing, unreachable, or returns 5xx.
    """

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Add the 'command' key with the executable to launch, e.g. "command": "npx" plus "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"].
  2. If this server is actually remote, replace the stdio fields with a "url" entry so it's checked as a remote server instead.
  3. Replace any explicit null 'command' value with a real executable string.

Example fix

// before
{"mcpServers": {"fs": {"args": ["/tmp"]}}}
// after
{"mcpServers": {"fs": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]}}}
Defensive patterns

Strategy: validation

Validate before calling

def check_stdio_entry(server):
    if "url" not in server and "command" not in server:
        raise SystemExit("stdio MCP server config requires 'command'")

Type guard

def is_valid_stdio_entry(server: dict) -> bool:
    return isinstance(server.get("command"), str) and bool(server["command"])

Try / catch

try:
    check_mcp_servers(cfg)
except RuntimeError as e:
    if "missing 'command'" in str(e):
        add_command_field(cfg_path, server_name=...)
    else:
        raise

Prevention

When it happens

Trigger: A server entry under 'mcpServers' that only has fields like 'args'/'env'/'url' but no 'command', e.g. {"mcpServers": {"fs": {"args": ["/tmp"]}}}, or "command": null explicitly present.

Common situations: Copying a remote/HTTP server entry (which uses 'url') into a stdio slot without a command; hand-writing a config and forgetting the launch line; templates where the command was meant to be filled in.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/5863c3a2c3c9f078. Report an issue: GitHub.