bito-code-review[bot] commented on code in PR #40347: URL: https://github.com/apache/superset/pull/40347#discussion_r3292322761
########## superset/mcp_service/plugin/tool/list_plugins.py: ########## @@ -0,0 +1,123 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +""" +List plugins FastMCP tool. +""" + +import logging + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import event_logger +from superset.mcp_service.mcp_core import ModelListCore +from superset.mcp_service.plugin.schemas import ( + ALL_PLUGIN_COLUMNS, + DEFAULT_PLUGIN_COLUMNS, + ListPluginsRequest, + PluginColumnFilter, + PluginError, + PluginInfo, + PluginList, + serialize_plugin_object, + SORTABLE_PLUGIN_COLUMNS, +) + +logger = logging.getLogger(__name__) + +_DEFAULT_LIST_PLUGINS_REQUEST = ListPluginsRequest() + + +@tool( + tags=["core"], + class_permission_name="DynamicPlugin", + annotations=ToolAnnotations( + title="List plugins", + readOnlyHint=True, + destructiveHint=False, + ), +) +async def list_plugins( + request: ListPluginsRequest | None = None, + ctx: Context | None = None, +) -> PluginList | PluginError: + """List dynamic plugins registered in this Superset instance. Requires admin access. + + Returns plugin metadata including name, key, and bundle URL. + + Sortable columns for order_column: id, name, key, changed_on, created_on + """ + if ctx is None: + raise RuntimeError("FastMCP context is required for list_plugins") + + request = request or _DEFAULT_LIST_PLUGINS_REQUEST.model_copy(deep=True) + + await ctx.info( + "Listing plugins: page=%s, page_size=%s, search=%s" + % (request.page, request.page_size, request.search) + ) + + try: + from superset.mcp_service.plugin.dao import DynamicPluginDAO + + def _serialize(obj: object, cols: list[str] | None) -> PluginInfo | None: Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Type mismatch in serializer signature</b></div> <div id="fix"> The `_serialize` function has `cols: list[str] | None` but `ModelListCore` expects `item_serializer: Callable[[T, List[str]], S | None]` where the second argument is `List[str]` (non-optional). The `cols` parameter is also unused in the function body. </div> <details> <summary> <b>Code suggestion</b> </summary> <blockquote>Check the AI-generated fix before applying</blockquote> <div id="code"> ``` --- a/superset/mcp_service/plugin/tool/list_plugins.py +++ b/superset/mcp_service/plugin/tool/list_plugins.py @@ -75,7 +75,7 @@ async def list_plugins( from superset.mcp_service.plugin.dao import DynamicPluginDAO - def _serialize(obj: object, cols: list[str] | None) -> PluginInfo | None: + def _serialize(obj: object, cols: list[str]) -> PluginInfo | None: return serialize_plugin_object(obj) list_tool = ModelListCore( ``` </div> </details> </div> <small><i>Code Review Run #f6e20e</i></small> </div> --- Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>) - [ ] Yes, avoid them -- 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]
