codeant-ai-for-open-source[bot] commented on code in PR #41472: URL: https://github.com/apache/superset/pull/41472#discussion_r3555942622
########## superset/mcp_service/dashboard/tool/delete_dashboard.py: ########## @@ -0,0 +1,166 @@ +# 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. + +""" +MCP tool: delete_dashboard +""" + +import logging +from typing import Any + +from fastmcp import Context +from sqlalchemy.exc import SQLAlchemyError +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.commands.dashboard.exceptions import ( + DashboardDeleteFailedReportsExistError, + DashboardForbiddenError, + DashboardNotFoundError, +) +from superset.commands.exceptions import CommandException +from superset.extensions import event_logger +from superset.mcp_service.dashboard.schemas import ( + DeleteDashboardRequest, + DeleteDashboardResponse, +) +from superset.mcp_service.utils import escape_llm_context_delimiters + +logger = logging.getLogger(__name__) + + +def _find_dashboard_by_identifier(identifier: int | str) -> Any | None: + """Resolve a dashboard by numeric ID, UUID string, or slug. Returns None.""" + from superset.daos.dashboard import DashboardDAO + + if isinstance(identifier, int) or ( + isinstance(identifier, str) and identifier.isdigit() + ): + return DashboardDAO.find_by_id(int(identifier)) Review Comment: ✅ **Customized review instruction saved!** **Instruction:** > Do not flag digit-only dashboard identifiers resolving as numeric IDs first in dashboard tool code; this precedence matches DashboardDAO.get_by_id_or_slug and the existing REST API semantics. **Applied to:** - `superset/mcp_service/dashboard/tool/**` --- 💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)* ########## superset/mcp_service/dashboard/schemas.py: ########## @@ -1528,3 +1528,30 @@ def dashboard_layout_serializer(dashboard: "Dashboard") -> DashboardLayout: has_layout=bool(position_json_str), ) ) + + +class DeleteDashboardRequest(BaseModel): + """Request schema for delete_dashboard.""" + + identifier: int | str = Field( + ..., + description="Dashboard identifier - numeric ID, UUID string, or slug.", + ) + + +class DeleteDashboardResponse(BaseModel): + """Result of a delete_dashboard operation.""" + + success: bool = Field(description="Whether the dashboard was deleted") + deleted_id: int | None = Field(None, description="ID of the deleted dashboard") Review Comment: ✅ **Customized review instruction saved!** **Instruction:** > In the MCP service surface, keep numeric IDs as the primary handle when the existing list/get/update/delete APIs already use them consistently; do not require UUID-only response fields for individual tools. **Applied to:** - `superset/mcp_service/**` --- 💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)* ########## superset/mcp_service/chart/schemas.py: ########## @@ -2550,3 +2550,32 @@ class ChartFiltersInfo(BaseModel): # Rebuild ChartInfo so Pydantic can resolve the ChartFiltersInfo forward reference. ChartInfo.model_rebuild() + + +class DeleteChartRequest(BaseModel): + """Request schema for delete_chart.""" + + identifier: int | str = Field( + ..., + description=( + "Chart identifier - numeric ID or UUID string (charts have no slug)." + ), + ) Review Comment: ✅ **Customized review instruction saved!** **Instruction:** > Do not require UUID-only identifiers in individual MCP tool request schemas when the broader MCP surface still uses numeric IDs; UUID-first changes should only be enforced once the entire surface is migrated consistently. **Applied to:** - `superset/mcp_service/**` --- 💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)* ########## superset/mcp_service/chart/schemas.py: ########## @@ -2550,3 +2550,32 @@ class ChartFiltersInfo(BaseModel): # Rebuild ChartInfo so Pydantic can resolve the ChartFiltersInfo forward reference. ChartInfo.model_rebuild() + + +class DeleteChartRequest(BaseModel): + """Request schema for delete_chart.""" + + identifier: int | str = Field( + ..., + description=( + "Chart identifier - numeric ID or UUID string (charts have no slug)." + ), + ) + + +class DeleteChartResponse(BaseModel): + """Result of a delete_chart operation.""" + + success: bool = Field(description="Whether the chart was deleted") + deleted_id: int | None = Field(None, description="ID of the deleted chart") Review Comment: ✅ **Customized review instruction saved!** **Instruction:** > Avoid flagging numeric ID fields in MCP tool responses when those IDs are the primary handle across the tool surface (e.g. list/get/update/delete all use them); UUID-first changes should be evaluated surface-wide, not per individual tool. **Applied to:** - `superset/mcp_service/**` --- 💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)* ########## superset/mcp_service/chart/schemas.py: ########## @@ -2695,3 +2695,32 @@ class ChartFiltersInfo(BaseModel): # Rebuild ChartInfo so Pydantic can resolve the ChartFiltersInfo forward reference. ChartInfo.model_rebuild() + + +class DeleteChartRequest(BaseModel): + """Request schema for delete_chart.""" + + identifier: int | str = Field( + ..., + description=( + "Chart identifier - numeric ID or UUID string (charts have no slug)." + ), + ) Review Comment: ✅ **Customized review instruction saved!** **Instruction:** > Do not enforce UUID-only identifiers on individual MCP service tools when the surface already uses numeric IDs as the primary handle; keep supporting both numeric IDs and UUIDs for consistency across the toolset. **Applied to:** - `superset/mcp_service/**` --- 💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)* ########## superset/mcp_service/chart/schemas.py: ########## @@ -2695,3 +2695,32 @@ class ChartFiltersInfo(BaseModel): # Rebuild ChartInfo so Pydantic can resolve the ChartFiltersInfo forward reference. ChartInfo.model_rebuild() + + +class DeleteChartRequest(BaseModel): + """Request schema for delete_chart.""" + + identifier: int | str = Field( + ..., + description=( + "Chart identifier - numeric ID or UUID string (charts have no slug)." + ), + ) + + +class DeleteChartResponse(BaseModel): + """Result of a delete_chart operation.""" + + success: bool = Field(description="Whether the chart was deleted") + deleted_id: int | None = Field(None, description="ID of the deleted chart") Review Comment: ✅ **Customized review instruction saved!** **Instruction:** > Do not flag integer identifiers in MCP service response contracts when the MCP surface uses numeric IDs end-to-end; apply UUID-first guidance only after the entire surface has migrated. **Applied to:** - `superset/mcp_service/**` --- 💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)* -- 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]
