{"record":{"id":"414a4958dfdaaf81","repo":"agentscope-ai/agentscope","slug":"the-tools-in-enable-tools-and-disable-tools-should","errorCode":null,"errorMessage":"The tools in enable_tools and disable_tools should not overlap, but got {intersection}.","messagePattern":"The tools in enable_tools and disable_tools should not overlap, but got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/agentscope/mcp/_mcp_client.py","lineNumber":159,"sourceCode":"                    \"Enable tools should be a list of strings, but got \"\n                    f\"{self.enable_tools}.\",\n                )\n\n        if self.disable_tools is not None:\n            if not isinstance(self.disable_tools, list) or any(\n                not isinstance(_, str) for _ in self.disable_tools\n            ):\n                raise ValueError(\n                    \"Disable tools should be a list of strings, but got \"\n                    f\"{self.disable_tools}.\",\n                )\n\n        if self.enable_tools is not None and self.disable_tools is not None:\n            intersection = set(self.enable_tools).intersection(\n                set(self.disable_tools),\n            )\n            if len(intersection) != 0:\n                raise ValueError(\n                    f\"The tools in enable_tools and disable_tools \"\n                    f\"should not overlap, but got {intersection}.\",\n                )\n\n        # Initialize the underlying client\n        self._initialize_client()\n\n    def _initialize_client(self) -> None:\n        \"\"\"Pre-build the stdio client context manager.\"\"\"\n        if self.mcp_config.type == \"stdio_mcp\":\n            config = self.mcp_config\n            self._client = stdio_client(\n                StdioServerParameters(\n                    command=config.command,\n                    args=config.args or [],\n                    env=config.env,\n                    cwd=str(config.cwd) if config.cwd else None,\n                    encoding=\"utf-8\",","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/mcp/_mcp_client.py#L141-L177","documentation":"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.","triggerScenarios":"MCPClient(..., enable_tools=[\"search\", \"fetch\"], disable_tools=[\"fetch\"]) — any non-empty intersection of the two lists.","commonSituations":"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.","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"],"exampleFix":"// before\nclient = MCPClient(name=\"m\", mcp_config=cfg,\n    enable_tools=[\"search\", \"fetch\"],\n    disable_tools=[\"fetch\"],\n)\n\n// after\nclient = MCPClient(name=\"m\", mcp_config=cfg,\n    enable_tools=[\"search\", \"fetch\"],\n    disable_tools=[\"delete\"],\n)","handlingStrategy":"validation","validationCode":"if enable_tools and disable_tools:\n    overlap = set(enable_tools) & set(disable_tools)\n    assert not overlap, f\"tools in both filters: {overlap}\"\nclient = MCPClient(name=n, mcp_config=cfg, enable_tools=enable_tools, disable_tools=disable_tools)","typeGuard":null,"tryCatchPattern":"try:\n    MCPClient(name=n, mcp_config=cfg, enable_tools=en, disable_tools=dis)\nexcept ValueError as e:\n    if \"should not overlap\" in str(e):\n        dis = [t for t in dis if t not in set(en)]","preventionTips":["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"],"tags":["mcp","conflicting-config","tool-filtering"],"backgroundTag":"conflicting-configuration-options","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}