agentscope-ai/agentscope · error · ValueError
Disable tools should be a list of strings, but got {self.dis
Error message
Disable tools should be a list of strings, but got {self.disable_tools}. What it means
Same validation as enable_tools but for disable_tools: it must be None or a list of strings. Any other shape (bare string, set, list with non-string elements) raises this ValueError in model_post_init.
Source
Thrown at src/agentscope/mcp/_mcp_client.py:149
raise ValueError(
"STDIO MCP must be stateful (is_stateful=True).",
)
# Check arguments for self.enable_tools and disable_tools
if self.enable_tools is not None:
if not isinstance(self.enable_tools, list) or any(
not isinstance(_, str) for _ in self.enable_tools
):
raise ValueError(
"Enable tools should be a list of strings, but got "
f"{self.enable_tools}.",
)
if self.disable_tools is not None:
if not isinstance(self.disable_tools, list) or any(
not isinstance(_, str) for _ in self.disable_tools
):
raise ValueError(
"Disable tools should be a list of strings, but got "
f"{self.disable_tools}.",
)
if self.enable_tools is not None and self.disable_tools is not None:
intersection = set(self.enable_tools).intersection(
set(self.disable_tools),
)
if len(intersection) != 0:
raise ValueError(
f"The tools in enable_tools and disable_tools "
f"should not overlap, but got {intersection}.",
)
# Initialize the underlying client
self._initialize_client()
def _initialize_client(self) -> None:View on GitHub (pinned to e90f1c7592)
Solutions
- Use a list of strings: disable_tools=["dangerous_tool"]
- Normalize config values (list(map(str, ...))) before constructing the client
Example fix
// before client = MCPClient(name="fs", mcp_config=cfg, disable_tools="delete_file") // after client = MCPClient(name="fs", mcp_config=cfg, disable_tools=["delete_file"])
Defensive patterns
Strategy: validation
Validate before calling
disable_tools = None if disable_tools is None else [str(t) for t in disable_tools] client = MCPClient(name=n, mcp_config=cfg, disable_tools=disable_tools)
Type guard
def is_tool_name_list(v) -> bool:
return v is None or (isinstance(v, list) and all(isinstance(x, str) for x in v)) Try / catch
try:
MCPClient(name=n, mcp_config=cfg, disable_tools=disable_tools)
except ValueError:
disable_tools = list(map(str, disable_tools or [])) or None Prevention
- Mirror the enable_tools rules for disable_tools
- Validate both filters with one shared helper
- Prefer tuples->list conversion when configs come from YAML
When it happens
Trigger: MCPClient(..., disable_tools="dangerous_tool") or disable_tools=["a", None] or disable_tools=("a",).
Common situations: Symmetric with enable_tools mistakes: scalar tool name passed directly, or filters loaded from user-supplied config without normalization.
Related errors
- Enable tools should be a list of strings, but got {self.enab
- The tools in enable_tools and disable_tools should not overl
- STDIO MCP does not support ephemeral mode. Use 'shared' or '
- Invalid values for MCP {card.name!r}: {e.message}
- MCP {card.name!r} needs a value for: {', '.join(sorted(missi
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/ffa903b7dba284da.
Report an issue: GitHub.