agentscope-ai/agentscope · error · ValueError
The tools in enable_tools and disable_tools should not overl
Error message
The tools in enable_tools and disable_tools should not overlap, but got {intersection}. What it means
MCPClient rejects configurations where a tool name appears in both enable_tools and disable_tools, since the filter behavior would be ambiguous. The error message includes the overlapping tool names.
Source
Thrown at src/agentscope/mcp/_mcp_client.py:159
"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:
"""Pre-build the stdio client context manager."""
if self.mcp_config.type == "stdio_mcp":
config = self.mcp_config
self._client = stdio_client(
StdioServerParameters(
command=config.command,
args=config.args or [],
env=config.env,
cwd=str(config.cwd) if config.cwd else None,
encoding="utf-8",View on GitHub (pinned to e90f1c7592)
Solutions
- Remove the overlapping tool(s) listed in the error from either enable_tools or disable_tools
- If both lists come from separate configs, deduplicate/intersect-check before constructing MCPClient
Example fix
// before
client = MCPClient(name="m", mcp_config=cfg,
enable_tools=["search", "fetch"],
disable_tools=["fetch"],
)
// after
client = MCPClient(name="m", mcp_config=cfg,
enable_tools=["search", "fetch"],
disable_tools=["delete"],
) Defensive patterns
Strategy: validation
Validate before calling
if enable_tools and disable_tools:
overlap = set(enable_tools) & set(disable_tools)
assert not overlap, f"tools in both filters: {overlap}"
client = MCPClient(name=n, mcp_config=cfg, enable_tools=enable_tools, disable_tools=disable_tools) Try / catch
try:
MCPClient(name=n, mcp_config=cfg, enable_tools=en, disable_tools=dis)
except ValueError as e:
if "should not overlap" in str(e):
dis = [t for t in dis if t not in set(en)] Prevention
- Treat enable_tools as the authoritative allowlist and derive disable_tools by difference
- Validate config composition when merging MCP filter settings from multiple sources
- Unit-test filter configs for disjointness
When it happens
Trigger: MCPClient(..., enable_tools=["search", "fetch"], disable_tools=["fetch"]) — any non-empty intersection of the two lists.
Common situations: Appending to one filter list during development while forgetting the tool is already in the other; merging filter configs from multiple sources; copy-paste between enable and disable blocks.
Related errors
- Enable tools should be a list of strings, but got {self.enab
- Disable tools should be a list of strings, but got {self.dis
- 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/414a4958dfdaaf81.
Report an issue: GitHub.