superset_chart_update
Modify existing chart properties and visualization settings in Apache Superset through API requests to update slice names, descriptions, chart types, and parameters.
Instructions
Update an existing chart
Makes a request to the /api/v1/chart/{id} PUT endpoint to update chart properties and visualization settings.
Args: chart_id: ID of the chart to update data: Data to update, can include slice_name, description, viz_type, params, etc.
Returns: A dictionary with the updated chart information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chart_id | Yes | ||
| data | Yes |
Implementation Reference
- main.py:696-715 (handler)The handler function for the 'superset_chart_update' tool. It authenticates, handles errors, and makes a PUT request to the Superset API endpoint /api/v1/chart/{chart_id} to update the chart with the provided data.@mcp.tool() @requires_auth @handle_api_errors async def superset_chart_update( ctx: Context, chart_id: int, data: Dict[str, Any] ) -> Dict[str, Any]: """ Update an existing chart Makes a request to the /api/v1/chart/{id} PUT endpoint to update chart properties and visualization settings. Args: chart_id: ID of the chart to update data: Data to update, can include slice_name, description, viz_type, params, etc. Returns: A dictionary with the updated chart information """ return await make_api_request(ctx, "put", f"/api/v1/chart/{chart_id}", data=data)
- main.py:696-696 (registration)The @mcp.tool() decorator registers the superset_chart_update function as an MCP tool.@mcp.tool()
- main.py:271-330 (helper)The make_api_request helper function used by superset_chart_update to perform the actual API call to Superset, including authentication refresh, CSRF handling, and error management.async def make_api_request( ctx: Context, method: str, endpoint: str, data: Dict[str, Any] = None, params: Dict[str, Any] = None, auto_refresh: bool = True, ) -> Dict[str, Any]: """ Helper function to make API requests to Superset Args: ctx: MCP context method: HTTP method (get, post, put, delete) endpoint: API endpoint (without base URL) data: Optional JSON payload for POST/PUT requests params: Optional query parameters auto_refresh: Whether to auto-refresh token on 401 """ superset_ctx: SupersetContext = ctx.request_context.lifespan_context client = superset_ctx.client # For non-GET requests, make sure we have a CSRF token if method.lower() != "get" and not superset_ctx.csrf_token: await get_csrf_token(ctx) async def make_request() -> httpx.Response: headers = {} # Add CSRF token for non-GET requests if method.lower() != "get" and superset_ctx.csrf_token: headers["X-CSRFToken"] = superset_ctx.csrf_token if method.lower() == "get": return await client.get(endpoint, params=params) elif method.lower() == "post": return await client.post( endpoint, json=data, params=params, headers=headers ) elif method.lower() == "put": return await client.put(endpoint, json=data, headers=headers) elif method.lower() == "delete": return await client.delete(endpoint, headers=headers) else: raise ValueError(f"Unsupported HTTP method: {method}") # Use auto_refresh if requested response = ( await with_auto_refresh(ctx, make_request) if auto_refresh else await make_request() ) if response.status_code not in [200, 201]: return { "error": f"API request failed: {response.status_code} - {response.text}" } return response.json()