langchain-ai/deepagents · error · ValueError
Server '{server_name}' has type '{server_type}' (remote) but
Error message
Server '{server_name}' has type '{server_type}' (remote) but also declares a 'command' field. Remove 'command' or set `"type": "stdio"`. What it means
A server whose resolved type is remote must not declare a 'command' field; that field is exclusive to stdio servers. The error tells the user to remove 'command' or switch the type to stdio.
Source
Thrown at libs/code/deepagents_code/mcp_tools.py:893
raise TypeError(error_msg)
server_type = _resolve_server_type(server_config)
if server_type in _SUPPORTED_REMOTE_TYPES:
if "url" not in server_config:
error_msg = (
f"Server '{server_name}' with type '{server_type}' "
"missing required 'url' field"
)
raise ValueError(error_msg)
if "command" in server_config:
error_msg = (
f"Server '{server_name}' has type '{server_type}' (remote) "
"but also declares a 'command' field. Remove 'command' or "
'set `"type": "stdio"`.'
)
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)View on GitHub (pinned to a1af029e6e)
Solutions
- Remove the 'command' (and 'args') fields from the remote server entry
- Set "type": "stdio" instead if the server is launched locally via command
- Re-run validation after editing to confirm the config is clean
Example fix
// before
{"api": {"type": "http", "url": "https://mcp.example.com", "command": "npx"}}
// after
{"api": {"type": "http", "url": "https://mcp.example.com"}} Defensive patterns
Strategy: validation
Validate before calling
def remote_entry_clean(cfg: dict) -> bool:
if cfg.get('type') in ('http', 'sse', 'streamable-http'):
return 'command' not in cfg
return True Try / catch
try:
tools = await resolve_and_load_mcp_tools(config)
except ValueError as e:
if "declares a 'command' field" in str(e):
log.error('remote server must not define command: %s', e)
raise Prevention
- When converting stdio -> remote, delete 'command'/'args' in the same edit
- Strip transport-specific keys per type before passing configs
- Lint MCP config files to forbid command+url together
When it happens
Trigger: Config mixing remote fields (type: http/sse + url) with a leftover 'command' key; converting a stdio entry to remote without deleting 'command'.
Common situations: Editing an existing stdio entry to point at a remote URL while keeping the launch command; merging two config files that define the same server differently.
Related errors
- Invalid MCP server name {server_name!r}: token storage names
- MCPServerInfo {self.name!r}: status={self.status!r} cannot c
- Server '{server_name}' config must be a dictionary
- Server '{server_name}' with type '{server_type}' missing req
- {what} must be absolute: {path}
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/ae9b0c7ab86c0a15.
Report an issue: GitHub.