fix: enable tool mode only if a server is selected (#8865)

* Enable tool mode only if a server is selected

* Set tool mode as false when mcp server is cleared

* Added bool to build config tool show
This commit is contained in:
Lucas Oliveira 2025-07-03 15:34:51 -03:00 committed by GitHub
commit 1fdeefda1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -120,7 +120,7 @@ class MCPToolsComponent(ComponentWithCache):
info="Placeholder for the tool",
value="",
show=False,
tool_mode=True,
tool_mode=False,
),
]
@ -280,9 +280,12 @@ class MCPToolsComponent(ComponentWithCache):
build_config["tool"]["options"] = []
build_config["tool"]["value"] = ""
build_config["tool"]["placeholder"] = ""
build_config["tool_placeholder"]["tool_mode"] = False
self.remove_non_default_keys(build_config)
return build_config
build_config["tool_placeholder"]["tool_mode"] = True
current_server_name = field_value.get("name") if isinstance(field_value, dict) else field_value
_last_selected_server = self._shared_component_cache.get("last_selected_server") or ""
@ -329,7 +332,7 @@ class MCPToolsComponent(ComponentWithCache):
elif field_name == "tool_mode":
build_config["tool"]["placeholder"] = ""
build_config["tool"]["show"] = not field_value
build_config["tool"]["show"] = not bool(field_value) and bool(build_config["mcp_server"])
self.remove_non_default_keys(build_config)
self.tool = build_config["tool"]["value"]
if field_value: