sadpandajoe commented on code in PR #43842:
URL: https://github.com/apache/superset/pull/43842#discussion_r4202067220
##########
superset/core/mcp/core_mcp_injection.py:
##########
@@ -181,6 +197,12 @@ def create_tool_decorator(
"""
def decorator(func: F) -> Callable[..., Any]:
+ # Skip registration when the MCP service app is not loaded in this
+ # process, so applying @tool never imports the heavy host-tool stack
+ # (see the module-level note on _MCP_SERVICE_APP_MODULE).
+ if not _mcp_host_tools_loaded():
Review Comment:
With the flag off, `@tool`/`@prompt` quietly return the bare function
whenever `superset.mcp_service.app` isn't in `sys.modules` yet, and nothing
replays them once it is imported later. So a process that runs `superset mcp
run` with `CORE_MCP_HOST_TOOLS_ENABLED = False` (e.g. one shared config) builds
the Flask app and eager-imports extensions first, then imports the MCP server;
the extension's tools/prompts are dropped with no log while the built-in tools
register, and the server comes up missing them. Should this at least log a
warning when it skips a decoration, or should the standalone MCP entrypoint
force host-tool loading regardless of the flag?
##########
superset/core/mcp/core_mcp_injection.py:
##########
@@ -396,6 +433,18 @@ def initialize_core_mcp_dependencies() -> None:
logger.info("MCP dependency injection initialized successfully")
+
+def initialize_core_mcp_host_tools() -> None:
Review Comment:
When `fastmcp` isn't installed, `initialize_core_mcp_decorators()` logs the
info-level skip and returns, but `init_core_dependencies()` (and the compat
wrapper) still call this function under the default flag. `from
superset.mcp_service import app` then fails on `from fastmcp import FastMCP`,
so every startup on an install without the `fastmcp` extra now logs `Failed to
register MCP host tools` at ERROR, where before it was a quiet skip. Should the
host-tool import keep the same fastmcp-availability guard, or should the
decorators step report whether it ran?
--
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]