aminghadersohi opened a new pull request, #40773: URL: https://github.com/apache/superset/pull/40773
### SUMMARY The `generate_explore_link` MCP tool was returning URLs like `/explore/?form_data_key=<key>` where the key is stored in Redis cache and expires in ~24h. This caused two problems for LLM-based workflows: 1. **Broken URLs after expiry**: The chart config is not embedded in the URL itself, so when the key expires the URL becomes unreachable and the LLM cannot reconstruct it. 2. **LLM cannot inspect config from URL**: The `form_data_key` is opaque — an LLM building charts iteratively cannot read back the current configuration from the URL to revise it. This fix changes the URL strategy to use Superset's **explore permalink** mechanism, which stores chart state in the key-value DB table (not Redis) and does not expire. The resulting URL is `/explore/p/<key>/` — bookmarkable, shareable, and reconstructible. **Fallback chain:** 1. `CreateExplorePermalinkCommand` (DB-backed, durable) → `/explore/p/<key>/` 2. `MCPCreateFormDataCommand` (Redis-backed, ephemeral) on permalink failure 3. Plain dataset URL (`/explore/?datasource_type=table&datasource_id=<id>`) on both failing **Response schema change:** adds `permalink_key` (populated for durable URLs) alongside the existing `form_data_key` (now only populated in the Redis-fallback case). ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF **Before:** `http://host/explore/?form_data_key=L-6rhlg-CSY` — expires in ~24h, config not in URL **After:** `http://host/explore/p/1OkEh0GK5e9lFKVMCGqEG1/` — permanent, DB-backed permalink ### TESTING INSTRUCTIONS 1. Enable MCP in Superset config 2. Call `generate_explore_link` MCP tool with a dataset ID and chart config 3. Verify the returned URL is `/explore/p/<key>/` format 4. Verify the URL remains accessible after Redis cache expiry 5. Run unit tests: `pytest tests/unit_tests/mcp_service/explore/tool/test_generate_explore_link.py -x -q` ### 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 -- 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]
