eschutho commented on code in PR #43842:
URL: https://github.com/apache/superset/pull/43842#discussion_r3946661222


##########
superset/initialization/__init__.py:
##########
@@ -558,7 +558,12 @@ def init_core_dependencies(self) -> None:
         )
 
         initialize_core_api_dependencies()
-        initialize_core_mcp_dependencies()
+        # MCP host tools only need to be registered in processes that serve MCP
+        # (the web app and the standalone MCP service). Deployments can disable
+        # this in processes that never serve MCP -- e.g. Celery workers -- to
+        # avoid importing the MCP stack where it is unused.
+        if self.config.get("CORE_MCP_HOST_TOOLS_ENABLED", True):
+            initialize_core_mcp_dependencies()

Review Comment:
   Fixed in f2009f2 — thanks for catching this, and confirming 
@aminghadersohi's open question from the review.
   
   You're right: the abstract `tool`/`prompt` in `superset_core.mcp.decorators` 
**do** raise `NotImplementedError` (verified against the source — both bodies 
are literally `raise NotImplementedError("MCP ... decorator not initialized. 
...")`). So with the previous all-or-nothing gate, a process with 
`CORE_MCP_HOST_TOOLS_ENABLED=False` that loaded an extension applying 
`@tool`/`@prompt` at import time would have crashed at import.
   
   `initialize_core_mcp_dependencies()` is now split into two independent steps:
   
   - `initialize_core_mcp_decorators()` — swaps the abstract decorators for the 
concrete ones. Runs **unconditionally** in `init_core_dependencies()`, so 
`@tool`/`@prompt` extensions keep working in every process (workers included). 
Cheap: no `superset.mcp_service` import.
   - `initialize_core_mcp_host_tools()` — does `from superset.mcp_service 
import app` (the memory-heavy host-tool registration that OOMed the workers). 
This is the only part now gated on the flag.
   
   Verified end to end: before init, `@tool` raises `NotImplementedError`; 
after `initialize_core_mcp_decorators()`, `superset_core.mcp.decorators.tool` 
is `create_tool_decorator` and decoration no longer raises — with the host-tool 
import still skipped when the flag is off.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to