langchain-ai/deepagents · error · ValueError
Server ' ' cannot set both 'allowedTools' and…
Error message
Server '{server_name}' cannot set both 'allowedTools' and 'disabledTools' — pick one. What it means
deepagents_code MCP server configs let you filter which tools are exposed either with an allow-list (`allowedTools`) or a block-list (`disabledTools`), but not both at once. `_validate_tool_filter_fields` raises this ValueError during `_validate_server_config` when a single server entry defines both keys, because the combined semantics would be ambiguous. Fix the config so exactly one of the two fields is present per server.
Solutions
- Choose one filtering style for the server: keep 'allowedTools' (allow-list) and delete the 'disabledTools' key, or vice versa.
- If you need allow-list semantics with exclusions, move the excluded tools out of 'allowedTools' instead of listing them in 'disabledTools'.
- If the conflict comes from merged configs, ensure the merge is per-key (last-writer-wins) rather than concatenating keys into the same server dict.
Example fix
// before
{"mcpServers": {"fs": {"command": "mcp-server-fs", "allowedTools": ["read_file"], "disabledTools": ["write_file"]}}}
// after
{"mcpServers": {"fs": {"command": "mcp-server-fs", "allowedTools": ["read_file"]}}} Defensive patterns
Strategy: validation
Validate before calling
def check_tool_filter(server):
has_allowed = "allowedTools" in server
has_disabled = "disabledTools" in server
if has_allowed and has_disabled:
raise ValueError("set only one of allowedTools/disabledTools") Type guard
def has_conflicting_filters(server: dict) -> bool:
return "allowedTools" in server and "disabledTools" in server Try / catch
try:
load_mcp_config(path)
except ValueError as e:
if "cannot set both" in str(e):
fix_config_file(path) # drop one of the two keys
else:
raise Prevention
- Pick one filtering convention per project and document it in the config README.
- When merging configs, merge per-server dicts wholesale instead of key-by-key.
- Add a CI check that validates the MCP config schema before deployment.
When it happens
Trigger: Loading an MCP config (via _load_mcp_config_top_level -> _validate_server_config) where one server dict under 'mcpServers' contains both 'allowedTools' and 'disabledTools' keys, e.g. {"mcpServers": {"fs": {"command": "mcp-server-fs", "allowedTools": ["read_file"], "disabledTools": ["write_file"]}}}.
Common situations: Merging configs from two sources (project .mcp.json plus user config) where one set allowedTools and the other disabledTools; copy-pasting a server entry from docs that used allowedTools and appending a disabledTools exclusion; team members with different filtering conventions editing the same config file.
Related errors
- Server ' ' ' ' must be non-empty; omit the field to disable…
- Invalid MCP config at
- MCP config must contain 'mcpServers' field. Expected format
- MCP server ' ': missing 'command' in config.
- 'mcpServers' field is empty - no servers configured
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/b61c861e6b1e1017.
Report an issue: GitHub.
Appendix: source
Thrown at libs/code/deepagents_code/mcp_tools.py:988
(`disabledTools`) — both are almost certainly user errors; omit the field
instead.
Args:
server_name: Name of the server (for error messages).
server_config: Server configuration dictionary.
Raises:
TypeError: If a field is not a list of strings.
ValueError: If both fields are set, or either field is empty.
"""
has_allowed = "allowedTools" in server_config
has_disabled = "disabledTools" in server_config
if has_allowed and has_disabled:
error_msg = (
f"Server '{server_name}' cannot set both 'allowedTools' and"
" 'disabledTools' — pick one."
)
raise ValueError(error_msg)
for field_name in ("allowedTools", "disabledTools"):
if field_name not in server_config:
continue
value = server_config[field_name]
if not isinstance(value, list) or not all(
isinstance(item, str) for item in value
):
error_msg = (
f"Server '{server_name}' '{field_name}' must be a list of strings"
)
raise TypeError(error_msg)
if not value:
error_msg = (
f"Server '{server_name}' '{field_name}' must be non-empty;"
" omit the field to disable filtering."
)
raise ValueError(error_msg)View on GitHub (pinned to a1af029e6e)