aminghadersohi opened a new pull request, #37183: URL: https://github.com/apache/superset/pull/37183
### SUMMARY Add support for `form_data_key` (Explore) and `permalink_key` (Dashboard) parameters in MCP tools to retrieve unsaved/temporary state. **Problem:** When a user edits a chart in Explore (changes type, metrics, etc.) but doesn't save, the current state is stored with a `form_data_key`. Similarly, when users apply filters in a dashboard, the state can be persisted in a `permalink_key`. The MCP tools were previously unaware of these keys and would only retrieve the saved version of charts/dashboards. This meant when users asked the chatbot to explain a chart they were editing, it would describe the saved version rather than what the user actually sees. **Solution:** - Add `form_data_key` parameter to chart tools (`get_chart_info`, `get_chart_data`, `get_chart_preview`) to retrieve unsaved chart configuration from cache - Add `permalink_key` parameter to `get_dashboard_info` to retrieve dashboard filter state from permalink - Add `is_unsaved_state`/`is_permalink_state` flags to indicate when data came from cache vs saved version **Changes:** - `superset/mcp_service/chart/schemas.py`: Add `form_data_key` to request schemas, add `is_unsaved_state` and `form_data_key` to `ChartInfo` - `superset/mcp_service/chart/tool/get_chart_info.py`: Retrieve cached form_data when `form_data_key` provided - `superset/mcp_service/chart/tool/get_chart_data.py`: Build query context from cached form_data - `superset/mcp_service/dashboard/schemas.py`: Add `permalink_key` to request schema, add `filter_state` and `is_permalink_state` to `DashboardInfo` - `superset/mcp_service/dashboard/tool/get_dashboard_info.py`: Retrieve filter state from permalink ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A - API changes only ### TESTING INSTRUCTIONS 1. Start Superset with MCP service enabled 2. Create or open an existing chart in Explore 3. Make changes to the chart (e.g., change viz type, metrics) without saving 4. Copy the `form_data_key` from the URL 5. Call `get_chart_info` with the chart ID and the `form_data_key` 6. Verify the response contains `is_unsaved_state: true` and the `form_data` reflects the unsaved changes For dashboards: 1. Open a dashboard and apply filters 2. Copy the `permalink_key` from the URL (if using permalinks) 3. Call `get_dashboard_info` with the dashboard ID and the `permalink_key` 4. Verify the response contains `is_permalink_state: true` and `filter_state` with the applied filters ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [x] Introduces new feature or API - [ ] Removes existing feature or API 🤖 Generated with [Claude Code](https://claude.ai/code) -- 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]
