langchain-ai/deepagents · error · ValueError
Server '{server_name}' missing required 'command' field
Error message
Server '{server_name}' missing required 'command' field What it means
A stdio MCP server is launched as a local subprocess, so its config must specify the executable via the required `command` field. `_validate_server_config` raises this ValueError when a server resolves to type `stdio` but has no `command` key, because there is no way to start the server process.
Source
Thrown at libs/code/deepagents_code/mcp_tools.py:911
raise ValueError(error_msg)
headers = server_config.get("headers")
if headers is not None and not isinstance(headers, dict):
error_msg = f"Server '{server_name}' 'headers' must be a dictionary"
raise TypeError(error_msg)
if isinstance(headers, dict):
for name, value in headers.items():
if not isinstance(value, str):
error_msg = (
f"Server '{server_name}' header {name!r} must be "
f"a string, got {type(value).__name__}"
)
raise TypeError(error_msg)
elif server_type == "stdio":
if "command" not in server_config:
error_msg = f"Server '{server_name}' missing required 'command' field"
raise ValueError(error_msg)
if "url" in server_config:
error_msg = (
f"Server '{server_name}' has type 'stdio' but also declares "
"a 'url' field. Remove 'url' or set "
'`"type": "http"` (or `"sse"`) for a remote server.'
)
raise ValueError(error_msg)
if "args" in server_config and not isinstance(server_config["args"], list):
error_msg = f"Server '{server_name}' 'args' must be a list"
raise TypeError(error_msg)
if "env" in server_config and not isinstance(server_config["env"], dict):
error_msg = f"Server '{server_name}' 'env' must be a dictionary"
raise TypeError(error_msg)
else:
error_msg = (View on GitHub (pinned to a1af029e6e)
Solutions
- Add the required `command` field naming the executable, e.g. "command": "npx" or "command": "python".
- If the server is actually remote, set `"type": "http"` (or `"sse"`) and provide a `url` instead of `command`.
- Verify the server entry includes both `command` and any needed `args` list.
- Validate the corrected config with `resolve_and_load_mcp_tools` before reloading the app.
Example fix
// before
{"fetch": {"type": "stdio", "args": ["mcp-server-fetch"]}}
// after
{"fetch": {"type": "stdio", "command": "python", "args": ["-m", "mcp_server_fetch"]}} Defensive patterns
Strategy: validation
Validate before calling
def validate_stdio_entry(name: str, cfg: dict) -> None:
if cfg.get("type", "stdio") == "stdio" and "command" not in cfg:
raise ValueError(f"Server '{name}' missing required 'command' field") Type guard
def is_valid_stdio_entry(cfg: dict) -> bool:
return cfg.get("type", "stdio") == "stdio" and isinstance(cfg.get("command"), str) and bool(cfg["command"]) Try / catch
try:
tools = resolve_and_load_mcp_tools(config)
except ValueError as e:
if "missing required 'command' field" in str(e):
print(f"Fix config: {e}") # add command or switch type to http/sse with url
else:
raise Prevention
- Every stdio server entry must have a `command`; make this a checklist item when adding servers.
- Use templates: local servers start with {"type": "stdio", "command": ..., "args": [...]}.
- For remote servers, always set type http/sse explicitly so missing `command` is not ambiguous.
- Validate configs in CI before distribution.
When it happens
Trigger: Calling `select_server`, `resolve_and_load_mcp_tools`, or config validation with a server entry that resolves to stdio (explicit `"type": "stdio"` or omitted type defaulting to stdio) but lacks `command`, e.g. `{"myserver": {"args": ["-y", "@modelcontextprotocol/server-x"]}}`.
Common situations: Config entries copied from remote-server examples and left without `command`; type key renamed to something else so stdio defaulting kicks in; truncated config where the command line was deleted; YAML where `command:` is present but empty (parsing to None may still count as missing depending on the `in` check).
Related errors
- {prefix}.args must be a list, got {type(args).__name__}
- Server '{server_name}' has type 'stdio' but also declares a
- Server '{server_name}' 'args' must be a list
- Server '{server_name}' 'env' must be a dictionary
- Server '{server_name}' uses stdio transport; 'auth: oauth' i
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/baf1ff4216f1d6aa.
Report an issue: GitHub.