codeant-ai-for-open-source[bot] commented on code in PR #39922:
URL: https://github.com/apache/superset/pull/39922#discussion_r3398659712


##########
superset/mcp_service/flask_singleton.py:
##########
@@ -51,6 +51,16 @@
         logger.info("Reusing existing Flask app from app context for MCP 
service")
         # Use _get_current_object() to get the actual Flask app, not the 
LocalProxy
         app = current_app._get_current_object()
+
+        # Configure the chart plugin registry from the host app's config.
+        # This module is the registry's only configure site — core Superset
+        # startup must not import mcp_service (fastmcp is an optional extra).
+        from superset.mcp_service.chart import registry as _chart_registry
+
+        _chart_registry.configure(
+            disabled=app.config.get("MCP_DISABLED_CHART_PLUGINS"),
+            enabled_func=app.config.get("MCP_CHART_PLUGIN_ENABLED_FUNC"),
+        )

Review Comment:
   **Suggestion:** Chart plugin filtering is only configured in this module, 
but the `run_server(..., use_factory_config=True)` startup path builds the MCP 
app through `create_mcp_app()` and never imports `flask_singleton`, so 
`MCP_DISABLED_CHART_PLUGINS` / `MCP_CHART_PLUGIN_ENABLED_FUNC` are silently 
ignored in that mode. Move registry configuration to a startup path shared by 
both server modes (or invoke the same configure step from the factory-config 
path) so plugin enable/disable rules are consistently enforced. [incomplete 
implementation]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Factory-config MCP servers ignore MCP_DISABLED_CHART_PLUGINS settings.
   - ⚠️ Dynamic MCP_CHART_PLUGIN_ENABLED_FUNC never applied in factory mode.
   - ⚠️ Operators cannot reliably kill specific chart types there.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure chart plugin filters as documented in 
`superset/mcp_service/mcp_config.py`:
   set `MCP_DISABLED_CHART_PLUGINS` / `MCP_CHART_PLUGIN_ENABLED_FUNC` (defaults 
defined at
   lines 111–115, and exported into Flask config by `get_mcp_config()` at lines 
23–51).
   
   2. Start the MCP HTTP server via the factory-config path by calling
   `run_server(use_factory_config=True)` in 
`superset/mcp_service/server.py:774-806`. This
   branch calls `get_mcp_factory_config()` and then 
`create_mcp_app(**factory_config)` (lines
   804–806) and explicitly does NOT import 
`superset.mcp_service.flask_singleton` or call
   `get_flask_app()`.
   
   3. Because `flask_singleton` is never imported in this startup mode, the 
module-level
   initialization in `superset/mcp_service/flask_singleton.py:35-113` does not 
run, so the
   two `_chart_registry.configure(...)` calls at lines 55–63 and 94–103 (the 
only
   `registry.configure()` sites found via Grep) are never executed. The chart 
registry
   therefore retains its default filter config (`_filter_config = 
_PluginFilterConfig()` with
   no disabled plugins and no enabled_func) as defined in
   `superset/mcp_service/chart/registry.py:64-71`.
   
   4. From a client, invoke a chart-generating MCP tool such as 
`generate_explore_link`,
   whose handler in 
`superset/mcp_service/explore/tool/generate_explore_link.py:188-28` calls
   `map_config_to_form_data()` in 
`superset/mcp_service/chart/chart_utils.py:315-332`. That
   function uses `get_registry().get(chart_type)` (line 337) to resolve the 
plugin. Because
   `configure()` was never called in the factory-config server, 
`_is_plugin_enabled()` in
   `registry.py:137-151` still sees an empty disabled set and 
`enabled_func=None`, so even
   chart types listed in `MCP_DISABLED_CHART_PLUGINS` or rejected by
   `MCP_CHART_PLUGIN_ENABLED_FUNC` remain enabled. The operator's plugin filter 
settings are
   silently ignored in this startup mode, while they are honored when using the 
default
   `run_server(use_factory_config=False)` path that imports `get_flask_app()` 
and triggers
   `flask_singleton`'s registry configuration.
   ```
   </details>
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b9e9d59765234b53986dff92d5c30030&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=b9e9d59765234b53986dff92d5c30030&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/flask_singleton.py
   **Line:** 55:63
   **Comment:**
        *Incomplete Implementation: Chart plugin filtering is only configured 
in this module, but the `run_server(..., use_factory_config=True)` startup path 
builds the MCP app through `create_mcp_app()` and never imports 
`flask_singleton`, so `MCP_DISABLED_CHART_PLUGINS` / 
`MCP_CHART_PLUGIN_ENABLED_FUNC` are silently ignored in that mode. Move 
registry configuration to a startup path shared by both server modes (or invoke 
the same configure step from the factory-config path) so plugin enable/disable 
rules are consistently enforced.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39922&comment_hash=9fd7046eeaadacebfa1c0f564c1e467a8d9894b36e9bfc7994561fe0f54fe4f4&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39922&comment_hash=9fd7046eeaadacebfa1c0f564c1e467a8d9894b36e9bfc7994561fe0f54fe4f4&reaction=dislike'>👎</a>



-- 
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